1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

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.
This commit is contained in:
Tom Lane
2002-07-12 18:43:19 +00:00
parent 791a40f943
commit 7c6df91dda
77 changed files with 4074 additions and 1987 deletions

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.192 2002/07/01 15:27:51 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.193 2002/07/12 18:43:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1505,11 +1505,12 @@ _copyFkConstraint(FkConstraint *from)
Node_Copy(from, newnode, pktable);
Node_Copy(from, newnode, fk_attrs);
Node_Copy(from, newnode, pk_attrs);
if (from->match_type)
newnode->match_type = pstrdup(from->match_type);
newnode->actions = from->actions;
newnode->fk_matchtype = from->fk_matchtype;
newnode->fk_upd_action = from->fk_upd_action;
newnode->fk_del_action = from->fk_del_action;
newnode->deferrable = from->deferrable;
newnode->initdeferred = from->initdeferred;
newnode->skip_validation = from->skip_validation;
return newnode;
}
@@ -2089,6 +2090,7 @@ _copyIndexStmt(IndexStmt *from)
Node_Copy(from, newnode, rangetable);
newnode->unique = from->unique;
newnode->primary = from->primary;
newnode->isconstraint = from->isconstraint;
return newnode;
}

View File

@@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.139 2002/07/01 15:27:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.140 2002/07/12 18:43:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -912,6 +912,8 @@ _equalIndexStmt(IndexStmt *a, IndexStmt *b)
return false;
if (a->primary != b->primary)
return false;
if (a->isconstraint != b->isconstraint)
return false;
return true;
}
@@ -1734,14 +1736,18 @@ _equalFkConstraint(FkConstraint *a, FkConstraint *b)
return false;
if (!equal(a->pk_attrs, b->pk_attrs))
return false;
if (!equalstr(a->match_type, b->match_type))
if (a->fk_matchtype != b->fk_matchtype)
return false;
if (a->actions != b->actions)
if (a->fk_upd_action != b->fk_upd_action)
return false;
if (a->fk_del_action != b->fk_del_action)
return false;
if (a->deferrable != b->deferrable)
return false;
if (a->initdeferred != b->initdeferred)
return false;
if (a->skip_validation != b->skip_validation)
return false;
return true;
}

View File

@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.161 2002/07/04 15:23:53 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.162 2002/07/12 18:43:16 tgl Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -136,9 +136,10 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
_outNode(str, node->whereClause);
appendStringInfo(str, " :rangetable ");
_outNode(str, node->rangetable);
appendStringInfo(str, " :unique %s :primary %s ",
appendStringInfo(str, " :unique %s :primary %s :isconstraint %s ",
booltostr(node->unique),
booltostr(node->primary));
booltostr(node->primary),
booltostr(node->isconstraint));
}
static void
@@ -1447,12 +1448,13 @@ _outFkConstraint(StringInfo str, FkConstraint *node)
_outNode(str, node->fk_attrs);
appendStringInfo(str, " :pk_attrs ");
_outNode(str, node->pk_attrs);
appendStringInfo(str, " :match_type ");
_outToken(str, node->match_type);
appendStringInfo(str, " :actions %d :deferrable %s :initdeferred %s",
node->actions,
appendStringInfo(str, " :fk_matchtype %c :fk_upd_action %c :fk_del_action %c :deferrable %s :initdeferred %s :skip_validation %s",
node->fk_matchtype,
node->fk_upd_action,
node->fk_del_action,
booltostr(node->deferrable),
booltostr(node->initdeferred));
booltostr(node->initdeferred),
booltostr(node->skip_validation));
}
static void