1 /*-------------------------------------------------------------------------
4 * Declarations for command trigger handling.
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/commands/event_trigger.h
11 *-------------------------------------------------------------------------
13 #ifndef EVENT_TRIGGER_H
14 #define EVENT_TRIGGER_H
16 #include "catalog/dependency.h"
17 #include "catalog/objectaddress.h"
18 #include "catalog/pg_event_trigger.h"
19 #include "nodes/parsenodes.h"
20 #include "utils/aclchk_internal.h"
21 #include "tcop/deparse_utility.h"
23 typedef struct EventTriggerData
26 const char *event
; /* event name */
27 Node
*parsetree
; /* parse tree */
28 const char *tag
; /* command tag */
31 #define AT_REWRITE_ALTER_PERSISTENCE 0x01
32 #define AT_REWRITE_DEFAULT_VAL 0x02
33 #define AT_REWRITE_COLUMN_REWRITE 0x04
36 * EventTriggerData is the node type that is passed as fmgr "context" info
37 * when a function is called by the event trigger manager.
39 #define CALLED_AS_EVENT_TRIGGER(fcinfo) \
40 ((fcinfo)->context != NULL && IsA((fcinfo)->context, EventTriggerData))
42 extern Oid
CreateEventTrigger(CreateEventTrigStmt
*stmt
);
43 extern void RemoveEventTriggerById(Oid trigOid
);
44 extern Oid
get_event_trigger_oid(const char *trigname
, bool missing_ok
);
46 extern Oid
AlterEventTrigger(AlterEventTrigStmt
*stmt
);
47 extern ObjectAddress
AlterEventTriggerOwner(const char *name
, Oid newOwnerId
);
48 extern void AlterEventTriggerOwner_oid(Oid
, Oid newOwnerId
);
50 extern bool EventTriggerSupportsObjectType(ObjectType obtype
);
51 extern bool EventTriggerSupportsObjectClass(ObjectClass objclass
);
52 extern void EventTriggerDDLCommandStart(Node
*parsetree
);
53 extern void EventTriggerDDLCommandEnd(Node
*parsetree
);
54 extern void EventTriggerSQLDrop(Node
*parsetree
);
55 extern void EventTriggerTableRewrite(Node
*parsetree
, Oid tableOid
, int reason
);
57 extern bool EventTriggerBeginCompleteQuery(void);
58 extern void EventTriggerEndCompleteQuery(void);
59 extern bool trackDroppedObjectsNeeded(void);
60 extern void EventTriggerSQLDropAddObject(const ObjectAddress
*object
,
61 bool original
, bool normal
);
63 extern void EventTriggerInhibitCommandCollection(void);
64 extern void EventTriggerUndoInhibitCommandCollection(void);
66 extern void EventTriggerCollectSimpleCommand(ObjectAddress address
,
67 ObjectAddress secondaryObject
,
70 extern void EventTriggerAlterTableStart(Node
*parsetree
);
71 extern void EventTriggerAlterTableRelid(Oid objectId
);
72 extern void EventTriggerCollectAlterTableSubcmd(Node
*subcmd
,
73 ObjectAddress address
);
74 extern void EventTriggerAlterTableEnd(void);
76 extern void EventTriggerCollectGrant(InternalGrant
*istmt
);
77 extern void EventTriggerCollectAlterOpFam(AlterOpFamilyStmt
*stmt
,
78 Oid opfamoid
, List
*operators
,
80 extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt
*stmt
,
81 Oid opcoid
, List
*operators
,
83 extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt
*stmt
,
84 Oid cfgId
, Oid
*dictIds
, int ndicts
);
85 extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt
*stmt
);
87 #endif /* EVENT_TRIGGER_H */