diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-06-15 19:05:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-06-15 19:06:21 -0400 |
commit | e1ccaff6eea1b48f4b9b28cabaf0f990119b0d19 (patch) | |
tree | a0a27055b145ea815d4658120bf120d8dbe91414 /src/backend/commands/tablecmds.c | |
parent | e3df3572f66aa099d337f013dceef7d519ef8398 (diff) | |
download | postgresql-e1ccaff6eea1b48f4b9b28cabaf0f990119b0d19.tar.gz postgresql-e1ccaff6eea1b48f4b9b28cabaf0f990119b0d19.zip |
Rework parsing of ConstraintAttributeSpec to improve NOT VALID handling.
The initial commit of the ALTER TABLE ADD FOREIGN KEY NOT VALID feature
failed to support labeling such constraints as deferrable. The best fix
for this seems to be to fold NOT VALID into ConstraintAttributeSpec.
That's a bit more general than the documented syntax, but it allows
better-targeted syntax error messages.
In addition, do some mostly-but-not-entirely-cosmetic code review for
the whole NOT VALID patch.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 2c9f855f531..912f45c052a 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -258,7 +258,7 @@ static void AlterIndexNamespaces(Relation classRel, Relation rel, static void AlterSeqNamespaces(Relation classRel, Relation rel, Oid oldNspOid, Oid newNspOid, const char *newNspName, LOCKMODE lockmode); -static void ATExecValidateConstraint(Relation rel, const char *constrName); +static void ATExecValidateConstraint(Relation rel, char *constrName); static int transformColumnNameList(Oid relId, List *colList, int16 *attnums, Oid *atttypids); static int transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, @@ -5726,9 +5726,9 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, createForeignKeyTriggers(rel, fkconstraint, constrOid, indexOid); /* - * Tell Phase 3 to check that the constraint is satisfied by existing rows - * We can skip this during table creation or if requested explicitly by - * specifying NOT VALID on an alter table statement. + * Tell Phase 3 to check that the constraint is satisfied by existing rows. + * We can skip this during table creation, or if requested explicitly by + * specifying NOT VALID in an ADD FOREIGN KEY command. */ if (!fkconstraint->skip_validation) { @@ -5755,7 +5755,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, * ALTER TABLE VALIDATE CONSTRAINT */ static void -ATExecValidateConstraint(Relation rel, const char *constrName) +ATExecValidateConstraint(Relation rel, char *constrName) { Relation conrel; SysScanDesc scan; @@ -5810,7 +5810,7 @@ ATExecValidateConstraint(Relation rel, const char *constrName) */ refrel = heap_open(con->confrelid, RowShareLock); - validateForeignKeyConstraint((char *) constrName, rel, refrel, + validateForeignKeyConstraint(constrName, rel, refrel, con->conindid, conid); @@ -5830,6 +5830,7 @@ ATExecValidateConstraint(Relation rel, const char *constrName) heap_close(conrel, RowExclusiveLock); } + /* * transformColumnNameList - transform list of column names * |