~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/include/catalog/pg_trigger.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2009, PostgreSQL Global Development Group
 
9
 * Portions Copyright (c) 1994, Regents of the University of California
 
10
 *
 
11
 * $PostgreSQL$
 
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
#include "catalog/genbki.h"
 
23
 
 
24
/* ----------------
 
25
 *              pg_trigger definition.  cpp turns this into
 
26
 *              typedef struct FormData_pg_trigger
 
27
 *
 
28
 * Note: when tgconstraint is nonzero, tgisconstraint must be true, and
 
29
 * tgconstrname, tgconstrrelid, tgdeferrable, tginitdeferred are redundant
 
30
 * with the referenced pg_constraint entry.  The reason we keep these fields
 
31
 * is that we support "stand-alone" constraint triggers with no corresponding
 
32
 * pg_constraint entry.
 
33
 * ----------------
 
34
 */
 
35
#define TriggerRelationId  2620
 
36
 
 
37
CATALOG(pg_trigger,2620)
 
38
{
 
39
        Oid                     tgrelid;                /* relation trigger is attached to */
 
40
        NameData        tgname;                 /* trigger's name */
 
41
        Oid                     tgfoid;                 /* OID of function to be called */
 
42
        int2            tgtype;                 /* BEFORE/AFTER UPDATE/DELETE/INSERT
 
43
                                                                 * ROW/STATEMENT; see below */
 
44
        char            tgenabled;              /* trigger's firing configuration WRT
 
45
                                                                 * session_replication_role */
 
46
        bool            tgisconstraint; /* trigger is a constraint trigger */
 
47
        NameData        tgconstrname;   /* constraint name */
 
48
        Oid                     tgconstrrelid;  /* constraint's FROM table, if any */
 
49
        Oid                     tgconstraint;   /* owning pg_constraint entry, if any */
 
50
        bool            tgdeferrable;   /* constraint trigger is deferrable */
 
51
        bool            tginitdeferred; /* constraint trigger is deferred initially */
 
52
        int2            tgnargs;                /* # of extra arguments in tgargs */
 
53
 
 
54
        /* VARIABLE LENGTH FIELDS: */
 
55
        int2vector      tgattr;                 /* reserved for column-specific triggers */
 
56
        bytea           tgargs;                 /* first\000second\000tgnargs\000 */
 
57
} FormData_pg_trigger;
 
58
 
 
59
/* ----------------
 
60
 *              Form_pg_trigger corresponds to a pointer to a tuple with
 
61
 *              the format of pg_trigger relation.
 
62
 * ----------------
 
63
 */
 
64
typedef FormData_pg_trigger *Form_pg_trigger;
 
65
 
 
66
/* ----------------
 
67
 *              compiler constants for pg_trigger
 
68
 * ----------------
 
69
 */
 
70
#define Natts_pg_trigger                                14
 
71
#define Anum_pg_trigger_tgrelid                 1
 
72
#define Anum_pg_trigger_tgname                  2
 
73
#define Anum_pg_trigger_tgfoid                  3
 
74
#define Anum_pg_trigger_tgtype                  4
 
75
#define Anum_pg_trigger_tgenabled               5
 
76
#define Anum_pg_trigger_tgisconstraint  6
 
77
#define Anum_pg_trigger_tgconstrname    7
 
78
#define Anum_pg_trigger_tgconstrrelid   8
 
79
#define Anum_pg_trigger_tgconstraint    9
 
80
#define Anum_pg_trigger_tgdeferrable    10
 
81
#define Anum_pg_trigger_tginitdeferred  11
 
82
#define Anum_pg_trigger_tgnargs                 12
 
83
#define Anum_pg_trigger_tgattr                  13
 
84
#define Anum_pg_trigger_tgargs                  14
 
85
 
 
86
/* Bits within tgtype */
 
87
#define TRIGGER_TYPE_ROW                                (1 << 0)
 
88
#define TRIGGER_TYPE_BEFORE                             (1 << 1)
 
89
#define TRIGGER_TYPE_INSERT                             (1 << 2)
 
90
#define TRIGGER_TYPE_DELETE                             (1 << 3)
 
91
#define TRIGGER_TYPE_UPDATE                             (1 << 4)
 
92
#define TRIGGER_TYPE_TRUNCATE                   (1 << 5)
 
93
 
 
94
/* Macros for manipulating tgtype */
 
95
#define TRIGGER_CLEAR_TYPE(type)                ((type) = 0)
 
96
 
 
97
#define TRIGGER_SETT_ROW(type)                  ((type) |= TRIGGER_TYPE_ROW)
 
98
#define TRIGGER_SETT_BEFORE(type)               ((type) |= TRIGGER_TYPE_BEFORE)
 
99
#define TRIGGER_SETT_INSERT(type)               ((type) |= TRIGGER_TYPE_INSERT)
 
100
#define TRIGGER_SETT_DELETE(type)               ((type) |= TRIGGER_TYPE_DELETE)
 
101
#define TRIGGER_SETT_UPDATE(type)               ((type) |= TRIGGER_TYPE_UPDATE)
 
102
#define TRIGGER_SETT_TRUNCATE(type)             ((type) |= TRIGGER_TYPE_TRUNCATE)
 
103
 
 
104
#define TRIGGER_FOR_ROW(type)                   ((type) & TRIGGER_TYPE_ROW)
 
105
#define TRIGGER_FOR_BEFORE(type)                ((type) & TRIGGER_TYPE_BEFORE)
 
106
#define TRIGGER_FOR_INSERT(type)                ((type) & TRIGGER_TYPE_INSERT)
 
107
#define TRIGGER_FOR_DELETE(type)                ((type) & TRIGGER_TYPE_DELETE)
 
108
#define TRIGGER_FOR_UPDATE(type)                ((type) & TRIGGER_TYPE_UPDATE)
 
109
#define TRIGGER_FOR_TRUNCATE(type)              ((type) & TRIGGER_TYPE_TRUNCATE)
 
110
 
 
111
#endif   /* PG_TRIGGER_H */