1/*-------------------------------------------------------------------------
2 *
3 * pg_trigger_d.h
4 * Macro definitions for pg_trigger
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * NOTES
10 * ******************************
11 * *** DO NOT EDIT THIS FILE! ***
12 * ******************************
13 *
14 * It has been GENERATED by src/backend/catalog/genbki.pl
15 *
16 *-------------------------------------------------------------------------
17 */
18#ifndef PG_TRIGGER_D_H
19#define PG_TRIGGER_D_H
20
21#define TriggerRelationId 2620
22
23#define Anum_pg_trigger_oid 1
24#define Anum_pg_trigger_tgrelid 2
25#define Anum_pg_trigger_tgname 3
26#define Anum_pg_trigger_tgfoid 4
27#define Anum_pg_trigger_tgtype 5
28#define Anum_pg_trigger_tgenabled 6
29#define Anum_pg_trigger_tgisinternal 7
30#define Anum_pg_trigger_tgconstrrelid 8
31#define Anum_pg_trigger_tgconstrindid 9
32#define Anum_pg_trigger_tgconstraint 10
33#define Anum_pg_trigger_tgdeferrable 11
34#define Anum_pg_trigger_tginitdeferred 12
35#define Anum_pg_trigger_tgnargs 13
36#define Anum_pg_trigger_tgattr 14
37#define Anum_pg_trigger_tgargs 15
38#define Anum_pg_trigger_tgqual 16
39#define Anum_pg_trigger_tgoldtable 17
40#define Anum_pg_trigger_tgnewtable 18
41
42#define Natts_pg_trigger 18
43
44
45/* Bits within tgtype */
46#define TRIGGER_TYPE_ROW (1 << 0)
47#define TRIGGER_TYPE_BEFORE (1 << 1)
48#define TRIGGER_TYPE_INSERT (1 << 2)
49#define TRIGGER_TYPE_DELETE (1 << 3)
50#define TRIGGER_TYPE_UPDATE (1 << 4)
51#define TRIGGER_TYPE_TRUNCATE (1 << 5)
52#define TRIGGER_TYPE_INSTEAD (1 << 6)
53
54#define TRIGGER_TYPE_LEVEL_MASK (TRIGGER_TYPE_ROW)
55#define TRIGGER_TYPE_STATEMENT 0
56
57/* Note bits within TRIGGER_TYPE_TIMING_MASK aren't adjacent */
58#define TRIGGER_TYPE_TIMING_MASK \
59 (TRIGGER_TYPE_BEFORE | TRIGGER_TYPE_INSTEAD)
60#define TRIGGER_TYPE_AFTER 0
61
62#define TRIGGER_TYPE_EVENT_MASK \
63 (TRIGGER_TYPE_INSERT | TRIGGER_TYPE_DELETE | TRIGGER_TYPE_UPDATE | TRIGGER_TYPE_TRUNCATE)
64
65/* Macros for manipulating tgtype */
66#define TRIGGER_CLEAR_TYPE(type) ((type) = 0)
67
68#define TRIGGER_SETT_ROW(type) ((type) |= TRIGGER_TYPE_ROW)
69#define TRIGGER_SETT_STATEMENT(type) ((type) |= TRIGGER_TYPE_STATEMENT)
70#define TRIGGER_SETT_BEFORE(type) ((type) |= TRIGGER_TYPE_BEFORE)
71#define TRIGGER_SETT_AFTER(type) ((type) |= TRIGGER_TYPE_AFTER)
72#define TRIGGER_SETT_INSTEAD(type) ((type) |= TRIGGER_TYPE_INSTEAD)
73#define TRIGGER_SETT_INSERT(type) ((type) |= TRIGGER_TYPE_INSERT)
74#define TRIGGER_SETT_DELETE(type) ((type) |= TRIGGER_TYPE_DELETE)
75#define TRIGGER_SETT_UPDATE(type) ((type) |= TRIGGER_TYPE_UPDATE)
76#define TRIGGER_SETT_TRUNCATE(type) ((type) |= TRIGGER_TYPE_TRUNCATE)
77
78#define TRIGGER_FOR_ROW(type) ((type) & TRIGGER_TYPE_ROW)
79#define TRIGGER_FOR_BEFORE(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_BEFORE)
80#define TRIGGER_FOR_AFTER(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_AFTER)
81#define TRIGGER_FOR_INSTEAD(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_INSTEAD)
82#define TRIGGER_FOR_INSERT(type) ((type) & TRIGGER_TYPE_INSERT)
83#define TRIGGER_FOR_DELETE(type) ((type) & TRIGGER_TYPE_DELETE)
84#define TRIGGER_FOR_UPDATE(type) ((type) & TRIGGER_TYPE_UPDATE)
85#define TRIGGER_FOR_TRUNCATE(type) ((type) & TRIGGER_TYPE_TRUNCATE)
86
87/*
88 * Efficient macro for checking if tgtype matches a particular level
89 * (TRIGGER_TYPE_ROW or TRIGGER_TYPE_STATEMENT), timing (TRIGGER_TYPE_BEFORE,
90 * TRIGGER_TYPE_AFTER or TRIGGER_TYPE_INSTEAD), and event (TRIGGER_TYPE_INSERT,
91 * TRIGGER_TYPE_DELETE, TRIGGER_TYPE_UPDATE, or TRIGGER_TYPE_TRUNCATE). Note
92 * that a tgtype can match more than one event, but only one level or timing.
93 */
94#define TRIGGER_TYPE_MATCHES(type, level, timing, event) \
95 (((type) & (TRIGGER_TYPE_LEVEL_MASK | TRIGGER_TYPE_TIMING_MASK | (event))) == ((level) | (timing) | (event)))
96
97/*
98 * Macro to determine whether tgnewtable or tgoldtable has been specified for
99 * a trigger.
100 */
101#define TRIGGER_USES_TRANSITION_TABLE(namepointer) \
102 ((namepointer) != (char *) NULL)
103
104
105#endif /* PG_TRIGGER_D_H */
106