OSDN Git Service

pgindent run for 8.3.
[pg-rex/syncrep.git] / src / include / catalog / pg_trigger.h
1 /*-------------------------------------------------------------------------
2  *
3  * pg_trigger.h
4  *        definition of the system "trigger" relation (pg_trigger)
5  *        along with the relation's initial contents.
6  *
7  *
8  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $PostgreSQL: pgsql/src/include/catalog/pg_trigger.h,v 1.29 2007/11/15 21:14:43 momjian Exp $
12  *
13  * NOTES
14  *        the genbki.sh script reads this file and generates .bki
15  *        information from the DATA() statements.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef PG_TRIGGER_H
20 #define PG_TRIGGER_H
21
22 /* ----------------
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.
26  * ----------------
27  */
28
29 /* ----------------
30  *              pg_trigger definition.  cpp turns this into
31  *              typedef struct FormData_pg_trigger
32  *
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.
38  * ----------------
39  */
40 #define TriggerRelationId  2620
41
42 CATALOG(pg_trigger,2620)
43 {
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 */
58
59         /* VARIABLE LENGTH FIELDS: */
60         int2vector      tgattr;                 /* reserved for column-specific triggers */
61         bytea           tgargs;                 /* first\000second\000tgnargs\000 */
62 } FormData_pg_trigger;
63
64 /* ----------------
65  *              Form_pg_trigger corresponds to a pointer to a tuple with
66  *              the format of pg_trigger relation.
67  * ----------------
68  */
69 typedef FormData_pg_trigger *Form_pg_trigger;
70
71 /* ----------------
72  *              compiler constants for pg_trigger
73  * ----------------
74  */
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
90
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)
97
98 /* Macros for manipulating tgtype */
99 #define TRIGGER_CLEAR_TYPE(type)                ((type) = 0)
100
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)
106
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)
112
113 #endif   /* PG_TRIGGER_H */