1 /*-------------------------------------------------------------------------
4 * definition of the system "trigger" relation (pg_trigger)
5 * along with the relation's initial contents.
8 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
9 * Portions Copyright (c) 1994, Regents of the University of California
11 * $PostgreSQL: pgsql/src/include/catalog/pg_trigger.h,v 1.29 2007/11/15 21:14:43 momjian Exp $
14 * the genbki.sh script reads this file and generates .bki
15 * information from the DATA() statements.
17 *-------------------------------------------------------------------------
23 * postgres.h contains the system type definitions and the
24 * CATALOG(), BKI_BOOTSTRAP and DATA() sugar words so this file
25 * can be read by both genbki.sh and the C compiler.
30 * pg_trigger definition. cpp turns this into
31 * typedef struct FormData_pg_trigger
33 * Note: when tgconstraint is nonzero, tgisconstraint must be true, and
34 * tgconstrname, tgconstrrelid, tgdeferrable, tginitdeferred are redundant
35 * with the referenced pg_constraint entry. The reason we keep these fields
36 * is that we support "stand-alone" constraint triggers with no corresponding
37 * pg_constraint entry.
40 #define TriggerRelationId 2620
42 CATALOG(pg_trigger,2620)
44 Oid tgrelid; /* relation trigger is attached to */
45 NameData tgname; /* trigger's name */
46 Oid tgfoid; /* OID of function to be called */
47 int2 tgtype; /* BEFORE/AFTER UPDATE/DELETE/INSERT
48 * ROW/STATEMENT; see below */
49 char tgenabled; /* trigger's firing configuration WRT
50 * session_replication_role */
51 bool tgisconstraint; /* trigger is a constraint trigger */
52 NameData tgconstrname; /* constraint name */
53 Oid tgconstrrelid; /* constraint's FROM table, if any */
54 Oid tgconstraint; /* owning pg_constraint entry, if any */
55 bool tgdeferrable; /* constraint trigger is deferrable */
56 bool tginitdeferred; /* constraint trigger is deferred initially */
57 int2 tgnargs; /* # of extra arguments in tgargs */
59 /* VARIABLE LENGTH FIELDS: */
60 int2vector tgattr; /* reserved for column-specific triggers */
61 bytea tgargs; /* first\000second\000tgnargs\000 */
62 } FormData_pg_trigger;
65 * Form_pg_trigger corresponds to a pointer to a tuple with
66 * the format of pg_trigger relation.
69 typedef FormData_pg_trigger *Form_pg_trigger;
72 * compiler constants for pg_trigger
75 #define Natts_pg_trigger 14
76 #define Anum_pg_trigger_tgrelid 1
77 #define Anum_pg_trigger_tgname 2
78 #define Anum_pg_trigger_tgfoid 3
79 #define Anum_pg_trigger_tgtype 4
80 #define Anum_pg_trigger_tgenabled 5
81 #define Anum_pg_trigger_tgisconstraint 6
82 #define Anum_pg_trigger_tgconstrname 7
83 #define Anum_pg_trigger_tgconstrrelid 8
84 #define Anum_pg_trigger_tgconstraint 9
85 #define Anum_pg_trigger_tgdeferrable 10
86 #define Anum_pg_trigger_tginitdeferred 11
87 #define Anum_pg_trigger_tgnargs 12
88 #define Anum_pg_trigger_tgattr 13
89 #define Anum_pg_trigger_tgargs 14
91 /* Bits within tgtype */
92 #define TRIGGER_TYPE_ROW (1 << 0)
93 #define TRIGGER_TYPE_BEFORE (1 << 1)
94 #define TRIGGER_TYPE_INSERT (1 << 2)
95 #define TRIGGER_TYPE_DELETE (1 << 3)
96 #define TRIGGER_TYPE_UPDATE (1 << 4)
98 /* Macros for manipulating tgtype */
99 #define TRIGGER_CLEAR_TYPE(type) ((type) = 0)
101 #define TRIGGER_SETT_ROW(type) ((type) |= TRIGGER_TYPE_ROW)
102 #define TRIGGER_SETT_BEFORE(type) ((type) |= TRIGGER_TYPE_BEFORE)
103 #define TRIGGER_SETT_INSERT(type) ((type) |= TRIGGER_TYPE_INSERT)
104 #define TRIGGER_SETT_DELETE(type) ((type) |= TRIGGER_TYPE_DELETE)
105 #define TRIGGER_SETT_UPDATE(type) ((type) |= TRIGGER_TYPE_UPDATE)
107 #define TRIGGER_FOR_ROW(type) ((type) & TRIGGER_TYPE_ROW)
108 #define TRIGGER_FOR_BEFORE(type) ((type) & TRIGGER_TYPE_BEFORE)
109 #define TRIGGER_FOR_INSERT(type) ((type) & TRIGGER_TYPE_INSERT)
110 #define TRIGGER_FOR_DELETE(type) ((type) & TRIGGER_TYPE_DELETE)
111 #define TRIGGER_FOR_UPDATE(type) ((type) & TRIGGER_TYPE_UPDATE)
113 #endif /* PG_TRIGGER_H */