alter-constraint-valid.patch

application/octet-stream

Filename: alter-constraint-valid.patch
Type: application/octet-stream
Part: 0
Message: Re: [COMMITTERS] pgsql: Add missing keywords to gram.y's unreserved_keywords list.

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
doc/src/sgml/ref/alter_table.sgml 2 2
src/backend/commands/tablecmds.c 1 1
src/backend/parser/gram.y 3 4
src/include/parser/kwlist.h 0 1
src/test/regress/expected/alter_table.out 4 4
src/test/regress/sql/alter_table.sql 4 4
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 <replaceable class="PARAMETER">name</replaceable>
     ADD <replaceable class="PARAMETER">table_constraint</replaceable>
     ADD <replaceable class="PARAMETER">table_constraint_using_index</replaceable>
     ADD <replaceable class="PARAMETER">table_constraint</replaceable> [ NOT VALID ]
-    VALIDATE CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable>
+    ALTER CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> VALID
     DROP CONSTRAINT [ IF EXISTS ]  <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ]
     DISABLE TRIGGER [ <replaceable class="PARAMETER">trigger_name</replaceable> | ALL | USER ]
     ENABLE TRIGGER [ <replaceable class="PARAMETER">trigger_name</replaceable> | ALL | USER ]
@@ -248,7 +248,7 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
    </varlistentry>
 
    <varlistentry>
-    <term><literal>VALIDATE CONSTRAINT</literal></term>
+    <term><literal>ALTER CONSTRAINT <replaceable class="PARAMTER">constraint_name</replaceable> VALID</literal></term>
     <listitem>
      <para>
       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 <name> VALIDATE CONSTRAINT ... */
-			| VALIDATE CONSTRAINT name
+			/* ALTER TABLE <name> 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