diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index c194862..16c34bf 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -45,7 +45,7 @@ ALTER TABLE name ADD table_constraint ADD table_constraint_using_index ADD table_constraint [ NOT VALID ] - VALIDATE CONSTRAINT constraint_name + ALTER CONSTRAINT constraint_name VALID DROP CONSTRAINT [ IF EXISTS ] constraint_name [ RESTRICT | CASCADE ] DISABLE TRIGGER [ trigger_name | ALL | USER ] ENABLE TRIGGER [ trigger_name | ALL | USER ] @@ -248,7 +248,7 @@ ALTER TABLE name - VALIDATE CONSTRAINT + ALTER CONSTRAINT constraint_name VALID This form validates a foreign key constraint that was previously created diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index f1264bf..38483fa 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -5642,7 +5642,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, } /* - * ALTER TABLE VALIDATE CONSTRAINT + * ALTER TABLE ALTER CONSTRAINT VALID */ static void ATExecValidateConstraint(Relation rel, const char *constrName) diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 373d2ad..927fef0 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -556,7 +556,7 @@ static void SplitColQualList(List *qualList, UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNLOGGED UNTIL UPDATE USER USING - VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING + VACUUM VALID VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING VERBOSE VERSION_P VIEW VOLATILE WHEN WHERE WHITESPACE_P WINDOW WITH WITHOUT WORK WRAPPER WRITE @@ -1770,8 +1770,8 @@ alter_table_cmd: n->def = $2; $$ = (Node *)n; } - /* ALTER TABLE VALIDATE CONSTRAINT ... */ - | VALIDATE CONSTRAINT name + /* ALTER TABLE ALTER CONSTRAINT ... VALID */ + | ALTER CONSTRAINT name VALID { AlterTableCmd *n = makeNode(AlterTableCmd); n->subtype = AT_ValidateConstraint; @@ -12057,7 +12057,6 @@ unreserved_keyword: | UPDATE | VACUUM | VALID - | VALIDATE | VALIDATOR | VALUE_P | VARYING diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index f288c76..c1a1686 100644 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -399,7 +399,6 @@ PG_KEYWORD("user", USER, RESERVED_KEYWORD) PG_KEYWORD("using", USING, RESERVED_KEYWORD) PG_KEYWORD("vacuum", VACUUM, UNRESERVED_KEYWORD) PG_KEYWORD("valid", VALID, UNRESERVED_KEYWORD) -PG_KEYWORD("validate", VALIDATE, UNRESERVED_KEYWORD) PG_KEYWORD("validator", VALIDATOR, UNRESERVED_KEYWORD) PG_KEYWORD("value", VALUE_P, UNRESERVED_KEYWORD) PG_KEYWORD("values", VALUES, COL_NAME_KEYWORD) diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index d5a59d5..0c24d70 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -186,16 +186,16 @@ DELETE FROM tmp3 where a=5; ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full; ALTER TABLE tmp3 drop constraint tmpconstr; INSERT INTO tmp3 values (5,50); --- Try NOT VALID and then VALIDATE CONSTRAINT, but fails. Delete failure then re-validate +-- Try NOT VALID and then ALTER CONSTRAINT VALID, but fails. Delete failure then re-validate ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full NOT VALID; -ALTER TABLE tmp3 validate constraint tmpconstr; +ALTER TABLE tmp3 alter constraint tmpconstr valid; ERROR: insert or update on table "tmp3" violates foreign key constraint "tmpconstr" DETAIL: Key (a)=(5) is not present in table "tmp2". -- Delete failing row DELETE FROM tmp3 where a=5; -- Try (and succeed) and repeat to show it works on already valid constraint -ALTER TABLE tmp3 validate constraint tmpconstr; -ALTER TABLE tmp3 validate constraint tmpconstr; +ALTER TABLE tmp3 alter constraint tmpconstr valid; +ALTER TABLE tmp3 alter constraint tmpconstr valid; -- Try (and fail) to create constraint from tmp5(a) to tmp4(a) - unique constraint on -- tmp4 is a,b ALTER TABLE tmp5 add constraint tmpconstr foreign key(a) references tmp4(a) match full; diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 6531a9f..af62fa6 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -225,16 +225,16 @@ ALTER TABLE tmp3 drop constraint tmpconstr; INSERT INTO tmp3 values (5,50); --- Try NOT VALID and then VALIDATE CONSTRAINT, but fails. Delete failure then re-validate +-- Try NOT VALID and then ALTER CONSTRAINT VALID, but fails. Delete failure then re-validate ALTER TABLE tmp3 add constraint tmpconstr foreign key (a) references tmp2 match full NOT VALID; -ALTER TABLE tmp3 validate constraint tmpconstr; +ALTER TABLE tmp3 alter constraint tmpconstr valid; -- Delete failing row DELETE FROM tmp3 where a=5; -- Try (and succeed) and repeat to show it works on already valid constraint -ALTER TABLE tmp3 validate constraint tmpconstr; -ALTER TABLE tmp3 validate constraint tmpconstr; +ALTER TABLE tmp3 alter constraint tmpconstr valid; +ALTER TABLE tmp3 alter constraint tmpconstr valid; -- Try (and fail) to create constraint from tmp5(a) to tmp4(a) - unique constraint on