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 428 of file event_trigger.c.

429{
432 Oid trigoid;
434 char tgenabled = stmt->tgenabled;
435
437
439 CStringGetDatum(stmt->trigname));
440 if (!HeapTupleIsValid(tup))
443 errmsg("event trigger \"%s\" does not exist",
444 stmt->trigname)));
445
447 trigoid = evtForm->oid;
448
451 stmt->trigname);
452
453 /* tuple is a copy, so we can modify it below */
454 evtForm->evtenabled = tgenabled;
455
456 CatalogTupleUpdate(tgrel, &tup->t_self, tup);
457
458 /*
459 * Login event triggers have an additional flag in pg_database to enable
460 * faster lookups in hot codepaths. Set the flag unless already True.
461 */
462 if (namestrcmp(&evtForm->evtevent, "login") == 0 &&
463 tgenabled != TRIGGER_DISABLED)
465
467 trigoid, 0);
468
469 /* clean up */
472
473 return trigoid;
474}
@ 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:4133
int errcode(int sqlerrcode)
Definition elog.c:874
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
static void SetDatabaseHasLoginEventTriggers(void)
void heap_freetuple(HeapTuple htup)
Definition heaptuple.c:1384
#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:370
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 480 of file event_trigger.c.

481{
482 Oid evtOid;
485 Relation rel;
486 ObjectAddress address;
487
489
491
492 if (!HeapTupleIsValid(tup))
495 errmsg("event trigger \"%s\" does not exist", name)));
496
498 evtOid = evtForm->oid;
499
501
503
505
507
508 return address;
509}
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 515 of file event_trigger.c.

516{
518 Relation rel;
519
521
523
524 if (!HeapTupleIsValid(tup))
527 errmsg("event trigger with OID %u does not exist", trigOid)));
528
530
532
534}
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 125 of file event_trigger.c.

126{
127 HeapTuple tuple;
128 Oid funcoid;
130 Oid evtowner = GetUserId();
131 ListCell *lc;
132 List *tags = NULL;
133
134 /*
135 * It would be nice to allow database owners or even regular users to do
136 * this, but there are obvious privilege escalation risks which would have
137 * to somehow be plugged first.
138 */
139 if (!superuser())
142 errmsg("permission denied to create event trigger \"%s\"",
143 stmt->trigname),
144 errhint("Must be superuser to create an event trigger.")));
145
146 /* Validate event name. */
147 if (strcmp(stmt->eventname, "ddl_command_start") != 0 &&
148 strcmp(stmt->eventname, "ddl_command_end") != 0 &&
149 strcmp(stmt->eventname, "sql_drop") != 0 &&
150 strcmp(stmt->eventname, "login") != 0 &&
151 strcmp(stmt->eventname, "table_rewrite") != 0)
154 errmsg("unrecognized event name \"%s\"",
155 stmt->eventname)));
156
157 /* Validate filter conditions. */
158 foreach(lc, stmt->whenclause)
159 {
160 DefElem *def = (DefElem *) lfirst(lc);
161
162 if (strcmp(def->defname, "tag") == 0)
163 {
164 if (tags != NULL)
166 tags = (List *) def->arg;
167 }
168 else
171 errmsg("unrecognized filter variable \"%s\"", def->defname)));
172 }
173
174 /* Validate tag list, if any. */
175 if ((strcmp(stmt->eventname, "ddl_command_start") == 0 ||
176 strcmp(stmt->eventname, "ddl_command_end") == 0 ||
177 strcmp(stmt->eventname, "sql_drop") == 0)
178 && tags != NULL)
179 validate_ddl_tags("tag", tags);
180 else if (strcmp(stmt->eventname, "table_rewrite") == 0
181 && tags != NULL)
183 else if (strcmp(stmt->eventname, "login") == 0 && tags != NULL)
186 errmsg("tag filtering is not supported for login event triggers")));
187
188 /*
189 * Give user a nice error message if an event trigger of the same name
190 * already exists.
191 */
193 if (HeapTupleIsValid(tuple))
196 errmsg("event trigger \"%s\" already exists",
197 stmt->trigname)));
198
199 /* Find and validate the trigger function. */
200 funcoid = LookupFuncName(stmt->funcname, 0, NULL, false);
205 errmsg("function %s must return type %s",
206 NameListToString(stmt->funcname), "event_trigger")));
207
208 /* Insert catalog entries. */
209 return insert_event_trigger_tuple(stmt->trigname, stmt->eventname,
210 evtowner, funcoid, tags);
211}
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:1875
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:857
Node * arg
Definition parsenodes.h:858
Definition pg_list.h:54
bool superuser(void)
Definition superuser.c:47
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:220

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 1841 of file event_trigger.c.

1842{
1843 CollectedCommand *parent;
1844
1845 /* ignore if event trigger context not set, or collection disabled */
1848 return;
1849
1851
1852 /* If no subcommands, don't collect */
1854 {
1856
1858
1862
1864 }
1865 else
1867
1869}
static EventTriggerQueryState * currentEventTriggerState
List * lappend(List *list, void *datum)
Definition list.c:339
void pfree(void *pointer)
Definition mcxt.c:1616
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
#define NIL
Definition pg_list.h:68
struct CollectedCommand * parent
struct CollectedCommand::@134::@136 alterTable
union CollectedCommand::@134 d
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 1754 of file event_trigger.c.

1755{
1757 CollectedCommand *command;
1758
1759 /* ignore if event trigger context not set, or collection disabled */
1762 return;
1763
1765
1767
1768 command->type = SCT_AlterTable;
1770
1772 command->d.alterTable.objectId = InvalidOid;
1773 command->d.alterTable.subcmds = NIL;
1774 command->parsetree = copyObject(parsetree);
1775
1778
1780}
@ SCT_AlterTable
bool creating_extension
Definition extension.c:80
#define palloc_object(type)
Definition fe_memutils.h:74
#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 1184 of file event_trigger.c.

1185{
1187 MemoryContext cxt;
1188
1189 /*
1190 * Currently, sql_drop, table_rewrite, ddl_command_end events are the only
1191 * reason to have event trigger state at all; so if there are none, don't
1192 * install one.
1193 */
1195 return false;
1196
1198 "event trigger state",
1201 state->cxt = cxt;
1202 slist_init(&(state->SQLDropList));
1203 state->in_sql_drop = false;
1204 state->table_rewrite_oid = InvalidOid;
1205
1206 state->commandCollectionInhibited = currentEventTriggerState ?
1208 state->currentCommand = NULL;
1209 state->commandList = NIL;
1210 state->previous = currentEventTriggerState;
1212
1213 return true;
1214}
bool trackDroppedObjectsNeeded(void)
static void slist_init(slist_head *head)
Definition ilist.h:986
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
MemoryContext TopMemoryContext
Definition mcxt.c:166
#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 2028 of file event_trigger.c.

2029{
2031 CollectedCommand *command;
2032
2033 /* ignore if event trigger context not set, or collection disabled */
2036 return;
2037
2039
2042 command->d.defprivs.objtype = stmt->action->objtype;
2044 command->parsetree = (Node *) copyObject(stmt);
2045
2049}
@ SCT_AlterDefaultPrivileges
#define palloc0_object(type)
Definition fe_memutils.h:75
struct CollectedCommand::@134::@141 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 1923 of file event_trigger.c.

1925{
1927 CollectedCommand *command;
1928
1929 /* ignore if event trigger context not set, or collection disabled */
1932 return;
1933
1935
1937 command->type = SCT_AlterOpFamily;
1941 command->d.opfam.operators = operators;
1942 command->d.opfam.procedures = procedures;
1943 command->parsetree = (Node *) copyObject(stmt);
1944
1947
1949}
@ SCT_AlterOpFamily
struct CollectedCommand::@134::@138 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 1806 of file event_trigger.c.

1807{
1810
1811 /* ignore if event trigger context not set, or collection disabled */
1814 return;
1815
1819
1821
1823 newsub->address = address;
1824 newsub->parsetree = copyObject(subcmd);
1825
1828
1830}
#define Assert(condition)
Definition c.h:945
#define OidIsValid(objectId)
Definition c.h:860
#define IsA(nodeptr, _type_)
Definition nodes.h:164
static color newsub(struct colormap *cm, color co)
Definition regc_color.c:389

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 1990 of file event_trigger.c.

1992{
1994 CollectedCommand *command;
1995
1996 /* ignore if event trigger context not set, or collection disabled */
1999 return;
2000
2002
2004 command->type = SCT_AlterTSConfig;
2007 TSConfigRelationId, cfgId);
2008 if (ndicts > 0)
2009 {
2010 command->d.atscfg.dictIds = palloc_array(Oid, ndicts);
2011 memcpy(command->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
2012 }
2013 command->d.atscfg.ndicts = ndicts;
2014 command->parsetree = (Node *) copyObject(stmt);
2015
2018
2020}
@ SCT_AlterTSConfig
#define palloc_array(type, count)
Definition fe_memutils.h:76
struct CollectedCommand::@134::@140 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(), 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 1956 of file event_trigger.c.

1958{
1960 CollectedCommand *command;
1961
1962 /* ignore if event trigger context not set, or collection disabled */
1965 return;
1966
1968
1970 command->type = SCT_CreateOpClass;
1974 command->d.createopc.operators = operators;
1975 command->d.createopc.procedures = procedures;
1976 command->parsetree = (Node *) copyObject(stmt);
1977
1980
1982}
@ SCT_CreateOpClass
struct CollectedCommand::@134::@139 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 1879 of file event_trigger.c.

1880{
1882 CollectedCommand *command;
1884 ListCell *cell;
1885
1886 /* ignore if event trigger context not set, or collection disabled */
1889 return;
1890
1892
1893 /*
1894 * This is tedious, but necessary.
1895 */
1897 memcpy(icopy, istmt, sizeof(InternalGrant));
1898 icopy->objects = list_copy(istmt->objects);
1899 icopy->grantees = list_copy(istmt->grantees);
1900 icopy->col_privs = NIL;
1901 foreach(cell, istmt->col_privs)
1902 icopy->col_privs = lappend(icopy->col_privs, copyObject(lfirst(cell)));
1903
1904 /* Now collect it, using the copied InternalGrant */
1906 command->type = SCT_Grant;
1908 command->d.grant.istmt = icopy;
1909 command->parsetree = NULL;
1910
1913
1915}
@ SCT_Grant
List * list_copy(const List *oldlist)
Definition list.c:1573
InternalGrant * istmt
struct CollectedCommand::@134::@137 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(), 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 1716 of file event_trigger.c.

1719{
1721 CollectedCommand *command;
1722
1723 /* ignore if event trigger context not set, or collection disabled */
1726 return;
1727
1729
1731
1732 command->type = SCT_Simple;
1734
1735 command->d.simple.address = address;
1736 command->d.simple.secondaryObject = secondaryObject;
1737 command->parsetree = copyObject(parsetree);
1738
1740 command);
1741
1743}
@ SCT_Simple
struct CollectedCommand::@134::@135 simple
ObjectAddress secondaryObject

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 777 of file event_trigger.c.

778{
779 List *runlist;
780 EventTriggerData trigdata;
781
782 /*
783 * See EventTriggerDDLCommandStart for a discussion about why event
784 * triggers are disabled in single user mode or via GUC.
785 */
787 return;
788
789 /*
790 * Also do nothing if our state isn't set up, which it won't be if there
791 * weren't any relevant event triggers at the start of the current DDL
792 * command. This test might therefore seem optional, but it's important
793 * because EventTriggerCommonSetup might find triggers that didn't exist
794 * at the time the command started. Although this function itself
795 * wouldn't crash, the event trigger functions would presumably call
796 * pg_event_trigger_ddl_commands which would fail. Better to do nothing
797 * until the next command.
798 */
800 return;
801
803 EVT_DDLCommandEnd, "ddl_command_end",
804 &trigdata, false);
805 if (runlist == NIL)
806 return;
807
808 /*
809 * Make sure anything the main command did will be visible to the event
810 * triggers.
811 */
813
814 /* Run the triggers. */
815 EventTriggerInvoke(runlist, &trigdata);
816
817 /* Cleanup. */
819}
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:120
void list_free(List *list)
Definition list.c:1546
void CommandCounterIncrement(void)
Definition xact.c:1102

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 726 of file event_trigger.c.

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

1229{
1231
1233
1234 /* this avoids the need for retail pfree of SQLDropList items: */
1236
1238}
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472
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 898 of file event_trigger.c.

899{
900 List *runlist;
901 EventTriggerData trigdata;
902
903 /*
904 * See EventTriggerDDLCommandStart for a discussion about why event
905 * triggers are disabled in single user mode or via a GUC. We also need a
906 * database connection (some background workers don't have it).
907 */
910 return;
911
914 EVT_Login, "login",
915 &trigdata, false);
916
917 if (runlist != NIL)
918 {
919 /*
920 * Event trigger execution may require an active snapshot.
921 */
923
924 /* Run the triggers. */
925 EventTriggerInvoke(runlist, &trigdata);
926
927 /* Cleanup. */
929
931 }
932
933 /*
934 * There is no active login event trigger, but our
935 * pg_database.dathasloginevt is set. Try to unset this flag. We use the
936 * lock to prevent concurrent SetDatabaseHasLoginEventTriggers(), but we
937 * don't want to hang the connection waiting on the lock. Thus, we are
938 * just trying to acquire the lock conditionally.
939 */
942 {
943 /*
944 * The lock is held. Now we need to recheck that login event triggers
945 * list is still empty. Once the list is empty, we know that even if
946 * there is a backend which concurrently inserts/enables a login event
947 * trigger, it will update pg_database.dathasloginevt *afterwards*.
948 */
950 EVT_Login, "login",
951 &trigdata, true);
952
953 if (runlist == NIL)
954 {
956 HeapTuple tuple;
957 void *state;
959 ScanKeyData key[1];
960
961 /* Fetch a copy of the tuple to scribble on */
962 ScanKeyInit(&key[0],
966
968 NULL, 1, key, &tuple, &state);
969
970 if (!HeapTupleIsValid(tuple))
971 elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
972
973 db = (Form_pg_database) GETSTRUCT(tuple);
974 if (db->dathasloginevt)
975 {
976 db->dathasloginevt = false;
977
978 /*
979 * Do an "in place" update of the pg_database tuple. Doing
980 * this instead of regular updates serves two purposes. First,
981 * that avoids possible waiting on the row-level lock. Second,
982 * that avoids dealing with TOAST.
983 */
985 }
986 else
989 heap_freetuple(tuple);
990 }
991 else
992 {
994 }
995 }
997}
#define elog(elevel,...)
Definition elog.h:226
@ EVT_Login
Definition evtcache.h:26
void systable_inplace_update_cancel(void *state)
Definition genam.c:903
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:808
void systable_inplace_update_finish(void *state, HeapTuple tuple)
Definition genam.c:884
bool MyDatabaseHasLoginEventTriggers
Definition globals.c:98
Oid MyDatabaseId
Definition globals.c:94
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:3081
void CommitTransactionCommand(void)
Definition xact.c:3179

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(), 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 825 of file event_trigger.c.

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

1279{
1280 SQLDropObject *obj;
1282
1284 return;
1285
1287
1289
1291 obj->address = *object;
1292 obj->original = original;
1293 obj->normal = normal;
1294
1295 if (object->classId == NamespaceRelationId)
1296 {
1297 /* Special handling is needed for temp namespaces */
1298 if (isTempNamespace(object->objectId))
1299 obj->istemp = true;
1300 else if (isAnyTempNamespace(object->objectId))
1301 {
1302 /* don't report temp schemas except my own */
1303 pfree(obj);
1305 return;
1306 }
1307 obj->objname = get_namespace_name(object->objectId);
1308 }
1309 else if (object->classId == AttrDefaultRelationId)
1310 {
1311 /* We treat a column default as temp if its table is temp */
1313
1315 if (OidIsValid(colobject.objectId))
1316 {
1318 {
1319 pfree(obj);
1321 return;
1322 }
1323 }
1324 }
1325 else if (object->classId == TriggerRelationId)
1326 {
1327 /* Similarly, a trigger is temp if its table is temp */
1328 /* Sadly, there's no lsyscache.c support for trigger objects */
1330 ScanKeyData skey[1];
1332 HeapTuple tuple;
1333 Oid relid;
1334
1335 /* Fetch the trigger's table OID the hard way */
1337 ScanKeyInit(&skey[0],
1340 ObjectIdGetDatum(object->objectId));
1342 NULL, 1, skey);
1343 tuple = systable_getnext(sscan);
1344 if (HeapTupleIsValid(tuple))
1345 relid = ((Form_pg_trigger) GETSTRUCT(tuple))->tgrelid;
1346 else
1347 relid = InvalidOid; /* shouldn't happen */
1350 /* Do nothing if we didn't find the trigger */
1351 if (OidIsValid(relid))
1352 {
1354
1356 relobject.objectId = relid;
1357 /* Arbitrarily set objectSubId nonzero so as not to fill objname */
1358 relobject.objectSubId = 1;
1360 {
1361 pfree(obj);
1363 return;
1364 }
1365 }
1366 }
1367 else if (object->classId == PolicyRelationId)
1368 {
1369 /* Similarly, a policy is temp if its table is temp */
1370 /* Sadly, there's no lsyscache.c support for policy objects */
1372 ScanKeyData skey[1];
1374 HeapTuple tuple;
1375 Oid relid;
1376
1377 /* Fetch the policy's table OID the hard way */
1379 ScanKeyInit(&skey[0],
1382 ObjectIdGetDatum(object->objectId));
1384 NULL, 1, skey);
1385 tuple = systable_getnext(sscan);
1386 if (HeapTupleIsValid(tuple))
1387 relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid;
1388 else
1389 relid = InvalidOid; /* shouldn't happen */
1392 /* Do nothing if we didn't find the policy */
1393 if (OidIsValid(relid))
1394 {
1396
1398 relobject.objectId = relid;
1399 /* Arbitrarily set objectSubId nonzero so as not to fill objname */
1400 relobject.objectSubId = 1;
1402 {
1403 pfree(obj);
1405 return;
1406 }
1407 }
1408 }
1409 else
1410 {
1411 /* Generic handling for all other object classes */
1412 if (!obtain_object_name_namespace(object, obj))
1413 {
1414 /* don't report temp objects except my own */
1415 pfree(obj);
1417 return;
1418 }
1419 }
1420
1421 /* object identity, objname and objargs */
1422 obj->objidentity =
1424 false);
1425
1426 /* object type */
1427 obj->objecttype = getObjectTypeDescription(&obj->address, false);
1428
1430
1432}
static bool obtain_object_name_namespace(const ObjectAddress *object, SQLDropObject *obj)
bool EventTriggerSupportsObject(const ObjectAddress *object)
void systable_endscan(SysScanDesc sysscan)
Definition genam.c:603
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition genam.c:514
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:3588
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 1158 of file event_trigger.c.

1159{
1160 switch (object->classId)
1161 {
1162 case DatabaseRelationId:
1164 case AuthIdRelationId:
1165 case AuthMemRelationId:
1167 /* no support for global objects (except subscriptions) */
1168 return false;
1170 /* no support for event triggers on event triggers */
1171 return false;
1172 default:
1173 return true;
1174 }
1175}

References ObjectAddress::classId, and fb().

Referenced by deleteObjectsInList(), and EventTriggerSQLDropAddObject().

◆ EventTriggerSupportsObjectType()

bool EventTriggerSupportsObjectType ( ObjectType  obtype)
extern

Definition at line 1134 of file event_trigger.c.

1135{
1136 switch (obtype)
1137 {
1138 case OBJECT_DATABASE:
1139 case OBJECT_TABLESPACE:
1140 case OBJECT_ROLE:
1142 /* no support for global objects (except subscriptions) */
1143 return false;
1145 /* no support for event triggers on event triggers */
1146 return false;
1147 default:
1148 return true;
1149 }
1150}
@ 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 1004 of file event_trigger.c.

1005{
1006 List *runlist;
1007 EventTriggerData trigdata;
1008
1009 /*
1010 * See EventTriggerDDLCommandStart for a discussion about why event
1011 * triggers are disabled in single user mode or via a GUC.
1012 */
1014 return;
1015
1016 /*
1017 * Also do nothing if our state isn't set up, which it won't be if there
1018 * weren't any relevant event triggers at the start of the current DDL
1019 * command. This test might therefore seem optional, but it's
1020 * *necessary*, because EventTriggerCommonSetup might find triggers that
1021 * didn't exist at the time the command started.
1022 */
1024 return;
1025
1026 runlist = EventTriggerCommonSetup(parsetree,
1028 "table_rewrite",
1029 &trigdata, false);
1030 if (runlist == NIL)
1031 return;
1032
1033 /*
1034 * Make sure pg_event_trigger_table_rewrite_oid only works when running
1035 * these triggers. Use PG_TRY to ensure table_rewrite_oid is reset even
1036 * when one trigger fails. (This is perhaps not necessary, as the
1037 * currentState variable will be removed shortly by our caller, but it
1038 * seems better to play safe.)
1039 */
1042
1043 /* Run the triggers. */
1044 PG_TRY();
1045 {
1046 EventTriggerInvoke(runlist, &trigdata);
1047 }
1048 PG_FINALLY();
1049 {
1052 }
1053 PG_END_TRY();
1054
1055 /* Cleanup. */
1057
1058 /*
1059 * Make sure anything the event triggers did will be visible to the main
1060 * command.
1061 */
1063}
@ 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 1694 of file event_trigger.c.

1695{
1697 return;
1698
1700}

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 580 of file event_trigger.c.

581{
582 Oid oid;
583
585 CStringGetDatum(trigname));
586 if (!OidIsValid(oid) && !missing_ok)
589 errmsg("event trigger \"%s\" does not exist", trigname)));
590 return oid;
591}
#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 1246 of file event_trigger.c.

1247{
1248 /*
1249 * true if any sql_drop, table_rewrite, ddl_command_end event trigger
1250 * exists
1251 */
1252 return (EventCacheLookup(EVT_SQLDrop) != NIL) ||
1255}
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