26 #define CALLED_AS_TRIGGER(fcinfo) \
27 ((fcinfo)->context != NULL && IsA((fcinfo)->context, TriggerData))
92 #define TRIGGER_EVENT_INSERT 0x00000000
93 #define TRIGGER_EVENT_DELETE 0x00000001
94 #define TRIGGER_EVENT_UPDATE 0x00000002
95 #define TRIGGER_EVENT_TRUNCATE 0x00000003
96 #define TRIGGER_EVENT_OPMASK 0x00000003
98 #define TRIGGER_EVENT_ROW 0x00000004
100 #define TRIGGER_EVENT_BEFORE 0x00000008
101 #define TRIGGER_EVENT_AFTER 0x00000000
102 #define TRIGGER_EVENT_INSTEAD 0x00000010
103 #define TRIGGER_EVENT_TIMINGMASK 0x00000018
107 #define AFTER_TRIGGER_DEFERRABLE 0x00000020
108 #define AFTER_TRIGGER_INITDEFERRED 0x00000040
110 #define TRIGGER_FIRED_BY_INSERT(event) \
111 (((event) & TRIGGER_EVENT_OPMASK) == TRIGGER_EVENT_INSERT)
113 #define TRIGGER_FIRED_BY_DELETE(event) \
114 (((event) & TRIGGER_EVENT_OPMASK) == TRIGGER_EVENT_DELETE)
116 #define TRIGGER_FIRED_BY_UPDATE(event) \
117 (((event) & TRIGGER_EVENT_OPMASK) == TRIGGER_EVENT_UPDATE)
119 #define TRIGGER_FIRED_BY_TRUNCATE(event) \
120 (((event) & TRIGGER_EVENT_OPMASK) == TRIGGER_EVENT_TRUNCATE)
122 #define TRIGGER_FIRED_FOR_ROW(event) \
123 ((event) & TRIGGER_EVENT_ROW)
125 #define TRIGGER_FIRED_FOR_STATEMENT(event) \
126 (!TRIGGER_FIRED_FOR_ROW(event))
128 #define TRIGGER_FIRED_BEFORE(event) \
129 (((event) & TRIGGER_EVENT_TIMINGMASK) == TRIGGER_EVENT_BEFORE)
131 #define TRIGGER_FIRED_AFTER(event) \
132 (((event) & TRIGGER_EVENT_TIMINGMASK) == TRIGGER_EVENT_AFTER)
134 #define TRIGGER_FIRED_INSTEAD(event) \
135 (((event) & TRIGGER_EVENT_TIMINGMASK) == TRIGGER_EVENT_INSTEAD)
140 #define SESSION_REPLICATION_ROLE_ORIGIN 0
141 #define SESSION_REPLICATION_ROLE_REPLICA 1
142 #define SESSION_REPLICATION_ROLE_LOCAL 2
149 #define TRIGGER_FIRES_ON_ORIGIN 'O'
150 #define TRIGGER_FIRES_ALWAYS 'A'
151 #define TRIGGER_FIRES_ON_REPLICA 'R'
152 #define TRIGGER_DISABLED 'D'
155 Oid relOid,
Oid refRelOid,
Oid constraintOid,
Oid indexOid,
156 Oid funcoid,
Oid parentTriggerOid,
Node *whenClause,
157 bool isInternal,
bool in_partition);
159 Oid relOid,
Oid refRelOid,
Oid constraintOid,
160 Oid indexOid,
Oid funcoid,
Oid parentTriggerOid,
161 Node *whenClause,
bool isInternal,
bool in_partition,
162 char trigger_fires_when);
174 char fires_when,
bool skip_system,
bool recurse,
199 List *recheckIndexes,
222 bool is_crosspart_update);
246 List *recheckIndexes,
248 bool is_crosspart_update);
282 #define RI_TRIGGER_PK 1
283 #define RI_TRIGGER_FK 2
284 #define RI_TRIGGER_NONE 0
struct AfterTriggersTableData * tcs_private
TupleTableSlot * tcs_original_insert_tuple
bool tcs_update_new_table
bool tcs_delete_old_table
bool tcs_insert_new_table
bool tcs_update_old_table
Tuplestorestate * tg_oldtable
const Bitmapset * tg_updatedcols
Tuplestorestate * tg_newtable
TupleTableSlot * tg_trigslot
TupleTableSlot * tg_newslot
bool ExecBRUpdateTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot *newslot, TM_Result *tmresult, TM_FailureData *tmfd)
void AfterTriggerBeginXact(void)
void ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TransitionCaptureState *transition_capture, bool is_crosspart_update)
void ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo)
bool ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
void AfterTriggerEndSubXact(bool isCommit)
bool RI_FKey_pk_upd_check_required(Trigger *trigger, Relation pk_rel, TupleTableSlot *oldslot, TupleTableSlot *newslot)
void ExecBSTruncateTriggers(EState *estate, ResultRelInfo *relinfo)
PGDLLIMPORT int SessionReplicationRole
void FreeTriggerDesc(TriggerDesc *trigdesc)
bool ExecIRDeleteTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple)
void ExecBSDeleteTriggers(EState *estate, ResultRelInfo *relinfo)
void EnableDisableTrigger(Relation rel, const char *tgname, Oid tgparent, char fires_when, bool skip_system, bool recurse, LOCKMODE lockmode)
bool ExecIRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
TriggerDesc * CopyTriggerDesc(TriggerDesc *trigdesc)
void ExecASTruncateTriggers(EState *estate, ResultRelInfo *relinfo)
const char * FindTriggerIncompatibleWithInheritance(TriggerDesc *trigdesc)
void ExecARUpdateTriggers(EState *estate, ResultRelInfo *relinfo, ResultRelInfo *src_partinfo, ResultRelInfo *dst_partinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot *newslot, List *recheckIndexes, TransitionCaptureState *transition_capture, bool is_crosspart_update)
void AfterTriggerSetState(ConstraintsSetStmt *stmt)
Oid get_trigger_oid(Oid relid, const char *trigname, bool missing_ok)
ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char *queryString, Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid, Oid funcoid, Oid parentTriggerOid, Node *whenClause, bool isInternal, bool in_partition)
struct TriggerData TriggerData
void ExecASUpdateTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
void ExecASDeleteTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
bool ExecBRDeleteTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot **epqslot, TM_Result *tmresult, TM_FailureData *tmfd)
ObjectAddress renametrig(RenameStmt *stmt)
void AfterTriggerFireDeferred(void)
void ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot, List *recheckIndexes, TransitionCaptureState *transition_capture)
void TriggerSetParentTrigger(Relation trigRel, Oid childTrigId, Oid parentTrigId, Oid childTableId)
struct TransitionCaptureState TransitionCaptureState
TransitionCaptureState * MakeTransitionCaptureState(TriggerDesc *trigdesc, Oid relid, CmdType cmdType)
void ExecASInsertTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
ObjectAddress CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid, Oid funcoid, Oid parentTriggerOid, Node *whenClause, bool isInternal, bool in_partition, char trigger_fires_when)
bool ExecIRUpdateTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple, TupleTableSlot *newslot)
void AfterTriggerEndXact(bool isCommit)
bool AfterTriggerPendingOnRel(Oid relid)
bool RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
void RelationBuildTriggers(Relation relation)
void AfterTriggerBeginSubXact(void)
void RI_PartitionRemove_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
bool RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel, TupleTableSlot *oldslot, TupleTableSlot *newslot)
int RI_FKey_trigger_type(Oid tgfoid)
void AfterTriggerEndQuery(EState *estate)
void RemoveTriggerById(Oid trigOid)
void ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo)
void AfterTriggerBeginQuery(void)