PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/relation.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/partition.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "commands/trigger.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "nodes/bitmapset.h"
#include "nodes/makefuncs.h"
#include "optimizer/optimizer.h"
#include "parser/parse_clause.h"
#include "parser/parse_collate.h"
#include "parser/parse_func.h"
#include "parser/parse_relation.h"
#include "partitioning/partdesc.h"
#include "pgstat.h"
#include "rewrite/rewriteManip.h"
#include "storage/lmgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc_hooks.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/plancache.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
#include "utils/tuplestore.h"
Go to the source code of this file.
Data Structures | |
struct | SetConstraintTriggerData |
struct | SetConstraintStateData |
struct | AfterTriggerSharedData |
struct | AfterTriggerEventData |
struct | AfterTriggerEventDataNoOids |
struct | AfterTriggerEventDataOneCtid |
struct | AfterTriggerEventDataZeroCtids |
struct | AfterTriggerEventChunk |
struct | AfterTriggerEventList |
struct | AfterTriggersData |
struct | AfterTriggersQueryData |
struct | AfterTriggersTransData |
struct | AfterTriggersTableData |
Macros | |
#define | AFTER_TRIGGER_OFFSET 0x07FFFFFF /* must be low-order bits */ |
#define | AFTER_TRIGGER_DONE 0x80000000 |
#define | AFTER_TRIGGER_IN_PROGRESS 0x40000000 |
#define | AFTER_TRIGGER_FDW_REUSE 0x00000000 |
#define | AFTER_TRIGGER_FDW_FETCH 0x20000000 |
#define | AFTER_TRIGGER_1CTID 0x10000000 |
#define | AFTER_TRIGGER_2CTID 0x30000000 |
#define | AFTER_TRIGGER_CP_UPDATE 0x08000000 |
#define | AFTER_TRIGGER_TUP_BITS 0x38000000 |
#define | SizeofTriggerEvent(evt) |
#define | GetTriggerSharedData(evt) ((AfterTriggerShared) ((char *) (evt) + ((evt)->ate_flags & AFTER_TRIGGER_OFFSET))) |
#define | CHUNK_DATA_START(cptr) ((char *) (cptr) + MAXALIGN(sizeof(AfterTriggerEventChunk))) |
#define | for_each_chunk(cptr, evtlist) for (cptr = (evtlist).head; cptr != NULL; cptr = cptr->next) |
#define | for_each_event(eptr, cptr) |
#define | for_each_event_chunk(eptr, cptr, evtlist) for_each_chunk(cptr, evtlist) for_each_event(eptr, cptr) |
#define | for_each_chunk_from(cptr) for (; cptr != NULL; cptr = cptr->next) |
#define | for_each_event_from(eptr, cptr) |
#define | MIN_CHUNK_SIZE 1024 |
#define | MAX_CHUNK_SIZE (1024*1024) |
Variables | |
int | SessionReplicationRole = SESSION_REPLICATION_ROLE_ORIGIN |
static int | MyTriggerDepth = 0 |
static AfterTriggersData | afterTriggers |
#define AFTER_TRIGGER_OFFSET 0x07FFFFFF /* must be low-order bits */ |
#define CHUNK_DATA_START | ( | cptr | ) | ((char *) (cptr) + MAXALIGN(sizeof(AfterTriggerEventChunk))) |
#define for_each_event | ( | eptr, | |
cptr | |||
) |
#define for_each_event_chunk | ( | eptr, | |
cptr, | |||
evtlist | |||
) | for_each_chunk(cptr, evtlist) for_each_event(eptr, cptr) |
#define for_each_event_from | ( | eptr, | |
cptr | |||
) |
#define GetTriggerSharedData | ( | evt | ) | ((AfterTriggerShared) ((char *) (evt) + ((evt)->ate_flags & AFTER_TRIGGER_OFFSET))) |
#define MAX_CHUNK_SIZE (1024*1024) |
#define MIN_CHUNK_SIZE 1024 |
#define SizeofTriggerEvent | ( | evt | ) |
typedef struct AfterTriggerEventData* AfterTriggerEvent |
typedef struct AfterTriggerEventChunk AfterTriggerEventChunk |
typedef struct AfterTriggerEventData AfterTriggerEventData |
typedef struct AfterTriggerEventDataNoOids AfterTriggerEventDataNoOids |
typedef struct AfterTriggerEventDataOneCtid AfterTriggerEventDataOneCtid |
typedef struct AfterTriggerEventDataZeroCtids AfterTriggerEventDataZeroCtids |
typedef struct AfterTriggerEventList AfterTriggerEventList |
typedef struct AfterTriggersData AfterTriggersData |
typedef struct AfterTriggerSharedData* AfterTriggerShared |
typedef struct AfterTriggerSharedData AfterTriggerSharedData |
typedef struct AfterTriggersQueryData AfterTriggersQueryData |
typedef struct AfterTriggersTableData AfterTriggersTableData |
typedef struct AfterTriggersTransData AfterTriggersTransData |
typedef SetConstraintStateData* SetConstraintState |
typedef struct SetConstraintStateData SetConstraintStateData |
typedef struct SetConstraintTriggerData* SetConstraintTrigger |
typedef struct SetConstraintTriggerData SetConstraintTriggerData |
typedef uint32 TriggerFlags |
|
static |
Definition at line 4032 of file trigger.c.
References AFTER_TRIGGER_OFFSET, afterTriggers, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AfterTriggerEventData::ate_flags, AfterTriggerSharedData::ats_event, AfterTriggerSharedData::ats_firing_id, AfterTriggerSharedData::ats_relid, AfterTriggerSharedData::ats_table, AfterTriggerSharedData::ats_tgoid, chunk, CHUNK_DATA_START, AfterTriggersData::event_cxt, AfterTriggerEventList::head, MAX_CHUNK_SIZE, MemoryContextAlloc(), Min, MIN_CHUNK_SIZE, AfterTriggerEventChunk::next, SizeofTriggerEvent, AfterTriggerEventList::tail, AfterTriggerEventList::tailfree, and TopTransactionContext.
Referenced by afterTriggerMarkEvents(), and AfterTriggerSaveEvent().
void AfterTriggerBeginQuery | ( | void | ) |
Definition at line 5024 of file trigger.c.
References afterTriggers, and AfterTriggersData::query_depth.
Referenced by CopyFrom(), create_edata_for_relation(), ExecuteTruncateGuts(), and standard_ExecutorStart().
void AfterTriggerBeginSubXact | ( | void | ) |
Definition at line 5307 of file trigger.c.
References afterTriggers, AfterTriggersData::events, AfterTriggersTransData::events, AfterTriggersData::firing_counter, AfterTriggersTransData::firing_counter, GetCurrentTransactionNestLevel(), AfterTriggersData::maxtransdepth, MemoryContextAlloc(), AfterTriggersData::query_depth, AfterTriggersTransData::query_depth, repalloc(), AfterTriggersTransData::state, TopTransactionContext, and AfterTriggersData::trans_stack.
Referenced by StartSubTransaction().
void AfterTriggerBeginXact | ( | void | ) |
Definition at line 4992 of file trigger.c.
References afterTriggers, Assert, AfterTriggersData::event_cxt, AfterTriggersData::events, AfterTriggersData::firing_counter, AfterTriggerEventList::head, AfterTriggersData::maxquerydepth, AfterTriggersData::maxtransdepth, AfterTriggersData::query_depth, AfterTriggersData::query_stack, AfterTriggersData::state, and AfterTriggersData::trans_stack.
Referenced by StartTransaction().
|
static |
Definition at line 3955 of file trigger.c.
References AFTER_TRIGGER_DEFERRABLE, AFTER_TRIGGER_INITDEFERRED, afterTriggers, AfterTriggerSharedData::ats_event, AfterTriggerSharedData::ats_tgoid, i, and AfterTriggersData::state.
Referenced by afterTriggerMarkEvents().
Definition at line 4000 of file trigger.c.
References afterTriggers, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, bms_copy(), AfterTriggersData::event_cxt, MemoryContextSwitchTo(), and TopTransactionContext.
Referenced by AfterTriggerSaveEvent().
|
static |
Definition at line 4212 of file trigger.c.
References AfterTriggersTableData::after_trig_done, AfterTriggersTableData::after_trig_events, Assert, AfterTriggersQueryData::events, AfterTriggerEventList::head, lfirst, AfterTriggerEventChunk::next, pfree(), AfterTriggersQueryData::tables, AfterTriggerEventList::tail, and AfterTriggerEventList::tailfree.
Referenced by AfterTriggerEndQuery().
void AfterTriggerEndQuery | ( | EState * | estate | ) |
Definition at line 5044 of file trigger.c.
References afterTriggerDeleteHeadEventChunk(), AfterTriggerFreeQuery(), afterTriggerInvokeEvents(), afterTriggerMarkEvents(), afterTriggers, Assert, AfterTriggersData::events, AfterTriggersQueryData::events, AfterTriggersData::firing_counter, AfterTriggerEventList::head, AfterTriggersData::maxquerydepth, AfterTriggersData::query_depth, AfterTriggersData::query_stack, and AfterTriggerEventList::tail.
Referenced by CopyFrom(), ExecuteTruncateGuts(), finish_edata(), and standard_ExecutorFinish().
void AfterTriggerEndSubXact | ( | bool | isCommit | ) |
Definition at line 5355 of file trigger.c.
References AFTER_TRIGGER_DONE, AFTER_TRIGGER_IN_PROGRESS, AfterTriggerFreeQuery(), afterTriggerRestoreEventList(), afterTriggers, Assert, AfterTriggerEventData::ate_flags, AfterTriggerSharedData::ats_firing_id, chunk, AfterTriggersData::events, AfterTriggersTransData::events, AfterTriggersTransData::firing_counter, for_each_event_chunk, GetCurrentTransactionNestLevel(), GetTriggerSharedData, AfterTriggersData::maxquerydepth, AfterTriggersData::maxtransdepth, pfree(), AfterTriggersData::query_depth, AfterTriggersTransData::query_depth, AfterTriggersData::query_stack, AfterTriggersData::state, AfterTriggersTransData::state, and AfterTriggersData::trans_stack.
Referenced by AbortSubTransaction(), and CommitSubTransaction().
void AfterTriggerEndXact | ( | bool | isCommit | ) |
Definition at line 5259 of file trigger.c.
References afterTriggers, AfterTriggersData::event_cxt, AfterTriggersData::events, AfterTriggerEventList::head, AfterTriggersData::maxquerydepth, AfterTriggersData::maxtransdepth, MemoryContextDelete(), AfterTriggersData::query_depth, AfterTriggersData::query_stack, AfterTriggersData::state, AfterTriggerEventList::tail, AfterTriggerEventList::tailfree, and AfterTriggersData::trans_stack.
Referenced by AbortTransaction(), CommitTransaction(), and PrepareTransaction().
|
static |
Definition at line 5543 of file trigger.c.
References afterTriggers, Assert, AfterTriggersQueryData::events, AfterTriggersQueryData::fdw_tuplestore, AfterTriggerEventList::head, Max, AfterTriggersData::maxquerydepth, MemoryContextAlloc(), NIL, AfterTriggersData::query_depth, AfterTriggersData::query_stack, repalloc(), AfterTriggersQueryData::tables, AfterTriggerEventList::tail, AfterTriggerEventList::tailfree, and TopTransactionContext.
Referenced by AfterTriggerSaveEvent(), before_stmt_triggers_fired(), and MakeTransitionCaptureState().
|
static |
Definition at line 4274 of file trigger.c.
References AFTER_TRIGGER_2CTID, AFTER_TRIGGER_CP_UPDATE, AFTER_TRIGGER_FDW_FETCH, AFTER_TRIGGER_FDW_REUSE, AFTER_TRIGGER_TUP_BITS, AfterTriggerEventData::ate_ctid1, AfterTriggerEventData::ate_ctid2, AfterTriggerEventData::ate_flags, AfterTriggerSharedData::ats_event, AfterTriggerSharedData::ats_modifiedcols, AfterTriggerSharedData::ats_table, AfterTriggerSharedData::ats_tgoid, TupleConversionMap::attrMap, AfterTriggersTableData::closed, elog, ERROR, ExecCallTriggerFunc(), ExecClearTuple(), ExecCopySlot(), ExecFetchSlotHeapTuple(), ExecGetChildToRootMap(), ExecGetTriggerNewSlot(), ExecGetTriggerOldSlot(), execute_attr_map_slot(), GetCurrentFDWTuplestore(), GetTriggerSharedData, heap_freetuple(), InstrStartNode(), InstrStopNode(), ItemPointerIsValid(), MemoryContextReset(), AfterTriggersTableData::new_ins_tuplestore, AfterTriggersTableData::new_upd_tuplestore, TriggerDesc::numtriggers, AfterTriggersTableData::old_del_tuplestore, AfterTriggersTableData::old_upd_tuplestore, ResultRelInfo::ri_RelationDesc, SnapshotAny, table_tuple_fetch_row_version(), TriggerData::tg_event, TriggerData::tg_newslot, TriggerData::tg_newtable, TriggerData::tg_newtuple, TriggerData::tg_oldtable, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigslot, TriggerData::tg_trigtuple, TriggerData::tg_updatedcols, Trigger::tgnewtable, Trigger::tgoid, Trigger::tgoldtable, Trigger::tgtype, TRIGGER_EVENT_OPMASK, TRIGGER_EVENT_ROW, TRIGGER_EVENT_UPDATE, TRIGGER_FIRED_BY_INSERT, TRIGGER_FIRED_BY_UPDATE, TriggerDesc::triggers, tuplestore_gettupleslot(), and TriggerData::type.
Referenced by afterTriggerInvokeEvents().
void AfterTriggerFireDeferred | ( | void | ) |
Definition at line 5203 of file trigger.c.
References afterTriggerInvokeEvents(), afterTriggerMarkEvents(), afterTriggers, Assert, AfterTriggersData::events, AfterTriggersData::firing_counter, GetTransactionSnapshot(), AfterTriggerEventList::head, PopActiveSnapshot(), PushActiveSnapshot(), and AfterTriggersData::query_depth.
Referenced by CommitTransaction(), and PrepareTransaction().
|
static |
Definition at line 4151 of file trigger.c.
References chunk, AfterTriggerEventList::head, pfree(), AfterTriggerEventList::tail, and AfterTriggerEventList::tailfree.
Referenced by AfterTriggerFreeQuery(), and afterTriggerRestoreEventList().
|
static |
Definition at line 5135 of file trigger.c.
References afterTriggerFreeEventList(), AfterTriggersQueryData::events, ExecDropSingleTupleTableSlot(), AfterTriggersQueryData::fdw_tuplestore, lfirst, list_free_deep(), AfterTriggersTableData::new_ins_tuplestore, AfterTriggersTableData::new_upd_tuplestore, NIL, AfterTriggersTableData::old_del_tuplestore, AfterTriggersTableData::old_upd_tuplestore, AfterTriggersTableData::storeslot, AfterTriggersQueryData::tables, and tuplestore_end().
Referenced by AfterTriggerEndQuery(), and AfterTriggerEndSubXact().
|
static |
Definition at line 4633 of file trigger.c.
References AFTER_TRIGGER_CP_UPDATE, AFTER_TRIGGER_DONE, AFTER_TRIGGER_IN_PROGRESS, AFTER_TRIGGER_TUP_BITS, AfterTriggerExecute(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AfterTriggerEventData::ate_dst_part, AfterTriggerEventData::ate_flags, AfterTriggerEventData::ate_src_part, AfterTriggerSharedData::ats_firing_id, AfterTriggerSharedData::ats_relid, chunk, CHUNK_DATA_START, CreateExecutorState(), CurrentMemoryContext, EState::es_tupleTable, ExecCloseResultRelations(), ExecDropSingleTupleTableSlot(), ExecGetTriggerResultRel(), ExecResetTupleTable(), for_each_chunk, for_each_event, FreeExecutorState(), GetTriggerSharedData, MakeSingleTupleTableSlot(), MemoryContextDelete(), OidIsValid, RelationData::rd_att, RelationData::rd_rel, RelationGetRelid, RelationHasReferenceCountZero, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigDesc, ResultRelInfo::ri_TrigFunctions, ResultRelInfo::ri_TrigInstrument, AfterTriggerEventList::tail, AfterTriggerEventList::tailfree, and TTSOpsMinimalTuple.
Referenced by AfterTriggerEndQuery(), AfterTriggerFireDeferred(), and AfterTriggerSetState().
|
static |
Definition at line 4549 of file trigger.c.
References AFTER_TRIGGER_DONE, AFTER_TRIGGER_IN_PROGRESS, afterTriggerAddEvent(), afterTriggerCheckState(), afterTriggers, AfterTriggerEventData::ate_flags, AfterTriggerSharedData::ats_firing_id, chunk, ereport, errcode(), errmsg(), ERROR, AfterTriggersData::firing_counter, for_each_event_chunk, GetTriggerSharedData, and InSecurityRestrictedOperation().
Referenced by AfterTriggerEndQuery(), AfterTriggerFireDeferred(), and AfterTriggerSetState().
Definition at line 5980 of file trigger.c.
References AFTER_TRIGGER_DONE, afterTriggers, AfterTriggerEventData::ate_flags, AfterTriggerSharedData::ats_relid, chunk, AfterTriggersData::events, AfterTriggersQueryData::events, for_each_event_chunk, GetTriggerSharedData, AfterTriggersData::maxquerydepth, AfterTriggersData::query_depth, and AfterTriggersData::query_stack.
Referenced by CheckTableNotInUse().
|
static |
Definition at line 4172 of file trigger.c.
References afterTriggerFreeEventList(), chunk, AfterTriggerEventChunk::freeptr, AfterTriggerEventChunk::next, pfree(), AfterTriggerEventList::tail, and AfterTriggerEventList::tailfree.
Referenced by AfterTriggerEndSubXact().
|
static |
Definition at line 6067 of file trigger.c.
References AFTER_TRIGGER_1CTID, AFTER_TRIGGER_2CTID, AFTER_TRIGGER_CP_UPDATE, AFTER_TRIGGER_DEFERRABLE, AFTER_TRIGGER_FDW_FETCH, AFTER_TRIGGER_FDW_REUSE, AFTER_TRIGGER_INITDEFERRED, afterTriggerAddEvent(), afterTriggerCopyBitmap(), AfterTriggerEnlargeQueryState(), afterTriggers, Assert, AfterTriggerEventData::ate_ctid1, AfterTriggerEventData::ate_ctid2, AfterTriggerEventData::ate_dst_part, AfterTriggerEventData::ate_flags, AfterTriggerEventData::ate_src_part, AfterTriggerSharedData::ats_event, AfterTriggerSharedData::ats_firing_id, AfterTriggerSharedData::ats_modifiedcols, AfterTriggerSharedData::ats_relid, AfterTriggerSharedData::ats_table, AfterTriggerSharedData::ats_tgoid, TupleConversionMap::attrMap, cancel_prior_stmt_triggers(), CMD_DELETE, CMD_INSERT, CMD_UPDATE, elog, ERROR, AfterTriggersQueryData::events, ExecCopySlot(), ExecGetChildToRootMap(), ExecGetTriggerNewSlot(), ExecGetTriggerOldSlot(), execute_attr_map_slot(), GetAfterTriggersTransitionTable(), GetCurrentFDWTuplestore(), i, ItemPointerCopy(), ItemPointerSetInvalid(), list_member_oid(), AfterTriggersData::maxquerydepth, TriggerDesc::numtriggers, AfterTriggersData::query_depth, AfterTriggersData::query_stack, RelationData::rd_rel, RelationGetRelid, RI_FKey_fk_upd_check_required(), RI_FKey_pk_upd_check_required(), RI_FKey_trigger_type(), ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigDesc, RI_TRIGGER_FK, RI_TRIGGER_NONE, RI_TRIGGER_PK, TransitionCaptureState::tcs_original_insert_tuple, TransitionCaptureState::tcs_private, Trigger::tgconstrindid, Trigger::tgdeferrable, Trigger::tgfoid, Trigger::tginitdeferred, Trigger::tgisclone, Trigger::tgnewtable, Trigger::tgoid, Trigger::tgoldtable, Trigger::tgtype, TransitionTableAddTuple(), TriggerDesc::trig_delete_after_row, TriggerDesc::trig_insert_after_row, TriggerDesc::trig_update_after_row, TRIGGER_EVENT_DELETE, TRIGGER_EVENT_INSERT, TRIGGER_EVENT_OPMASK, TRIGGER_EVENT_ROW, TRIGGER_EVENT_TRUNCATE, TRIGGER_EVENT_UPDATE, TRIGGER_FIRED_BY_DELETE, TRIGGER_FIRED_BY_UPDATE, TriggerEnabled(), TriggerDesc::triggers, TupleTableSlot::tts_tid, TupIsNull, and tuplestore_puttupleslot().
Referenced by ExecARDeleteTriggers(), ExecARInsertTriggers(), ExecARUpdateTriggers(), ExecASDeleteTriggers(), ExecASInsertTriggers(), ExecASTruncateTriggers(), and ExecASUpdateTriggers().
void AfterTriggerSetState | ( | ConstraintsSetStmt * | stmt | ) |
Definition at line 5665 of file trigger.c.
References AccessShareLock, afterTriggerInvokeEvents(), afterTriggerMarkEvents(), afterTriggers, SetConstraintStateData::all_isdeferred, SetConstraintStateData::all_isset, BTEqualStrategyNumber, RangeVar::catalogname, CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, AfterTriggersData::events, fetch_search_path(), AfterTriggersData::firing_counter, get_database_name(), GetCurrentTransactionNestLevel(), GETSTRUCT, GetTransactionSnapshot(), HeapTupleIsValid, i, IsSubTransaction(), sort-test::key, lappend_oid(), lfirst, lfirst_oid, list_free(), list_make1_oid, LookupExplicitNamespace(), MyDatabaseId, NIL, SetConstraintStateData::numstates, ObjectIdGetDatum(), PopActiveSnapshot(), PushActiveSnapshot(), RangeVar::relname, ScanKeyInit(), RangeVar::schemaname, SetConstraintStateAddItem(), SetConstraintStateCopy(), SetConstraintStateCreate(), AfterTriggersData::state, AfterTriggersTransData::state, stmt, systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), and AfterTriggersData::trans_stack.
Referenced by standard_ProcessUtility().
void assign_session_replication_role | ( | int | newval, |
void * | extra | ||
) |
Definition at line 6585 of file trigger.c.
References newval, ResetPlanCache(), and SessionReplicationRole.
Definition at line 6464 of file trigger.c.
References AfterTriggerEnlargeQueryState(), afterTriggers, AfterTriggersTableData::before_trig_done, elog, ERROR, GetAfterTriggersTableData(), AfterTriggersData::maxquerydepth, and AfterTriggersData::query_depth.
Referenced by ExecBSDeleteTriggers(), ExecBSInsertTriggers(), and ExecBSUpdateTriggers().
Definition at line 6510 of file trigger.c.
References AfterTriggersTableData::after_trig_done, AfterTriggersTableData::after_trig_events, AFTER_TRIGGER_DONE, AFTER_TRIGGER_IN_PROGRESS, afterTriggers, AfterTriggerSharedData::ats_event, AfterTriggerSharedData::ats_relid, chunk, CHUNK_DATA_START, AfterTriggersQueryData::events, for_each_chunk_from, for_each_event_from, GetAfterTriggersTableData(), GetTriggerSharedData, AfterTriggerEventList::head, AfterTriggersData::query_depth, AfterTriggersData::query_stack, AfterTriggerEventList::tail, AfterTriggerEventList::tailfree, TRIGGER_EVENT_OPMASK, TRIGGER_FIRED_AFTER, and TRIGGER_FIRED_FOR_STATEMENT.
Referenced by AfterTriggerSaveEvent().
TriggerDesc* CopyTriggerDesc | ( | TriggerDesc * | trigdesc | ) |
Definition at line 2086 of file trigger.c.
References i, j, TriggerDesc::numtriggers, palloc(), pstrdup(), Trigger::tgargs, Trigger::tgattr, Trigger::tgname, Trigger::tgnargs, Trigger::tgnattr, Trigger::tgnewtable, Trigger::tgoldtable, Trigger::tgqual, and TriggerDesc::triggers.
Referenced by InitResultRelInfo(), and RelationBuildTriggers().
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 | ||
) |
Definition at line 158 of file trigger.c.
References CreateTriggerFiringOn(), stmt, and TRIGGER_FIRES_ON_ORIGIN.
Referenced by CreateFKCheckTrigger(), createForeignKeyActionTriggers(), index_constraint_create(), and ProcessUtilitySlow().
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 | ||
) |
Definition at line 175 of file trigger.c.
References AccessShareLock, ACL_EXECUTE, ACL_TRIGGER, aclcheck_error(), ACLCHECK_OK, addNSItemToQuery(), addRangeTableEntryForRelation(), ALLOCSET_SMALL_SIZES, AllocSetContextCreate, allowSystemTableMods, generate_unaccent_rules::args, Assert, assign_expr_collations(), attnameAttNum(), attnum, BoolGetDatum(), BTEqualStrategyNumber, buildint2vector(), byteain(), CacheInvalidateRelcacheByTuple(), CatalogTupleInsert(), CatalogTupleUpdate(), ObjectAddress::classId, CommandCounterIncrement(), copyObject, CreateConstraintEntry(), CStringGetDatum(), CStringGetTextDatum, CurrentMemoryContext, DatumGetPointer(), deleteDependencyRecordsFor(), DEPENDENCY_AUTO, DEPENDENCY_INTERNAL, DEPENDENCY_NORMAL, DEPENDENCY_PARTITION_PRI, DEPENDENCY_PARTITION_SEC, DirectFunctionCall1, elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errdetail(), errdetail_relkind_not_supported(), errhint(), errmsg(), ERROR, EXPR_KIND_TRIGGER_WHEN, find_all_inheritors(), free_parsestate(), CreateTrigStmt::funcname, get_func_rettype(), get_rel_name(), get_rel_relkind(), get_relkind_objtype(), GetNewOidWithIndex(), GETSTRUCT, GetUserId(), has_superclass(), heap_copytuple(), heap_form_tuple(), heap_freetuple(), HeapTupleIsValid, i, Int16GetDatum(), InvalidAttrNumber, InvalidOid, InvokeObjectPostCreateHookArg, TriggerTransition::isNew, IsSystemRelation(), TriggerTransition::isTable, j, len, lfirst, lfirst_node, list_free(), list_length(), Var::location, LockRelationOid(), LookupFuncName(), make_parsestate(), makeAlias(), map_partition_varattnos(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), name, TriggerTransition::name, NAMEDATALEN, namein(), NameListToString(), NameStr, NIL, nodeToString(), NoLock, PartitionDescData::nparts, object_aclcheck(), OBJECT_FUNCTION, ObjectAddressSet, ObjectAddress::objectId, ObjectIdGetDatum(), ObjectAddress::objectSubId, OidIsValid, PartitionDescData::oids, ParseState::p_rtable, ParseState::p_sourcetext, palloc(), parser_errposition(), pfree(), pg_class_aclcheck(), PointerGetDatum(), PRS2_NEW_VARNO, PRS2_OLD_VARNO, pull_var_clause(), RangeVarGetRelid, RelationData::rd_att, RelationData::rd_id, RelationData::rd_rel, recordDependencyOn(), recordDependencyOnExpr(), RelationGetDescr, RelationGetNamespace, RelationGetPartitionDesc(), RelationGetRelationName, RelationGetRelid, RowExclusiveLock, ScanKeyInit(), SearchSysCacheCopy1, ShareRowExclusiveLock, snprintf, stmt, strVal, systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), table_open(), table_openrv(), transformWhereClause(), TupleDescAttr, values, Var::varattno, Var::varno, and CreateTrigStmt::whenClause.
Referenced by CloneRowTriggersToPartition(), and CreateTrigger().
void EnableDisableTrigger | ( | Relation | rel, |
const char * | tgname, | ||
Oid | tgparent, | ||
char | fires_when, | ||
bool | skip_system, | ||
bool | recurse, | ||
LOCKMODE | lockmode | ||
) |
Definition at line 1722 of file trigger.c.
References BTEqualStrategyNumber, CacheInvalidateRelcache(), CatalogTupleUpdate(), CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GETSTRUCT, heap_copytuple(), heap_freetuple(), HeapTupleIsValid, i, InvokeObjectPostAlterHook, NameStr, NoLock, PartitionDescData::nparts, ObjectIdGetDatum(), OidIsValid, PartitionDescData::oids, RelationData::rd_rel, relation_open(), RelationGetPartitionDesc(), RelationGetRelationName, RelationGetRelid, RowExclusiveLock, ScanKeyInit(), superuser(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by ATExecEnableDisableTrigger().
void ExecARDeleteTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo, | ||
ItemPointer | tupleid, | ||
HeapTuple | fdw_trigtuple, | ||
TransitionCaptureState * | transition_capture, | ||
bool | is_crosspart_update | ||
) |
Definition at line 2775 of file trigger.c.
References AfterTriggerSaveEvent(), Assert, ExecForceStoreHeapTuple(), ExecGetTriggerOldSlot(), GetTupleForTrigger(), HeapTupleIsValid, ItemPointerIsValid(), LockTupleExclusive, NIL, ResultRelInfo::ri_TrigDesc, TransitionCaptureState::tcs_delete_old_table, TriggerDesc::trig_delete_after_row, and TRIGGER_EVENT_DELETE.
Referenced by ExecDeleteEpilogue(), and ExecSimpleRelationDelete().
void ExecARInsertTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo, | ||
TupleTableSlot * | slot, | ||
List * | recheckIndexes, | ||
TransitionCaptureState * | transition_capture | ||
) |
Definition at line 2535 of file trigger.c.
References AfterTriggerSaveEvent(), ResultRelInfo::ri_TrigDesc, TransitionCaptureState::tcs_insert_new_table, TriggerDesc::trig_insert_after_row, and TRIGGER_EVENT_INSERT.
Referenced by CopyFrom(), CopyMultiInsertBufferFlush(), ExecBatchInsert(), ExecInsert(), and ExecSimpleRelationInsert().
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 | ||
) |
Definition at line 3098 of file trigger.c.
References AfterTriggerSaveEvent(), Assert, ExecClearTuple(), ExecForceStoreHeapTuple(), ExecGetAllUpdatedCols(), ExecGetTriggerOldSlot(), GetTupleForTrigger(), ItemPointerIsValid(), LockTupleExclusive, ResultRelInfo::ri_TrigDesc, TransitionCaptureState::tcs_update_new_table, TransitionCaptureState::tcs_update_old_table, TriggerDesc::trig_update_after_row, and TRIGGER_EVENT_UPDATE.
Referenced by ExecCrossPartitionUpdateForeignKey(), ExecDeleteEpilogue(), ExecInsert(), ExecSimpleRelationUpdate(), and ExecUpdateEpilogue().
void ExecASDeleteTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo, | ||
TransitionCaptureState * | transition_capture | ||
) |
Definition at line 2664 of file trigger.c.
References AfterTriggerSaveEvent(), NIL, ResultRelInfo::ri_TrigDesc, TriggerDesc::trig_delete_after_statement, and TRIGGER_EVENT_DELETE.
Referenced by fireASTriggers().
void ExecASInsertTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo, | ||
TransitionCaptureState * | transition_capture | ||
) |
Definition at line 2446 of file trigger.c.
References AfterTriggerSaveEvent(), NIL, ResultRelInfo::ri_TrigDesc, TriggerDesc::trig_insert_after_statement, and TRIGGER_EVENT_INSERT.
Referenced by CopyFrom(), and fireASTriggers().
void ExecASTruncateTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo | ||
) |
Definition at line 3270 of file trigger.c.
References AfterTriggerSaveEvent(), NIL, ResultRelInfo::ri_TrigDesc, TriggerDesc::trig_truncate_after_statement, and TRIGGER_EVENT_TRUNCATE.
Referenced by ExecuteTruncateGuts().
void ExecASUpdateTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo, | ||
TransitionCaptureState * | transition_capture | ||
) |
Definition at line 2917 of file trigger.c.
References AfterTriggerSaveEvent(), Assert, ExecGetAllUpdatedCols(), NIL, ResultRelInfo::ri_RootResultRelInfo, ResultRelInfo::ri_TrigDesc, TriggerDesc::trig_update_after_statement, and TRIGGER_EVENT_UPDATE.
Referenced by fireASTriggers().
bool ExecBRDeleteTriggers | ( | EState * | estate, |
EPQState * | epqstate, | ||
ResultRelInfo * | relinfo, | ||
ItemPointer | tupleid, | ||
HeapTuple | fdw_trigtuple, | ||
TupleTableSlot ** | epqslot, | ||
TM_Result * | tmresult, | ||
TM_FailureData * | tmfd | ||
) |
Definition at line 2684 of file trigger.c.
References Assert, ExecCallTriggerFunc(), ExecFetchSlotHeapTuple(), ExecForceStoreHeapTuple(), ExecGetTriggerOldSlot(), GetPerTupleMemoryContext, GetTupleForTrigger(), heap_freetuple(), HeapTupleIsValid, i, ItemPointerIsValid(), LockTupleExclusive, TriggerDesc::numtriggers, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigDesc, ResultRelInfo::ri_TrigFunctions, ResultRelInfo::ri_TrigInstrument, TriggerData::tg_event, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigslot, TriggerData::tg_trigtuple, Trigger::tgtype, TRIGGER_EVENT_BEFORE, TRIGGER_EVENT_DELETE, TRIGGER_EVENT_ROW, TriggerEnabled(), TriggerDesc::triggers, and TriggerData::type.
Referenced by ExecDeletePrologue(), and ExecSimpleRelationDelete().
bool ExecBRInsertTriggers | ( | EState * | estate, |
ResultRelInfo * | relinfo, | ||
TupleTableSlot * | slot | ||
) |
Definition at line 2459 of file trigger.c.
References ereport, errcode(), errdetail(), errmsg(), ERROR, ExecCallTriggerFunc(), ExecFetchSlotHeapTuple(), ExecForceStoreHeapTuple(), ExecPartitionCheck(), get_namespace_name(), GetPerTupleMemoryContext, heap_freetuple(), i, TriggerDesc::numtriggers, RelationGetNamespace, RelationGetRelationName, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigDesc, ResultRelInfo::ri_TrigFunctions, ResultRelInfo::ri_TrigInstrument, TriggerData::tg_event, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigslot, TriggerData::tg_trigtuple, Trigger::tgisclone, Trigger::tgname, Trigger::tgtype, TRIGGER_EVENT_BEFORE, TRIGGER_EVENT_INSERT, TRIGGER_EVENT_ROW, TriggerEnabled(), TriggerDesc::triggers, and TriggerData::type.
Referenced by CopyFrom(), ExecInsert(), and ExecSimpleRelationInsert().
bool ExecBRUpdateTriggers | ( | EState * | estate, |
EPQState * | epqstate, | ||
ResultRelInfo * | relinfo, | ||
ItemPointer | tupleid, | ||
HeapTuple | fdw_trigtuple, | ||
TupleTableSlot * | newslot, | ||
TM_Result * | tmresult, | ||
TM_FailureData * | tmfd | ||
) |