summaryrefslogtreecommitdiff
path: root/src/include/nodes/parsenodes.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-07-12 18:43:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-07-12 18:43:19 +0000
commit7c6df91dda27accab3097390ef0d21d93028c7a1 (patch)
tree5705b975e8de4edf82252e6df28e0bd57c83cb95 /src/include/nodes/parsenodes.h
parent791a40f943e2a9353c5823fb4f2bd446ec623d38 (diff)
downloadpostgresql-7c6df91dda27accab3097390ef0d21d93028c7a1.tar.gz
Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY constraints all have real live entries in pg_constraint. pg_depend exists, and RESTRICT/CASCADE options work on most kinds of DROP; however, pg_depend is not yet very well populated with dependencies. (Most of the ones that are present at this point just replace formerly hardwired associations, such as the implicit drop of a relation's pg_type entry when the relation is dropped.) Need to add more logic to create dependency entries, improve pg_dump to dump constraints in place of indexes and triggers, and add some regression tests.
Diffstat (limited to 'src/include/nodes/parsenodes.h')
-rw-r--r--src/include/nodes/parsenodes.h41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 19693d57b3..2fec7f66fb 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.184 2002/07/11 07:39:27 ishii Exp $
+ * $Id: parsenodes.h,v 1.185 2002/07/12 18:43:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -762,6 +762,8 @@ typedef struct AlterTableStmt
* M = alter column storage
* D = drop column
* C = add constraint
+ * c = pre-processed add constraint
+ * (local in parser/analyze.c)
* X = drop constraint
* E = create toast table
* U = change owner
@@ -929,31 +931,41 @@ typedef struct Constraint
/* ----------
* Definitions for FOREIGN KEY constraints in CreateStmt
+ *
+ * Note: FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
+ * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
+ * stored into pg_constraint.confmatchtype. Changing the code values may
+ * require an initdb!
+ *
+ * If skip_validation is true then we skip checking that the existing rows
+ * in the table satisfy the constraint, and just install the catalog entries
+ * for the constraint. This is currently used only during CREATE TABLE
+ * (when we know the table must be empty).
* ----------
*/
-#define FKCONSTR_ON_KEY_NOACTION 0x0000
-#define FKCONSTR_ON_KEY_RESTRICT 0x0001
-#define FKCONSTR_ON_KEY_CASCADE 0x0002
-#define FKCONSTR_ON_KEY_SETNULL 0x0004
-#define FKCONSTR_ON_KEY_SETDEFAULT 0x0008
-
-#define FKCONSTR_ON_DELETE_MASK 0x000F
-#define FKCONSTR_ON_DELETE_SHIFT 0
+#define FKCONSTR_ACTION_NOACTION 'a'
+#define FKCONSTR_ACTION_RESTRICT 'r'
+#define FKCONSTR_ACTION_CASCADE 'c'
+#define FKCONSTR_ACTION_SETNULL 'n'
+#define FKCONSTR_ACTION_SETDEFAULT 'd'
-#define FKCONSTR_ON_UPDATE_MASK 0x00F0
-#define FKCONSTR_ON_UPDATE_SHIFT 4
+#define FKCONSTR_MATCH_FULL 'f'
+#define FKCONSTR_MATCH_PARTIAL 'p'
+#define FKCONSTR_MATCH_UNSPECIFIED 'u'
typedef struct FkConstraint
{
NodeTag type;
- char *constr_name; /* Constraint name */
+ char *constr_name; /* Constraint name, or NULL if unnamed */
RangeVar *pktable; /* Primary key table */
List *fk_attrs; /* Attributes of foreign key */
List *pk_attrs; /* Corresponding attrs in PK table */
- char *match_type; /* FULL or PARTIAL */
- int32 actions; /* ON DELETE/UPDATE actions */
+ char fk_matchtype; /* FULL, PARTIAL, UNSPECIFIED */
+ char fk_upd_action; /* ON UPDATE action */
+ char fk_del_action; /* ON DELETE action */
bool deferrable; /* DEFERRABLE */
bool initdeferred; /* INITIALLY DEFERRED */
+ bool skip_validation; /* skip validation of existing rows? */
} FkConstraint;
/* ----------------------
@@ -1201,6 +1213,7 @@ typedef struct IndexStmt
* transformStmt() */
bool unique; /* is index unique? */
bool primary; /* is index on primary key? */
+ bool isconstraint; /* is it from a CONSTRAINT clause? */
} IndexStmt;
/* ----------------------