diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/catalog/indexing.h | 5 | ||||
-rw-r--r-- | src/include/catalog/pg_constraint.h | 34 | ||||
-rw-r--r-- | src/include/catalog/pg_trigger.h | 43 | ||||
-rw-r--r-- | src/include/commands/trigger.h | 36 | ||||
-rw-r--r-- | src/include/utils/lsyscache.h | 3 | ||||
-rw-r--r-- | src/include/utils/rel.h | 3 | ||||
-rw-r--r-- | src/include/utils/syscache.h | 75 |
8 files changed, 106 insertions, 97 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 5bdda05960e..aec8dee45cc 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.383 2007/02/09 03:35:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.384 2007/02/14 01:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200702081 +#define CATALOG_VERSION_NO 200702131 #endif diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 73e2cf0cc7d..baa650a8edb 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.97 2007/01/05 22:19:52 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.98 2007/02/14 01:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -214,9 +214,6 @@ DECLARE_UNIQUE_INDEX(pg_tablespace_spcname_index, 2698, on pg_tablespace using b /* This following index is not used for a cache and is not unique */ DECLARE_INDEX(pg_trigger_tgconstrname_index, 2699, on pg_trigger using btree(tgconstrname name_ops)); #define TriggerConstrNameIndexId 2699 -/* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_trigger_tgconstrrelid_index, 2700, on pg_trigger using btree(tgconstrrelid oid_ops)); -#define TriggerConstrRelidIndexId 2700 DECLARE_UNIQUE_INDEX(pg_trigger_tgrelid_tgname_index, 2701, on pg_trigger using btree(tgrelid oid_ops, tgname name_ops)); #define TriggerRelidNameIndexId 2701 DECLARE_UNIQUE_INDEX(pg_trigger_oid_index, 2702, on pg_trigger using btree(oid oid_ops)); diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h index 6fbfb6a0cda..d01c22c703c 100644 --- a/src/include/catalog/pg_constraint.h +++ b/src/include/catalog/pg_constraint.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.24 2007/01/05 22:19:52 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.25 2007/02/14 01:58:58 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -92,6 +92,24 @@ CATALOG(pg_constraint,2606) int2 confkey[1]; /* + * If a foreign key, the OIDs of the PK = FK equality operators for each + * column of the constraint + */ + Oid conpfeqop[1]; + + /* + * If a foreign key, the OIDs of the PK = PK equality operators for each + * column of the constraint (i.e., equality for the referenced columns) + */ + Oid conppeqop[1]; + + /* + * If a foreign key, the OIDs of the FK = FK equality operators for each + * column of the constraint (i.e., equality for the referencing columns) + */ + Oid conffeqop[1]; + + /* * If a check constraint, nodeToString representation of expression */ text conbin; @@ -113,7 +131,7 @@ typedef FormData_pg_constraint *Form_pg_constraint; * compiler constants for pg_constraint * ---------------- */ -#define Natts_pg_constraint 15 +#define Natts_pg_constraint 18 #define Anum_pg_constraint_conname 1 #define Anum_pg_constraint_connamespace 2 #define Anum_pg_constraint_contype 3 @@ -127,8 +145,11 @@ typedef FormData_pg_constraint *Form_pg_constraint; #define Anum_pg_constraint_confmatchtype 11 #define Anum_pg_constraint_conkey 12 #define Anum_pg_constraint_confkey 13 -#define Anum_pg_constraint_conbin 14 -#define Anum_pg_constraint_consrc 15 +#define Anum_pg_constraint_conpfeqop 14 +#define Anum_pg_constraint_conppeqop 15 +#define Anum_pg_constraint_conffeqop 16 +#define Anum_pg_constraint_conbin 17 +#define Anum_pg_constraint_consrc 18 /* Valid values for contype */ @@ -167,6 +188,9 @@ extern Oid CreateConstraintEntry(const char *constraintName, Oid domainId, Oid foreignRelId, const int16 *foreignKey, + const Oid *pfEqOp, + const Oid *ppEqOp, + const Oid *ffEqOp, int foreignNKeys, char foreignUpdateType, char foreignDeleteType, @@ -184,8 +208,6 @@ extern char *ChooseConstraintName(const char *name1, const char *name2, const char *label, Oid namespace, List *others); -extern char *GetConstraintNameForTrigger(Oid triggerId); - extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, Oid newNspId, bool isType); diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h index b5408253b34..df22089e310 100644 --- a/src/include/catalog/pg_trigger.h +++ b/src/include/catalog/pg_trigger.h @@ -1,11 +1,14 @@ /*------------------------------------------------------------------------- * * pg_trigger.h + * definition of the system "trigger" relation (pg_trigger) + * along with the relation's initial contents. * * * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California - * $PostgreSQL: pgsql/src/include/catalog/pg_trigger.h,v 1.26 2007/01/05 22:19:53 momjian Exp $ + * + * $PostgreSQL: pgsql/src/include/catalog/pg_trigger.h,v 1.27 2007/02/14 01:58:58 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -26,23 +29,30 @@ /* ---------------- * pg_trigger definition. cpp turns this into * typedef struct FormData_pg_trigger + * + * Note: when tgconstraint is nonzero, tgisconstraint must be true, and + * tgconstrname, tgconstrrelid, tgdeferrable, tginitdeferred are redundant + * with the referenced pg_constraint entry. The reason we keep these fields + * is that we support "stand-alone" constraint triggers with no corresponding + * pg_constraint entry. * ---------------- */ #define TriggerRelationId 2620 CATALOG(pg_trigger,2620) { - Oid tgrelid; /* triggered relation */ - NameData tgname; /* trigger' name */ + Oid tgrelid; /* relation trigger is attached to */ + NameData tgname; /* trigger's name */ Oid tgfoid; /* OID of function to be called */ int2 tgtype; /* BEFORE/AFTER UPDATE/DELETE/INSERT - * ROW/STATEMENT */ + * ROW/STATEMENT; see below */ 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 */ - bool tgdeferrable; /* RI trigger is deferrable */ - bool tginitdeferred; /* RI trigger is deferred initially */ + bool tgisconstraint; /* trigger is a constraint trigger */ + NameData tgconstrname; /* constraint name */ + Oid tgconstrrelid; /* constraint's FROM table, if any */ + Oid tgconstraint; /* owning pg_constraint entry, if any */ + bool tgdeferrable; /* constraint trigger is deferrable */ + bool tginitdeferred; /* constraint trigger is deferred initially */ int2 tgnargs; /* # of extra arguments in tgargs */ /* VARIABLE LENGTH FIELDS: */ @@ -61,7 +71,7 @@ typedef FormData_pg_trigger *Form_pg_trigger; * compiler constants for pg_trigger * ---------------- */ -#define Natts_pg_trigger 13 +#define Natts_pg_trigger 14 #define Anum_pg_trigger_tgrelid 1 #define Anum_pg_trigger_tgname 2 #define Anum_pg_trigger_tgfoid 3 @@ -70,18 +80,21 @@ typedef FormData_pg_trigger *Form_pg_trigger; #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 +#define Anum_pg_trigger_tgconstraint 9 +#define Anum_pg_trigger_tgdeferrable 10 +#define Anum_pg_trigger_tginitdeferred 11 +#define Anum_pg_trigger_tgnargs 12 +#define Anum_pg_trigger_tgattr 13 +#define Anum_pg_trigger_tgargs 14 +/* Bits within tgtype */ #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) +/* Macros for manipulating tgtype */ #define TRIGGER_CLEAR_TYPE(type) ((type) = 0) #define TRIGGER_SETT_ROW(type) ((type) |= TRIGGER_TYPE_ROW) diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index 284815b47f7..ac9eb7296d1 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.60 2007/01/05 22:19:54 momjian Exp $ + * $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.61 2007/02/14 01:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -78,34 +78,8 @@ typedef struct TriggerData #define TRIGGER_FIRED_AFTER(event) \ (!TRIGGER_FIRED_BEFORE (event)) -/* - * RI trigger function arguments are stored in pg_trigger.tgargs bytea - * - * constrname\0fkrel\0pkrel\0matchtype\0fkatt\0pkatt\0fkatt\0pkatt\0... - * - * There are one or more pairs of fkatt/pkatt names. - * - * The relation names are no longer of much use since they are not - * guaranteed unique; they are present only for backwards compatibility. - * Use the tgrelid and tgconstrrelid fields to identify the referenced - * relations, instead. (But note that which is which will depend on which - * trigger you are looking at!) - */ -#define RI_CONSTRAINT_NAME_ARGNO 0 -#define RI_FK_RELNAME_ARGNO 1 -#define RI_PK_RELNAME_ARGNO 2 -#define RI_MATCH_TYPE_ARGNO 3 -#define RI_FIRST_ATTNAME_ARGNO 4 /* first attname pair starts - * here */ - -#define RI_KEYPAIR_FK_IDX 0 -#define RI_KEYPAIR_PK_IDX 1 - -#define RI_MAX_NUMKEYS INDEX_MAX_KEYS -#define RI_MAX_ARGUMENTS (RI_FIRST_ATTNAME_ARGNO + (RI_MAX_NUMKEYS * 2)) - -extern Oid CreateTrigger(CreateTrigStmt *stmt, bool forConstraint); +extern Oid CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid); extern void DropTrigger(Oid relid, const char *trigname, DropBehavior behavior, bool missing_ok); @@ -175,10 +149,10 @@ extern bool RI_FKey_keyequal_upd_pk(Trigger *trigger, Relation pk_rel, HeapTuple old_row, HeapTuple new_row); extern bool RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel, HeapTuple old_row, HeapTuple new_row); -extern bool RI_Initial_Check(FkConstraint *fkconstraint, - Relation rel, - Relation pkrel); +extern bool RI_Initial_Check(Trigger *trigger, + Relation fk_rel, Relation pk_rel); +/* result values for RI_FKey_trigger_type: */ #define RI_TRIGGER_PK 1 /* is a trigger on the PK relation */ #define RI_TRIGGER_FK 2 /* is a trigger on the FK relation */ #define RI_TRIGGER_NONE 0 /* is not an RI trigger function */ diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 8e9bfaa1edc..78c45891fa4 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.116 2007/01/30 01:33:36 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.117 2007/02/14 01:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -58,6 +58,7 @@ extern Oid get_atttype(Oid relid, AttrNumber attnum); extern int32 get_atttypmod(Oid relid, AttrNumber attnum); extern void get_atttypetypmod(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod); +extern char *get_constraint_name(Oid conoid); extern Oid get_opclass_family(Oid opclass); extern Oid get_opclass_input_type(Oid opclass); extern RegProcedure get_opcode(Oid opno); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 8ce7e118a4f..3ac44b11cdc 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.96 2007/01/25 02:17:26 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.97 2007/02/14 01:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -56,6 +56,7 @@ typedef struct Trigger bool tgenabled; bool tgisconstraint; Oid tgconstrrelid; + Oid tgconstraint; bool tgdeferrable; bool tginitdeferred; int16 tgnargs; diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index b8e55e57efa..c6967251ce1 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/syscache.h,v 1.67 2007/01/05 22:19:59 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/syscache.h,v 1.68 2007/02/14 01:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -28,42 +28,43 @@ * Keep them in alphabetical order. */ -#define AGGFNOID 0 -#define AMNAME 1 -#define AMOID 2 -#define AMOPOPID 3 -#define AMOPSTRATEGY 4 -#define AMPROCNUM 5 -#define ATTNAME 6 -#define ATTNUM 7 -#define AUTHMEMMEMROLE 8 -#define AUTHMEMROLEMEM 9 -#define AUTHNAME 10 -#define AUTHOID 11 -#define CASTSOURCETARGET 12 -#define CLAAMNAMENSP 13 -#define CLAOID 14 -#define CONDEFAULT 15 -#define CONNAMENSP 16 -#define CONOID 17 -#define DATABASEOID 18 -#define INDEXRELID 19 -#define LANGNAME 20 -#define LANGOID 21 -#define NAMESPACENAME 22 -#define NAMESPACEOID 23 -#define OPERNAMENSP 24 -#define OPEROID 25 -#define OPFAMILYAMNAMENSP 26 -#define OPFAMILYOID 27 -#define PROCNAMEARGSNSP 28 -#define PROCOID 29 -#define RELNAMENSP 30 -#define RELOID 31 -#define RULERELNAME 32 -#define STATRELATT 33 -#define TYPENAMENSP 34 -#define TYPEOID 35 +#define AGGFNOID 0 +#define AMNAME 1 +#define AMOID 2 +#define AMOPOPID 3 +#define AMOPSTRATEGY 4 +#define AMPROCNUM 5 +#define ATTNAME 6 +#define ATTNUM 7 +#define AUTHMEMMEMROLE 8 +#define AUTHMEMROLEMEM 9 +#define AUTHNAME 10 +#define AUTHOID 11 +#define CASTSOURCETARGET 12 +#define CLAAMNAMENSP 13 +#define CLAOID 14 +#define CONDEFAULT 15 +#define CONNAMENSP 16 +#define CONSTROID 17 +#define CONVOID 18 +#define DATABASEOID 19 +#define INDEXRELID 20 +#define LANGNAME 21 +#define LANGOID 22 +#define NAMESPACENAME 23 +#define NAMESPACEOID 24 +#define OPERNAMENSP 25 +#define OPEROID 26 +#define OPFAMILYAMNAMENSP 27 +#define OPFAMILYOID 28 +#define PROCNAMEARGSNSP 29 +#define PROCOID 30 +#define RELNAMENSP 31 +#define RELOID 32 +#define RULERELNAME 33 +#define STATRELATT 34 +#define TYPENAMENSP 35 +#define TYPEOID 36 extern void InitCatalogCache(void); extern void InitCatalogCachePhase2(void); |