postgresql/src/include/catalog/pg_trigger.h

97 lines
3.3 KiB
C
Raw Normal View History

1997-08-31 11:55:24 +02:00
/*-------------------------------------------------------------------------
*
* pg_trigger.h
1997-08-31 11:55:24 +02:00
*
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
1997-08-31 11:55:24 +02:00
*
* NOTES
* the genbki.sh script reads this file and generates .bki
* information from the DATA() statements.
1997-08-31 11:55:24 +02:00
*
*-------------------------------------------------------------------------
*/
#ifndef PG_TRIGGER_H
#define PG_TRIGGER_H
/* ----------------
* postgres.h contains the system type definitions and the
* CATALOG(), BOOTSTRAP and DATA() sugar words so this file
* can be read by both genbki.sh and the C compiler.
1997-08-31 11:55:24 +02:00
* ----------------
*/
/* ----------------
* pg_trigger definition. cpp turns this into
* typedef struct FormData_pg_trigger
1997-08-31 11:55:24 +02:00
* ----------------
*/
Clean up various to-do items associated with system indexes: pg_database now has unique indexes on oid and on datname. pg_shadow now has unique indexes on usename and on usesysid. pg_am now has unique index on oid. pg_opclass now has unique index on oid. pg_amproc now has unique index on amid+amopclaid+amprocnum. Remove pg_rewrite's unnecessary index on oid, delete unused RULEOID syscache. Remove index on pg_listener and associated syscache for performance reasons (caching rows that are certain to change before you need 'em again is rather pointless). Change pg_attrdef's nonunique index on adrelid into a unique index on adrelid+adnum. Fix various incorrect settings of pg_class.relisshared, make that the primary reference point for whether a relation is shared or not. IsSharedSystemRelationName() is now only consulted to initialize relisshared during initial creation of tables and indexes. In theory we might now support shared user relations, though it's not clear how one would get entries for them into pg_class &etc of multiple databases. Fix recently reported bug that pg_attribute rows created for an index all have the same OID. (Proof that non-unique OID doesn't matter unless it's actually used to do lookups ;-)) There's no need to treat pg_trigger, pg_attrdef, pg_relcheck as bootstrap relations. Convert them into plain system catalogs without hardwired entries in pg_class and friends. Unify global.bki and template1.bki into a single init script postgres.bki, since the alleged distinction between them was misleading and pointless. Not to mention that it didn't work for setting up indexes on shared system relations. Rationalize locking of pg_shadow, pg_group, pg_attrdef (no need to use AccessExclusiveLock where ExclusiveLock or even RowExclusiveLock will do). Also, hold locks until transaction commit where necessary.
2001-06-12 07:55:50 +02:00
CATALOG(pg_trigger)
{
Oid tgrelid; /* triggered relation */
NameData tgname; /* trigger' name */
Oid tgfoid; /* OID of function to be called */
int2 tgtype; /* BEFORE/AFTER UPDATE/DELETE/INSERT
* ROW/STATEMENT */
bool tgenabled; /* trigger is enabled/disabled */
bool tgisconstraint; /* trigger is a RI constraint */
NameData tgconstrname; /* RI constraint name */
Oid tgconstrrelid; /* RI table of foreign key definition */
/* in the case of ON DELETE or ON UPDATE */
bool tgdeferrable; /* RI trigger is deferrable */
bool tginitdeferred; /* RI trigger is deferred initially */
int2 tgnargs; /* # of extra arguments in tgargs */
int2vector tgattr; /* UPDATE of attr1, attr2 ... (NI) */
bytea tgargs; /* first\000second\000tgnargs\000 */
1997-08-31 11:55:24 +02:00
} FormData_pg_trigger;
/* ----------------
* Form_pg_trigger corresponds to a pointer to a tuple with
* the format of pg_trigger relation.
1997-08-31 11:55:24 +02:00
* ----------------
*/
typedef FormData_pg_trigger *Form_pg_trigger;
1997-08-31 11:55:24 +02:00
/* ----------------
* compiler constants for pg_trigger
1997-08-31 11:55:24 +02:00
* ----------------
*/
#define Natts_pg_trigger 13
#define Anum_pg_trigger_tgrelid 1
#define Anum_pg_trigger_tgname 2
#define Anum_pg_trigger_tgfoid 3
#define Anum_pg_trigger_tgtype 4
#define Anum_pg_trigger_tgenabled 5
#define Anum_pg_trigger_tgisconstraint 6
#define Anum_pg_trigger_tgconstrname 7
#define Anum_pg_trigger_tgconstrrelid 8
#define Anum_pg_trigger_tgdeferrable 9
#define Anum_pg_trigger_tginitdeferred 10
#define Anum_pg_trigger_tgnargs 11
#define Anum_pg_trigger_tgattr 12
#define Anum_pg_trigger_tgargs 13
1997-08-31 11:55:24 +02:00
#define TRIGGER_TYPE_ROW (1 << 0)
#define TRIGGER_TYPE_BEFORE (1 << 1)
#define TRIGGER_TYPE_INSERT (1 << 2)
#define TRIGGER_TYPE_DELETE (1 << 3)
#define TRIGGER_TYPE_UPDATE (1 << 4)
1997-08-31 11:55:24 +02:00
#define TRIGGER_CLEAR_TYPE(type) (type = 0)
1997-08-31 11:55:24 +02:00
#define TRIGGER_SETT_ROW(type) (type |= TRIGGER_TYPE_ROW)
#define TRIGGER_SETT_BEFORE(type) (type |= TRIGGER_TYPE_BEFORE)
#define TRIGGER_SETT_INSERT(type) (type |= TRIGGER_TYPE_INSERT)
#define TRIGGER_SETT_DELETE(type) (type |= TRIGGER_TYPE_DELETE)
#define TRIGGER_SETT_UPDATE(type) (type |= TRIGGER_TYPE_UPDATE)
1997-08-31 11:55:24 +02:00
#define TRIGGER_FOR_ROW(type) (type & TRIGGER_TYPE_ROW)
#define TRIGGER_FOR_BEFORE(type) (type & TRIGGER_TYPE_BEFORE)
#define TRIGGER_FOR_INSERT(type) (type & TRIGGER_TYPE_INSERT)
#define TRIGGER_FOR_DELETE(type) (type & TRIGGER_TYPE_DELETE)
#define TRIGGER_FOR_UPDATE(type) (type & TRIGGER_TYPE_UPDATE)
#endif /* PG_TRIGGER_H */