1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * event_trigger.h |
4 | * Declarations for command trigger handling. |
5 | * |
6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
7 | * Portions Copyright (c) 1994, Regents of the University of California |
8 | * |
9 | * src/include/commands/event_trigger.h |
10 | * |
11 | *------------------------------------------------------------------------- |
12 | */ |
13 | #ifndef EVENT_TRIGGER_H |
14 | #define EVENT_TRIGGER_H |
15 | |
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" |
22 | |
23 | typedef struct EventTriggerData |
24 | { |
25 | NodeTag type; |
26 | const char *event; /* event name */ |
27 | Node *parsetree; /* parse tree */ |
28 | const char *tag; /* command tag */ |
29 | } EventTriggerData; |
30 | |
31 | #define AT_REWRITE_ALTER_PERSISTENCE 0x01 |
32 | #define AT_REWRITE_DEFAULT_VAL 0x02 |
33 | #define AT_REWRITE_COLUMN_REWRITE 0x04 |
34 | |
35 | /* |
36 | * EventTriggerData is the node type that is passed as fmgr "context" info |
37 | * when a function is called by the event trigger manager. |
38 | */ |
39 | #define CALLED_AS_EVENT_TRIGGER(fcinfo) \ |
40 | ((fcinfo)->context != NULL && IsA((fcinfo)->context, EventTriggerData)) |
41 | |
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); |
45 | |
46 | extern Oid AlterEventTrigger(AlterEventTrigStmt *stmt); |
47 | extern ObjectAddress AlterEventTriggerOwner(const char *name, Oid newOwnerId); |
48 | extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId); |
49 | |
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); |
56 | |
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); |
62 | |
63 | extern void EventTriggerInhibitCommandCollection(void); |
64 | extern void EventTriggerUndoInhibitCommandCollection(void); |
65 | |
66 | extern void EventTriggerCollectSimpleCommand(ObjectAddress address, |
67 | ObjectAddress secondaryObject, |
68 | Node *parsetree); |
69 | |
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); |
75 | |
76 | extern void EventTriggerCollectGrant(InternalGrant *istmt); |
77 | extern void EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, |
78 | Oid opfamoid, List *operators, |
79 | List *procedures); |
80 | extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, |
81 | Oid opcoid, List *operators, |
82 | List *procedures); |
83 | extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, |
84 | Oid cfgId, Oid *dictIds, int ndicts); |
85 | extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt); |
86 | |
87 | #endif /* EVENT_TRIGGER_H */ |
88 | |