mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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.
This commit is contained in:
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user