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
23typedef 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
42extern Oid CreateEventTrigger(CreateEventTrigStmt *stmt);
43extern void RemoveEventTriggerById(Oid trigOid);
44extern Oid get_event_trigger_oid(const char *trigname, bool missing_ok);
45
46extern Oid AlterEventTrigger(AlterEventTrigStmt *stmt);
47extern ObjectAddress AlterEventTriggerOwner(const char *name, Oid newOwnerId);
48extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId);
49
50extern bool EventTriggerSupportsObjectType(ObjectType obtype);
51extern bool EventTriggerSupportsObjectClass(ObjectClass objclass);
52extern void EventTriggerDDLCommandStart(Node *parsetree);
53extern void EventTriggerDDLCommandEnd(Node *parsetree);
54extern void EventTriggerSQLDrop(Node *parsetree);
55extern void EventTriggerTableRewrite(Node *parsetree, Oid tableOid, int reason);
56
57extern bool EventTriggerBeginCompleteQuery(void);
58extern void EventTriggerEndCompleteQuery(void);
59extern bool trackDroppedObjectsNeeded(void);
60extern void EventTriggerSQLDropAddObject(const ObjectAddress *object,
61 bool original, bool normal);
62
63extern void EventTriggerInhibitCommandCollection(void);
64extern void EventTriggerUndoInhibitCommandCollection(void);
65
66extern void EventTriggerCollectSimpleCommand(ObjectAddress address,
67 ObjectAddress secondaryObject,
68 Node *parsetree);
69
70extern void EventTriggerAlterTableStart(Node *parsetree);
71extern void EventTriggerAlterTableRelid(Oid objectId);
72extern void EventTriggerCollectAlterTableSubcmd(Node *subcmd,
73 ObjectAddress address);
74extern void EventTriggerAlterTableEnd(void);
75
76extern void EventTriggerCollectGrant(InternalGrant *istmt);
77extern void EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt,
78 Oid opfamoid, List *operators,
79 List *procedures);
80extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt,
81 Oid opcoid, List *operators,
82 List *procedures);
83extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt,
84 Oid cfgId, Oid *dictIds, int ndicts);
85extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt);
86
87#endif /* EVENT_TRIGGER_H */
88