PostgreSQL Source Code git master
Loading...
Searching...
No Matches
event_trigger.h File Reference
Include dependency graph for event_trigger.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  EventTriggerData
 

Macros

#define AT_REWRITE_ALTER_PERSISTENCE   0x01
 
#define AT_REWRITE_DEFAULT_VAL   0x02
 
#define AT_REWRITE_COLUMN_REWRITE   0x04
 
#define AT_REWRITE_ACCESS_METHOD   0x08
 
#define CALLED_AS_EVENT_TRIGGER(fcinfo)    ((fcinfo)->context != NULL && IsA((fcinfo)->context, EventTriggerData))
 

Typedefs

typedef struct EventTriggerData EventTriggerData
 

Functions

Oid CreateEventTrigger (CreateEventTrigStmt *stmt)
 
Oid get_event_trigger_oid (const char *trigname, bool missing_ok)
 
Oid AlterEventTrigger (AlterEventTrigStmt *stmt)
 
ObjectAddress AlterEventTriggerOwner (const char *name, Oid newOwnerId)
 
void AlterEventTriggerOwner_oid (Oid, Oid newOwnerId)
 
bool EventTriggerSupportsObjectType (ObjectType obtype)
 
bool EventTriggerSupportsObject (const ObjectAddress *object)
 
void EventTriggerDDLCommandStart (Node *parsetree)
 
void EventTriggerDDLCommandEnd (Node *parsetree)
 
void EventTriggerSQLDrop (Node *parsetree)
 
void EventTriggerTableRewrite (Node *parsetree, Oid tableOid, int reason)
 
void EventTriggerOnLogin (void)
 
bool EventTriggerBeginCompleteQuery (void)
 
void EventTriggerEndCompleteQuery (void)
 
bool trackDroppedObjectsNeeded (void)
 
void EventTriggerSQLDropAddObject (const ObjectAddress *object, bool original, bool normal)
 
void EventTriggerInhibitCommandCollection (void)
 
void EventTriggerUndoInhibitCommandCollection (void)
 
void EventTriggerCollectSimpleCommand (ObjectAddress address, ObjectAddress secondaryObject, const Node *parsetree)
 
void EventTriggerAlterTableStart (const Node *parsetree)
 
void EventTriggerAlterTableRelid (Oid objectId)
 
void EventTriggerCollectAlterTableSubcmd (const Node *subcmd, ObjectAddress address)
 
void EventTriggerAlterTableEnd (void)
 
void EventTriggerCollectGrant (InternalGrant *istmt)
 
void EventTriggerCollectAlterOpFam (const AlterOpFamilyStmt *stmt, Oid opfamoid, List *operators, List *procedures)
 
void EventTriggerCollectCreateOpClass (const CreateOpClassStmt *stmt, Oid opcoid, List *operators, List *procedures)
 
void EventTriggerCollectAlterTSConfig (const AlterTSConfigurationStmt *stmt, Oid cfgId, Oid *dictIds, int ndicts)
 
void EventTriggerCollectAlterDefPrivs (const AlterDefaultPrivilegesStmt *stmt)
 

Variables

PGDLLIMPORT bool event_triggers
 

Macro Definition Documentation

◆ AT_REWRITE_ACCESS_METHOD

#define AT_REWRITE_ACCESS_METHOD   0x08

Definition at line 43 of file event_trigger.h.

◆ AT_REWRITE_ALTER_PERSISTENCE

#define AT_REWRITE_ALTER_PERSISTENCE   0x01

Definition at line 40 of file event_trigger.h.

◆ AT_REWRITE_COLUMN_REWRITE

#define AT_REWRITE_COLUMN_REWRITE   0x04

Definition at line 42 of file event_trigger.h.

◆ AT_REWRITE_DEFAULT_VAL

#define AT_REWRITE_DEFAULT_VAL   0x02

Definition at line 41 of file event_trigger.h.

◆ CALLED_AS_EVENT_TRIGGER

#define CALLED_AS_EVENT_TRIGGER (   fcinfo)     ((fcinfo)->context != NULL && IsA((fcinfo)->context, EventTriggerData))

Definition at line 49 of file event_trigger.h.

Typedef Documentation

◆ EventTriggerData

Function Documentation

◆ AlterEventTrigger()

Oid AlterEventTrigger ( AlterEventTrigStmt stmt)
extern

Definition at line 429 of file event_trigger.c.

430{
433 Oid trigoid;
435 char tgenabled = stmt->tgenabled;
436
438
440 CStringGetDatum(stmt->trigname));
441 if (!HeapTupleIsValid(tup))
444 errmsg("event trigger \"%s\" does not exist",
445 stmt->trigname)));
446
448 trigoid = evtForm->oid;
449
452 stmt->trigname);
453
454 /* tuple is a copy, so we can modify it below */
455 evtForm->evtenabled = tgenabled;
456
457 CatalogTupleUpdate(tgrel, &tup->t_self, tup);
458
459 /*
460 * Login event triggers have an additional flag in pg_database to enable
461 * faster lookups in hot codepaths. Set the flag unless already True.
462 */
463 if (namestrcmp(&evtForm->evtevent, "login") == 0 &&
464 tgenabled != TRIGGER_DISABLED)
466
468 trigoid, 0);
469
470 /* clean up */
473
474 return trigoid;
475}
@ ACLCHECK_NOT_OWNER
Definition acl.h:186
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition aclchk.c:2672
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
Definition aclchk.c:4134
int errcode(int sqlerrcode)
Definition elog.c:875
#define ERROR
Definition elog.h:40
#define ereport(elevel,...)
Definition elog.h:152
static void SetDatabaseHasLoginEventTriggers(void)
void heap_freetuple(HeapTuple htup)
Definition heaptuple.c:1372
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
#define stmt
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
Definition indexing.c:313
#define RowExclusiveLock
Definition lockdefs.h:38
Oid GetUserId(void)
Definition miscinit.c:470
int namestrcmp(Name name, const char *str)
Definition name.c:247
static char * errmsg
#define InvokeObjectPostAlterHook(classId, objectId, subId)
@ OBJECT_EVENT_TRIGGER
END_CATALOG_STRUCT typedef FormData_pg_event_trigger * Form_pg_event_trigger
static Datum CStringGetDatum(const char *X)
Definition postgres.h:383
unsigned int Oid
static int fb(int x)
#define SearchSysCacheCopy1(cacheId, key1)
Definition syscache.h:91
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40
#define TRIGGER_DISABLED
Definition trigger.h:154

References aclcheck_error(), ACLCHECK_NOT_OWNER, CatalogTupleUpdate(), CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), Form_pg_event_trigger, GETSTRUCT(), GetUserId(), heap_freetuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, namestrcmp(), OBJECT_EVENT_TRIGGER, object_ownercheck(), RowExclusiveLock, SearchSysCacheCopy1, SetDatabaseHasLoginEventTriggers(), stmt, table_close(), table_open(), and TRIGGER_DISABLED.

Referenced by standard_ProcessUtility().

◆ AlterEventTriggerOwner()

ObjectAddress AlterEventTriggerOwner ( const char name,
Oid  newOwnerId 
)
extern

Definition at line 481 of file event_trigger.c.

482{
483 Oid evtOid;
486 Relation rel;
487 ObjectAddress address;
488
490
492
493 if (!HeapTupleIsValid(tup))
496 errmsg("event trigger \"%s\" does not exist", name)));
497
499 evtOid = evtForm->oid;
500
502
504
506
508
509 return address;
510}
static void AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
#define ObjectAddressSet(addr, class_id, object_id)
const char * name

References AlterEventTriggerOwner_internal(), CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), Form_pg_event_trigger, GETSTRUCT(), heap_freetuple(), HeapTupleIsValid, name, ObjectAddressSet, RowExclusiveLock, SearchSysCacheCopy1, table_close(), and table_open().

Referenced by ExecAlterOwnerStmt().

◆ AlterEventTriggerOwner_oid()

void AlterEventTriggerOwner_oid ( Oid  trigOid,
Oid  newOwnerId 
)
extern

Definition at line 516 of file event_trigger.c.

517{
519 Relation rel;
520
522
524
525 if (!HeapTupleIsValid(tup))
528 errmsg("event trigger with OID %u does not exist", trigOid)));
529
531
533
535}
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252

References AlterEventTriggerOwner_internal(), ereport, errcode(), errmsg, ERROR, fb(), heap_freetuple(), HeapTupleIsValid, ObjectIdGetDatum(), RowExclusiveLock, SearchSysCacheCopy1, table_close(), and table_open().

Referenced by shdepReassignOwned_Owner().

◆ CreateEventTrigger()

Oid CreateEventTrigger ( CreateEventTrigStmt stmt)
extern

Definition at line 126 of file event_trigger.c.

127{
128 HeapTuple tuple;
129 Oid funcoid;
131 Oid evtowner = GetUserId();
132 ListCell *lc;
133 List *tags = NULL;
134
135 /*
136 * It would be nice to allow database owners or even regular users to do
137 * this, but there are obvious privilege escalation risks which would have
138 * to somehow be plugged first.
139 */
140 if (!superuser())
143 errmsg("permission denied to create event trigger \"%s\"",
144 stmt->trigname),
145 errhint("Must be superuser to create an event trigger.")));
146
147 /* Validate event name. */
148 if (strcmp(stmt->eventname, "ddl_command_start") != 0 &&
149 strcmp(stmt->eventname, "ddl_command_end") != 0 &&
150 strcmp(stmt->eventname, "sql_drop") != 0 &&
151 strcmp(stmt->eventname, "login") != 0 &&
152 strcmp(stmt->eventname, "table_rewrite") != 0)
155 errmsg("unrecognized event name \"%s\"",
156 stmt->eventname)));
157
158 /* Validate filter conditions. */
159 foreach(lc, stmt->whenclause)
160 {
161 DefElem *def = (DefElem *) lfirst(lc);
162
163 if (strcmp(def->defname, "tag") == 0)
164 {
165 if (tags != NULL)
167 tags = (List *) def->arg;
168 }
169 else
172 errmsg("unrecognized filter variable \"%s\"", def->defname)));
173 }
174
175 /* Validate tag list, if any. */
176 if ((strcmp(stmt->eventname, "ddl_command_start") == 0 ||
177 strcmp(stmt->eventname, "ddl_command_end") == 0 ||
178 strcmp(stmt->eventname, "sql_drop") == 0)
179 && tags != NULL)
180 validate_ddl_tags("tag", tags);
181 else if (strcmp(stmt->eventname, "table_rewrite") == 0
182 && tags != NULL)
184 else if (strcmp(stmt->eventname, "login") == 0 && tags != NULL)
187 errmsg("tag filtering is not supported for login event triggers")));
188
189 /*
190 * Give user a nice error message if an event trigger of the same name
191 * already exists.
192 */
194 if (HeapTupleIsValid(tuple))
197 errmsg("event trigger \"%s\" already exists",
198 stmt->trigname)));
199
200 /* Find and validate the trigger function. */
201 funcoid = LookupFuncName(stmt->funcname, 0, NULL, false);
206 errmsg("function %s must return type %s",
207 NameListToString(stmt->funcname), "event_trigger")));
208
209 /* Insert catalog entries. */
210 return insert_event_trigger_tuple(stmt->trigname, stmt->eventname,
211 evtowner, funcoid, tags);
212}
int errhint(const char *fmt,...) pg_attribute_printf(1
static void validate_table_rewrite_tags(const char *filtervar, List *taglist)
static void validate_ddl_tags(const char *filtervar, List *taglist)
static void error_duplicate_filter_variable(const char *defname)
static Oid insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtOwner, Oid funcoid, List *taglist)
Oid get_func_rettype(Oid funcid)
Definition lsyscache.c:1961
char * NameListToString(const List *names)
Definition namespace.c:3666
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
#define lfirst(lc)
Definition pg_list.h:172
#define ERRCODE_DUPLICATE_OBJECT
Definition streamutil.c:30
char * defname
Definition parsenodes.h:860
Node * arg
Definition parsenodes.h:861
Definition pg_list.h:54
bool superuser(void)
Definition superuser.c:47
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:221

References DefElem::arg, CStringGetDatum(), DefElem::defname, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg, ERROR, error_duplicate_filter_variable(), fb(), get_func_rettype(), GetUserId(), HeapTupleIsValid, insert_event_trigger_tuple(), lfirst, LookupFuncName(), NameListToString(), SearchSysCache1(), stmt, superuser(), validate_ddl_tags(), and validate_table_rewrite_tags().

Referenced by standard_ProcessUtility().

◆ EventTriggerAlterTableEnd()

void EventTriggerAlterTableEnd ( void  )
extern

Definition at line 1850 of file event_trigger.c.

1851{
1852 CollectedCommand *parent;
1853
1854 /* ignore if event trigger context not set, or collection disabled */
1857 return;
1858
1860
1861 /* If no subcommands, don't collect */
1863 {
1865
1867
1871
1873 }
1874 else
1876
1878}
static EventTriggerQueryState * currentEventTriggerState
List * lappend(List *list, void *datum)
Definition list.c:339
void pfree(void *pointer)
Definition mcxt.c:1619
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:138
#define NIL
Definition pg_list.h:68
union CollectedCommand::@137 d
struct CollectedCommand * parent
struct CollectedCommand::@137::@139 alterTable
CollectedCommand * currentCommand

References CollectedCommand::alterTable, EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, EventTriggerQueryState::currentCommand, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), lappend(), MemoryContextSwitchTo(), NIL, CollectedCommand::parent, pfree(), and CollectedCommand::subcmds.

Referenced by AlterTableMoveAll(), ProcessUtilityForAlterTable(), and ProcessUtilitySlow().

◆ EventTriggerAlterTableRelid()

◆ EventTriggerAlterTableStart()

void EventTriggerAlterTableStart ( const Node parsetree)
extern

Definition at line 1763 of file event_trigger.c.

1764{
1766 CollectedCommand *command;
1767
1768 /* ignore if event trigger context not set, or collection disabled */
1771 return;
1772
1774
1776
1777 command->type = SCT_AlterTable;
1779
1781 command->d.alterTable.objectId = InvalidOid;
1782 command->d.alterTable.subcmds = NIL;
1783 command->parsetree = copyObject(parsetree);
1784
1787
1789}
@ SCT_AlterTable
bool creating_extension
Definition extension.c:80
#define palloc_object(type)
Definition fe_memutils.h:89
#define copyObject(obj)
Definition nodes.h:232
#define InvalidOid
CollectedCommandType type

References CollectedCommand::alterTable, CollectedCommand::classId, EventTriggerQueryState::commandCollectionInhibited, copyObject, creating_extension, EventTriggerQueryState::currentCommand, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), CollectedCommand::in_extension, InvalidOid, MemoryContextSwitchTo(), NIL, CollectedCommand::objectId, palloc_object, CollectedCommand::parent, CollectedCommand::parsetree, SCT_AlterTable, CollectedCommand::subcmds, and CollectedCommand::type.

Referenced by AlterTableMoveAll(), ProcessUtilityForAlterTable(), and ProcessUtilitySlow().

◆ EventTriggerBeginCompleteQuery()

bool EventTriggerBeginCompleteQuery ( void  )
extern

Definition at line 1193 of file event_trigger.c.

1194{
1196 MemoryContext cxt;
1197
1198 /*
1199 * Currently, sql_drop, table_rewrite, ddl_command_end events are the only
1200 * reason to have event trigger state at all; so if there are none, don't
1201 * install one.
1202 */
1204 return false;
1205
1207 "event trigger state",
1210 state->cxt = cxt;
1211 slist_init(&(state->SQLDropList));
1212 state->in_sql_drop = false;
1213 state->table_rewrite_oid = InvalidOid;
1214
1215 state->commandCollectionInhibited = currentEventTriggerState ?
1217 state->currentCommand = NULL;
1218 state->commandList = NIL;
1219 state->previous = currentEventTriggerState;
1221
1222 return true;
1223}
bool trackDroppedObjectsNeeded(void)
static void slist_init(slist_head *head)
Definition ilist.h:986
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1235
MemoryContext TopMemoryContext
Definition mcxt.c:167
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, EventTriggerQueryState::commandCollectionInhibited, currentEventTriggerState, fb(), InvalidOid, MemoryContextAlloc(), NIL, slist_init(), TopMemoryContext, and trackDroppedObjectsNeeded().

Referenced by ProcessUtilitySlow().

◆ EventTriggerCollectAlterDefPrivs()

void EventTriggerCollectAlterDefPrivs ( const AlterDefaultPrivilegesStmt stmt)
extern

Definition at line 2037 of file event_trigger.c.

2038{
2040 CollectedCommand *command;
2041
2042 /* ignore if event trigger context not set, or collection disabled */
2045 return;
2046
2048
2051 command->d.defprivs.objtype = stmt->action->objtype;
2053 command->parsetree = (Node *) copyObject(stmt);
2054
2058}
@ SCT_AlterDefaultPrivileges
#define palloc0_object(type)
Definition fe_memutils.h:90
struct CollectedCommand::@137::@144 defprivs
Definition nodes.h:135

References EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, copyObject, creating_extension, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, CollectedCommand::defprivs, fb(), CollectedCommand::in_extension, lappend(), MemoryContextSwitchTo(), CollectedCommand::objtype, palloc0_object, CollectedCommand::parsetree, SCT_AlterDefaultPrivileges, stmt, and CollectedCommand::type.

Referenced by ProcessUtilitySlow().

◆ EventTriggerCollectAlterOpFam()

void EventTriggerCollectAlterOpFam ( const AlterOpFamilyStmt stmt,
Oid  opfamoid,
List operators,
List procedures 
)
extern

Definition at line 1932 of file event_trigger.c.

1934{
1936 CollectedCommand *command;
1937
1938 /* ignore if event trigger context not set, or collection disabled */
1941 return;
1942
1944
1946 command->type = SCT_AlterOpFamily;
1950 command->d.opfam.operators = operators;
1951 command->d.opfam.procedures = procedures;
1952 command->parsetree = (Node *) copyObject(stmt);
1953
1956
1958}
@ SCT_AlterOpFamily
struct CollectedCommand::@137::@141 opfam
ObjectAddress address

References CollectedCommand::address, EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, copyObject, creating_extension, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), CollectedCommand::in_extension, lappend(), MemoryContextSwitchTo(), ObjectAddressSet, CollectedCommand::operators, CollectedCommand::opfam, palloc_object, CollectedCommand::parsetree, CollectedCommand::procedures, SCT_AlterOpFamily, stmt, and CollectedCommand::type.

Referenced by AlterOpFamilyAdd(), and AlterOpFamilyDrop().

◆ EventTriggerCollectAlterTableSubcmd()

void EventTriggerCollectAlterTableSubcmd ( const Node subcmd,
ObjectAddress  address 
)
extern

Definition at line 1815 of file event_trigger.c.

1816{
1819
1820 /* ignore if event trigger context not set, or collection disabled */
1823 return;
1824
1828
1830
1832 newsub->address = address;
1833 newsub->parsetree = copyObject(subcmd);
1834
1837
1839}
#define Assert(condition)
Definition c.h:943
#define OidIsValid(objectId)
Definition c.h:858
#define IsA(nodeptr, _type_)
Definition nodes.h:164
static color newsub(struct colormap *cm, color co)
Definition regc_color.c:390

References CollectedCommand::alterTable, Assert, EventTriggerQueryState::commandCollectionInhibited, copyObject, EventTriggerQueryState::currentCommand, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), IsA, lappend(), MemoryContextSwitchTo(), newsub(), CollectedCommand::objectId, OidIsValid, palloc_object, and CollectedCommand::subcmds.

Referenced by ATExecCmd().

◆ EventTriggerCollectAlterTSConfig()

void EventTriggerCollectAlterTSConfig ( const AlterTSConfigurationStmt stmt,
Oid  cfgId,
Oid dictIds,
int  ndicts 
)
extern

Definition at line 1999 of file event_trigger.c.

2001{
2003 CollectedCommand *command;
2004
2005 /* ignore if event trigger context not set, or collection disabled */
2008 return;
2009
2011
2013 command->type = SCT_AlterTSConfig;
2016 TSConfigRelationId, cfgId);
2017 if (ndicts > 0)
2018 {
2019 command->d.atscfg.dictIds = palloc_array(Oid, ndicts);
2020 memcpy(command->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
2021 }
2022 command->d.atscfg.ndicts = ndicts;
2023 command->parsetree = (Node *) copyObject(stmt);
2024
2027
2029}
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
@ SCT_AlterTSConfig
#define palloc_array(type, count)
Definition fe_memutils.h:91
struct CollectedCommand::@137::@143 atscfg

References CollectedCommand::address, CollectedCommand::atscfg, EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, copyObject, creating_extension, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, CollectedCommand::dictIds, fb(), CollectedCommand::in_extension, lappend(), memcpy(), MemoryContextSwitchTo(), CollectedCommand::ndicts, ObjectAddressSet, palloc0_object, palloc_array, CollectedCommand::parsetree, SCT_AlterTSConfig, stmt, and CollectedCommand::type.

Referenced by DropConfigurationMapping(), and MakeConfigurationMapping().

◆ EventTriggerCollectCreateOpClass()

void EventTriggerCollectCreateOpClass ( const CreateOpClassStmt stmt,
Oid  opcoid,
List operators,
List procedures 
)
extern

Definition at line 1965 of file event_trigger.c.

1967{
1969 CollectedCommand *command;
1970
1971 /* ignore if event trigger context not set, or collection disabled */
1974 return;
1975
1977
1979 command->type = SCT_CreateOpClass;
1983 command->d.createopc.operators = operators;
1984 command->d.createopc.procedures = procedures;
1985 command->parsetree = (Node *) copyObject(stmt);
1986
1989
1991}
@ SCT_CreateOpClass
struct CollectedCommand::@137::@142 createopc

References CollectedCommand::address, EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, copyObject, CollectedCommand::createopc, creating_extension, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), CollectedCommand::in_extension, lappend(), MemoryContextSwitchTo(), ObjectAddressSet, CollectedCommand::operators, palloc0_object, CollectedCommand::parsetree, CollectedCommand::procedures, SCT_CreateOpClass, stmt, and CollectedCommand::type.

Referenced by DefineOpClass().

◆ EventTriggerCollectGrant()

void EventTriggerCollectGrant ( InternalGrant istmt)
extern

Definition at line 1888 of file event_trigger.c.

1889{
1891 CollectedCommand *command;
1893 ListCell *cell;
1894
1895 /* ignore if event trigger context not set, or collection disabled */
1898 return;
1899
1901
1902 /*
1903 * This is tedious, but necessary.
1904 */
1906 memcpy(icopy, istmt, sizeof(InternalGrant));
1907 icopy->objects = list_copy(istmt->objects);
1908 icopy->grantees = list_copy(istmt->grantees);
1909 icopy->col_privs = NIL;
1910 foreach(cell, istmt->col_privs)
1911 icopy->col_privs = lappend(icopy->col_privs, copyObject(lfirst(cell)));
1912
1913 /* Now collect it, using the copied InternalGrant */
1915 command->type = SCT_Grant;
1917 command->d.grant.istmt = icopy;
1918 command->parsetree = NULL;
1919
1922
1924}
@ SCT_Grant
List * list_copy(const List *oldlist)
Definition list.c:1573
InternalGrant * istmt
struct CollectedCommand::@137::@140 grant

References InternalGrant::col_privs, EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, copyObject, creating_extension, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), CollectedCommand::grant, InternalGrant::grantees, CollectedCommand::in_extension, CollectedCommand::istmt, lappend(), lfirst, list_copy(), memcpy(), MemoryContextSwitchTo(), NIL, InternalGrant::objects, palloc_object, CollectedCommand::parsetree, SCT_Grant, and CollectedCommand::type.

Referenced by ExecGrantStmt_oids().

◆ EventTriggerCollectSimpleCommand()

void EventTriggerCollectSimpleCommand ( ObjectAddress  address,
ObjectAddress  secondaryObject,
const Node parsetree 
)
extern

Definition at line 1725 of file event_trigger.c.

1728{
1730 CollectedCommand *command;
1731
1732 /* ignore if event trigger context not set, or collection disabled */
1735 return;
1736
1738
1740
1741 command->type = SCT_Simple;
1743
1744 command->d.simple.address = address;
1745 command->d.simple.secondaryObject = secondaryObject;
1746 command->parsetree = copyObject(parsetree);
1747
1749 command);
1750
1752}
@ SCT_Simple
ObjectAddress secondaryObject
struct CollectedCommand::@137::@138 simple

References CollectedCommand::address, EventTriggerQueryState::commandCollectionInhibited, EventTriggerQueryState::commandList, copyObject, creating_extension, currentEventTriggerState, EventTriggerQueryState::cxt, CollectedCommand::d, fb(), CollectedCommand::in_extension, lappend(), MemoryContextSwitchTo(), palloc_object, CollectedCommand::parsetree, SCT_Simple, CollectedCommand::secondaryObject, CollectedCommand::simple, and CollectedCommand::type.

Referenced by AlterPublicationOptions(), CreateOpFamily(), CreateSchemaCommand(), ProcessUtilitySlow(), PublicationAddSchemas(), PublicationAddTables(), reindex_index(), and ReindexRelationConcurrently().

◆ EventTriggerDDLCommandEnd()

void EventTriggerDDLCommandEnd ( Node parsetree)
extern

Definition at line 778 of file event_trigger.c.

779{
780 List *runlist;
781 EventTriggerData trigdata;
782
783 /*
784 * See EventTriggerDDLCommandStart for a discussion about why event
785 * triggers are disabled in single user mode or via GUC.
786 */
788 return;
789
790 /*
791 * Also do nothing if our state isn't set up, which it won't be if there
792 * weren't any relevant event triggers at the start of the current DDL
793 * command. This test might therefore seem optional, but it's important
794 * because EventTriggerCommonSetup might find triggers that didn't exist
795 * at the time the command started. Although this function itself
796 * wouldn't crash, the event trigger functions would presumably call
797 * pg_event_trigger_ddl_commands which would fail. Better to do nothing
798 * until the next command.
799 */
801 return;
802
804 EVT_DDLCommandEnd, "ddl_command_end",
805 &trigdata, false);
806 if (runlist == NIL)
807 return;
808
809 /*
810 * Make sure anything the main command did will be visible to the event
811 * triggers.
812 */
814
815 /* Run the triggers. */
816 EventTriggerInvoke(runlist, &trigdata);
817
818 /* Cleanup. */
820}
bool event_triggers
static List * EventTriggerCommonSetup(Node *parsetree, EventTriggerEvent event, const char *eventstr, EventTriggerData *trigdata, bool unfiltered)
static void EventTriggerInvoke(List *fn_oid_list, EventTriggerData *trigdata)
@ EVT_DDLCommandEnd
Definition evtcache.h:23
bool IsUnderPostmaster
Definition globals.c:122
void list_free(List *list)
Definition list.c:1546
void CommandCounterIncrement(void)
Definition xact.c:1130

References CommandCounterIncrement(), currentEventTriggerState, event_triggers, EventTriggerCommonSetup(), EventTriggerInvoke(), EVT_DDLCommandEnd, fb(), IsUnderPostmaster, list_free(), and NIL.

Referenced by ProcessUtilitySlow().

◆ EventTriggerDDLCommandStart()

void EventTriggerDDLCommandStart ( Node parsetree)
extern

Definition at line 727 of file event_trigger.c.

728{
729 List *runlist;
730 EventTriggerData trigdata;
731
732 /*
733 * Event Triggers are completely disabled in standalone mode. There are
734 * (at least) two reasons for this:
735 *
736 * 1. A sufficiently broken event trigger might not only render the
737 * database unusable, but prevent disabling itself to fix the situation.
738 * In this scenario, restarting in standalone mode provides an escape
739 * hatch.
740 *
741 * 2. BuildEventTriggerCache relies on systable_beginscan_ordered, and
742 * therefore will malfunction if pg_event_trigger's indexes are damaged.
743 * To allow recovery from a damaged index, we need some operating mode
744 * wherein event triggers are disabled. (Or we could implement
745 * heapscan-and-sort logic for that case, but having disaster recovery
746 * scenarios depend on code that's otherwise untested isn't appetizing.)
747 *
748 * Additionally, event triggers can be disabled with a superuser-only GUC
749 * to make fixing database easier as per 1 above.
750 */
752 return;
753
756 "ddl_command_start",
757 &trigdata, false);
758 if (runlist == NIL)
759 return;
760
761 /* Run the triggers. */
762 EventTriggerInvoke(runlist, &trigdata);
763
764 /* Cleanup. */
766
767 /*
768 * Make sure anything the event triggers did will be visible to the main
769 * command.
770 */
772}
@ EVT_DDLCommandStart
Definition evtcache.h:22

References CommandCounterIncrement(), event_triggers, EventTriggerCommonSetup(), EventTriggerInvoke(), EVT_DDLCommandStart, fb(), IsUnderPostmaster, list_free(), and NIL.

Referenced by ProcessUtilitySlow().

◆ EventTriggerEndCompleteQuery()

void EventTriggerEndCompleteQuery ( void  )
extern

Definition at line 1237 of file event_trigger.c.

1238{
1240
1242
1243 /* this avoids the need for retail pfree of SQLDropList items: */
1245
1247}
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:475
struct EventTriggerQueryState * previous

References currentEventTriggerState, EventTriggerQueryState::cxt, fb(), MemoryContextDelete(), and EventTriggerQueryState::previous.

Referenced by ProcessUtilitySlow().

◆ EventTriggerInhibitCommandCollection()

void EventTriggerInhibitCommandCollection ( void  )
extern

◆ EventTriggerOnLogin()

void EventTriggerOnLogin ( void  )
extern

Definition at line 899 of file event_trigger.c.

900{
901 List *runlist;
902 EventTriggerData trigdata;
903
904 /*
905 * See EventTriggerDDLCommandStart for a discussion about why event
906 * triggers are disabled in single user mode or via a GUC. We also need a
907 * database connection (some background workers don't have it).
908 */
911 return;
912
915 EVT_Login, "login",
916 &trigdata, false);
917
918 if (runlist != NIL)
919 {
920 /*
921 * Event trigger execution may require an active snapshot.
922 */
924
925 /* Run the triggers. */
926 EventTriggerInvoke(runlist, &trigdata);
927
928 /* Cleanup. */
930
932 }
933
934 /*
935 * There is no active login event trigger, but our
936 * pg_database.dathasloginevt is set. Try to unset this flag. We use the
937 * lock to prevent concurrent SetDatabaseHasLoginEventTriggers(), but we
938 * don't want to hang the connection waiting on the lock. Thus, we are
939 * just trying to acquire the lock conditionally.
940 *
941 * Skip this on a hot standby: the conditional AccessExclusiveLock on the
942 * database object would fail with "cannot acquire lock mode ... while
943 * recovery is in progress", which the caller would surface as a FATAL
944 * connection error. On a standby, we cannot (and must not) clear the
945 * pg_database flag ourselves; it will be cleared via WAL replay once the
946 * primary's next login event trigger run clears it on the primary.
947 */
948 else if (!RecoveryInProgress() &&
951 {
952 /*
953 * The lock is held. Now we need to recheck that login event triggers
954 * list is still empty. Once the list is empty, we know that even if
955 * there is a backend which concurrently inserts/enables a login event
956 * trigger, it will update pg_database.dathasloginevt *afterwards*.
957 */
959 EVT_Login, "login",
960 &trigdata, true);
961
962 if (runlist == NIL)
963 {
965 HeapTuple tuple;
966 void *state;
968 ScanKeyData key[1];
969
970 /* Fetch a copy of the tuple to scribble on */
971 ScanKeyInit(&key[0],
975
977 NULL, 1, key, &tuple, &state);
978
979 if (!HeapTupleIsValid(tuple))
980 elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
981
982 db = (Form_pg_database) GETSTRUCT(tuple);
983 if (db->dathasloginevt)
984 {
985 db->dathasloginevt = false;
986
987 /*
988 * Do an "in place" update of the pg_database tuple. Doing
989 * this instead of regular updates serves two purposes. First,
990 * that avoids possible waiting on the row-level lock. Second,
991 * that avoids dealing with TOAST.
992 */
994 }
995 else
998 heap_freetuple(tuple);
999 }
1000 else
1001 {
1003 }
1004 }
1006}
#define elog(elevel,...)
Definition elog.h:228
@ EVT_Login
Definition evtcache.h:26
void systable_inplace_update_cancel(void *state)
Definition genam.c:905
void systable_inplace_update_begin(Relation relation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, const ScanKeyData *key, HeapTuple *oldtupcopy, void **state)
Definition genam.c:810
void systable_inplace_update_finish(void *state, HeapTuple tuple)
Definition genam.c:886
bool MyDatabaseHasLoginEventTriggers
Definition globals.c:100
Oid MyDatabaseId
Definition globals.c:96
bool ConditionalLockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition lmgr.c:1112
#define AccessExclusiveLock
Definition lockdefs.h:43
END_CATALOG_STRUCT typedef FormData_pg_database * Form_pg_database
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition scankey.c:76
Snapshot GetTransactionSnapshot(void)
Definition snapmgr.c:272
void PushActiveSnapshot(Snapshot snapshot)
Definition snapmgr.c:682
void PopActiveSnapshot(void)
Definition snapmgr.c:775
#define BTEqualStrategyNumber
Definition stratnum.h:31
void StartTransactionCommand(void)
Definition xact.c:3109
void CommitTransactionCommand(void)
Definition xact.c:3207
bool RecoveryInProgress(void)
Definition xlog.c:6834

References AccessExclusiveLock, BTEqualStrategyNumber, CommitTransactionCommand(), ConditionalLockSharedObject(), elog, ERROR, event_triggers, EventTriggerCommonSetup(), EventTriggerInvoke(), EVT_Login, fb(), Form_pg_database, GETSTRUCT(), GetTransactionSnapshot(), heap_freetuple(), HeapTupleIsValid, IsUnderPostmaster, list_free(), MyDatabaseHasLoginEventTriggers, MyDatabaseId, NIL, ObjectIdGetDatum(), OidIsValid, PopActiveSnapshot(), PushActiveSnapshot(), RecoveryInProgress(), RowExclusiveLock, ScanKeyInit(), StartTransactionCommand(), systable_inplace_update_begin(), systable_inplace_update_cancel(), systable_inplace_update_finish(), table_close(), and table_open().

Referenced by PostgresMain().

◆ EventTriggerSQLDrop()

void EventTriggerSQLDrop ( Node parsetree)
extern

Definition at line 826 of file event_trigger.c.

827{
828 List *runlist;
829 EventTriggerData trigdata;
830
831 /*
832 * See EventTriggerDDLCommandStart for a discussion about why event
833 * triggers are disabled in single user mode or via a GUC.
834 */
836 return;
837
838 /*
839 * Use current state to determine whether this event fires at all. If
840 * there are no triggers for the sql_drop event, then we don't have
841 * anything to do here. Note that dropped object collection is disabled
842 * if this is the case, so even if we were to try to run, the list would
843 * be empty.
844 */
847 return;
848
850 EVT_SQLDrop, "sql_drop",
851 &trigdata, false);
852
853 /*
854 * Nothing to do if run list is empty. Note this typically can't happen,
855 * because if there are no sql_drop events, then objects-to-drop wouldn't
856 * have been collected in the first place and we would have quit above.
857 * But it could occur if event triggers were dropped partway through.
858 */
859 if (runlist == NIL)
860 return;
861
862 /*
863 * Make sure anything the main command did will be visible to the event
864 * triggers.
865 */
867
868 /*
869 * Make sure pg_event_trigger_dropped_objects only works when running
870 * these triggers. Use PG_TRY to ensure in_sql_drop is reset even when
871 * one trigger fails. (This is perhaps not necessary, as the currentState
872 * variable will be removed shortly by our caller, but it seems better to
873 * play safe.)
874 */
876
877 /* Run the triggers. */
878 PG_TRY();
879 {
880 EventTriggerInvoke(runlist, &trigdata);
881 }
882 PG_FINALLY();
883 {
885 }
886 PG_END_TRY();
887
888 /* Cleanup. */
890}
#define PG_TRY(...)
Definition elog.h:374
#define PG_END_TRY(...)
Definition elog.h:399
#define PG_FINALLY(...)
Definition elog.h:391
@ EVT_SQLDrop
Definition evtcache.h:24
static bool slist_is_empty(const slist_head *head)
Definition ilist.h:995

References CommandCounterIncrement(), currentEventTriggerState, event_triggers, EventTriggerCommonSetup(), EventTriggerInvoke(), EVT_SQLDrop, fb(), EventTriggerQueryState::in_sql_drop, IsUnderPostmaster, list_free(), NIL, PG_END_TRY, PG_FINALLY, PG_TRY, slist_is_empty(), and EventTriggerQueryState::SQLDropList.

Referenced by ProcessUtilitySlow().

◆ EventTriggerSQLDropAddObject()

void EventTriggerSQLDropAddObject ( const ObjectAddress object,
bool  original,
bool  normal 
)
extern

Definition at line 1287 of file event_trigger.c.

1288{
1289 SQLDropObject *obj;
1291
1293 return;
1294
1296
1298
1300 obj->address = *object;
1301 obj->original = original;
1302 obj->normal = normal;
1303
1304 if (object->classId == NamespaceRelationId)
1305 {
1306 /* Special handling is needed for temp namespaces */
1307 if (isTempNamespace(object->objectId))
1308 obj->istemp = true;
1309 else if (isAnyTempNamespace(object->objectId))
1310 {
1311 /* don't report temp schemas except my own */
1312 pfree(obj);
1314 return;
1315 }
1316 obj->objname = get_namespace_name(object->objectId);
1317 }
1318 else if (object->classId == AttrDefaultRelationId)
1319 {
1320 /* We treat a column default as temp if its table is temp */
1322
1324 if (OidIsValid(colobject.objectId))
1325 {
1327 {
1328 pfree(obj);
1330 return;
1331 }
1332 }
1333 }
1334 else if (object->classId == TriggerRelationId)
1335 {
1336 /* Similarly, a trigger is temp if its table is temp */
1337 /* Sadly, there's no lsyscache.c support for trigger objects */
1339 ScanKeyData skey[1];
1341 HeapTuple tuple;
1342 Oid relid;
1343
1344 /* Fetch the trigger's table OID the hard way */
1346 ScanKeyInit(&skey[0],
1349 ObjectIdGetDatum(object->objectId));
1351 NULL, 1, skey);
1352 tuple = systable_getnext(sscan);
1353 if (HeapTupleIsValid(tuple))
1354 relid = ((Form_pg_trigger) GETSTRUCT(tuple))->tgrelid;
1355 else
1356 relid = InvalidOid; /* shouldn't happen */
1359 /* Do nothing if we didn't find the trigger */
1360 if (OidIsValid(relid))
1361 {
1363
1365 relobject.objectId = relid;
1366 /* Arbitrarily set objectSubId nonzero so as not to fill objname */
1367 relobject.objectSubId = 1;
1369 {
1370 pfree(obj);
1372 return;
1373 }
1374 }
1375 }
1376 else if (object->classId == PolicyRelationId)
1377 {
1378 /* Similarly, a policy is temp if its table is temp */
1379 /* Sadly, there's no lsyscache.c support for policy objects */
1381 ScanKeyData skey[1];
1383 HeapTuple tuple;
1384 Oid relid;
1385
1386 /* Fetch the policy's table OID the hard way */
1388 ScanKeyInit(&skey[0],
1391 ObjectIdGetDatum(object->objectId));
1393 NULL, 1, skey);
1394 tuple = systable_getnext(sscan);
1395 if (HeapTupleIsValid(tuple))
1396 relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
1397 else
1398 relid = InvalidOid; /* shouldn't happen */
1401 /* Do nothing if we didn't find the policy */
1402 if (OidIsValid(relid))
1403 {
1405
1407 relobject.objectId = relid;
1408 /* Arbitrarily set objectSubId nonzero so as not to fill objname */
1409 relobject.objectSubId = 1;
1411 {
1412 pfree(obj);
1414 return;
1415 }
1416 }
1417 }
1418 else
1419 {
1420 /* Generic handling for all other object classes */
1421 if (!obtain_object_name_namespace(object, obj))
1422 {
1423 /* don't report temp objects except my own */
1424 pfree(obj);
1426 return;
1427 }
1428 }
1429
1430 /* object identity, objname and objargs */
1431 obj->objidentity =
1433 false);
1434
1435 /* object type */
1436 obj->objecttype = getObjectTypeDescription(&obj->address, false);
1437
1439
1441}
static bool obtain_object_name_namespace(const ObjectAddress *object, SQLDropObject *obj)
bool EventTriggerSupportsObject(const ObjectAddress *object)
void systable_endscan(SysScanDesc sysscan)
Definition genam.c:604
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition genam.c:515
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition genam.c:388
static void slist_push_head(slist_head *head, slist_node *node)
Definition ilist.h:1006
#define AccessShareLock
Definition lockdefs.h:36
char * get_namespace_name(Oid nspid)
Definition lsyscache.c:3674
bool isTempNamespace(Oid namespaceId)
Definition namespace.c:3721
bool isAnyTempNamespace(Oid namespaceId)
Definition namespace.c:3759
char * getObjectTypeDescription(const ObjectAddress *object, bool missing_ok)
char * getObjectIdentityParts(const ObjectAddress *object, List **objname, List **objargs, bool missing_ok)
ObjectAddress GetAttrDefaultColumnAddress(Oid attrdefoid)
Definition pg_attrdef.c:322
END_CATALOG_STRUCT typedef FormData_pg_policy * Form_pg_policy
Definition pg_policy.h:55
END_CATALOG_STRUCT typedef FormData_pg_trigger * Form_pg_trigger
Definition pg_trigger.h:84
ObjectAddress address
slist_node next
const char * objidentity
const char * objecttype
const char * objname

References AccessShareLock, SQLDropObject::addrargs, SQLDropObject::address, SQLDropObject::addrnames, Assert, BTEqualStrategyNumber, ObjectAddress::classId, currentEventTriggerState, EventTriggerQueryState::cxt, EventTriggerSupportsObject(), fb(), Form_pg_policy, Form_pg_trigger, get_namespace_name(), GetAttrDefaultColumnAddress(), getObjectIdentityParts(), getObjectTypeDescription(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, isAnyTempNamespace(), SQLDropObject::istemp, isTempNamespace(), MemoryContextSwitchTo(), SQLDropObject::next, SQLDropObject::normal, ObjectAddress::objectId, ObjectIdGetDatum(), SQLDropObject::objecttype, SQLDropObject::objidentity, SQLDropObject::objname, obtain_object_name_namespace(), OidIsValid, SQLDropObject::original, palloc0_object, pfree(), ScanKeyInit(), slist_push_head(), EventTriggerQueryState::SQLDropList, systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().

Referenced by deleteObjectsInList(), and DropSubscription().

◆ EventTriggerSupportsObject()

bool EventTriggerSupportsObject ( const ObjectAddress object)
extern

Definition at line 1167 of file event_trigger.c.

1168{
1169 switch (object->classId)
1170 {
1171 case DatabaseRelationId:
1173 case AuthIdRelationId:
1174 case AuthMemRelationId:
1176 /* no support for global objects (except subscriptions) */
1177 return false;
1179 /* no support for event triggers on event triggers */
1180 return false;
1181 default:
1182 return true;
1183 }
1184}

References ObjectAddress::classId, and fb().

Referenced by deleteObjectsInList(), and EventTriggerSQLDropAddObject().

◆ EventTriggerSupportsObjectType()

bool EventTriggerSupportsObjectType ( ObjectType  obtype)
extern

Definition at line 1143 of file event_trigger.c.

1144{
1145 switch (obtype)
1146 {
1147 case OBJECT_DATABASE:
1148 case OBJECT_TABLESPACE:
1149 case OBJECT_ROLE:
1151 /* no support for global objects (except subscriptions) */
1152 return false;
1154 /* no support for event triggers on event triggers */
1155 return false;
1156 default:
1157 return true;
1158 }
1159}
@ OBJECT_TABLESPACE
@ OBJECT_ROLE
@ OBJECT_DATABASE
@ OBJECT_PARAMETER_ACL

References fb(), OBJECT_DATABASE, OBJECT_EVENT_TRIGGER, OBJECT_PARAMETER_ACL, OBJECT_ROLE, and OBJECT_TABLESPACE.

Referenced by ExecGrantStmt_oids(), and standard_ProcessUtility().

◆ EventTriggerTableRewrite()

void EventTriggerTableRewrite ( Node parsetree,
Oid  tableOid,
int  reason 
)
extern

Definition at line 1013 of file event_trigger.c.

1014{
1015 List *runlist;
1016 EventTriggerData trigdata;
1017
1018 /*
1019 * See EventTriggerDDLCommandStart for a discussion about why event
1020 * triggers are disabled in single user mode or via a GUC.
1021 */
1023 return;
1024
1025 /*
1026 * Also do nothing if our state isn't set up, which it won't be if there
1027 * weren't any relevant event triggers at the start of the current DDL
1028 * command. This test might therefore seem optional, but it's
1029 * *necessary*, because EventTriggerCommonSetup might find triggers that
1030 * didn't exist at the time the command started.
1031 */
1033 return;
1034
1035 runlist = EventTriggerCommonSetup(parsetree,
1037 "table_rewrite",
1038 &trigdata, false);
1039 if (runlist == NIL)
1040 return;
1041
1042 /*
1043 * Make sure pg_event_trigger_table_rewrite_oid only works when running
1044 * these triggers. Use PG_TRY to ensure table_rewrite_oid is reset even
1045 * when one trigger fails. (This is perhaps not necessary, as the
1046 * currentState variable will be removed shortly by our caller, but it
1047 * seems better to play safe.)
1048 */
1051
1052 /* Run the triggers. */
1053 PG_TRY();
1054 {
1055 EventTriggerInvoke(runlist, &trigdata);
1056 }
1057 PG_FINALLY();
1058 {
1061 }
1062 PG_END_TRY();
1063
1064 /* Cleanup. */
1066
1067 /*
1068 * Make sure anything the event triggers did will be visible to the main
1069 * command.
1070 */
1072}
@ EVT_TableRewrite
Definition evtcache.h:25

References CommandCounterIncrement(), currentEventTriggerState, event_triggers, EventTriggerCommonSetup(), EventTriggerInvoke(), EVT_TableRewrite, fb(), InvalidOid, IsUnderPostmaster, list_free(), NIL, PG_END_TRY, PG_FINALLY, PG_TRY, EventTriggerQueryState::table_rewrite_oid, and EventTriggerQueryState::table_rewrite_reason.

Referenced by ATRewriteTables().

◆ EventTriggerUndoInhibitCommandCollection()

void EventTriggerUndoInhibitCommandCollection ( void  )
extern

Definition at line 1703 of file event_trigger.c.

1704{
1706 return;
1707
1709}

References EventTriggerQueryState::commandCollectionInhibited, and currentEventTriggerState.

Referenced by ProcessUtilitySlow().

◆ get_event_trigger_oid()

Oid get_event_trigger_oid ( const char trigname,
bool  missing_ok 
)
extern

Definition at line 581 of file event_trigger.c.

582{
583 Oid oid;
584
586 CStringGetDatum(trigname));
587 if (!OidIsValid(oid) && !missing_ok)
590 errmsg("event trigger \"%s\" does not exist", trigname)));
591 return oid;
592}
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition syscache.h:109

References CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), GetSysCacheOid1, and OidIsValid.

Referenced by get_object_address_unqualified().

◆ trackDroppedObjectsNeeded()

bool trackDroppedObjectsNeeded ( void  )
extern

Definition at line 1255 of file event_trigger.c.

1256{
1257 /*
1258 * true if any sql_drop, table_rewrite, ddl_command_end event trigger
1259 * exists
1260 */
1261 return (EventCacheLookup(EVT_SQLDrop) != NIL) ||
1264}
List * EventCacheLookup(EventTriggerEvent event)
Definition evtcache.c:64

References EventCacheLookup(), EVT_DDLCommandEnd, EVT_SQLDrop, EVT_TableRewrite, and NIL.

Referenced by deleteObjectsInList(), and EventTriggerBeginCompleteQuery().

Variable Documentation

◆ event_triggers