Fix test case to do what it intends to
authorAlvaro Herrera <[email protected]>
Mon, 13 May 2024 08:32:33 +0000 (10:32 +0200)
committerAlvaro Herrera <[email protected]>
Mon, 13 May 2024 08:32:33 +0000 (10:32 +0200)
This test case intended to fail because setting a column as generated to
the partitioned table while leaving the partition alone is not allowed;
but instead failed because of a discrepancy of not-null constraint.  Fix
this by adding the not-null constraint first, then set the column as
generated in a separate ALTER TABLE command, which gets the expected
error.  Also, because the next test also wants to set the column as
not-null, add a BEGIN/ROLLBACK block so that the added not-null is
removed.

Oversight in 699586315704.

src/test/regress/expected/identity.out
src/test/regress/sql/identity.sql

index 31ad041055f7d26887618c61723f2625772d5979..29539e7f6323814672c78ecc6d17967b5218270e 100644 (file)
@@ -756,11 +756,13 @@ ALTER TABLE pitest3_p1
             ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
 ERROR:  cannot add identity to a column of a partition
 -- fails, changing only the partitioned table not allowed
+BEGIN;
+ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL;
 ALTER TABLE ONLY pitest3
-            ALTER COLUMN f3 SET NOT NULL,
             ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
-ERROR:  constraint must be added to child tables too
+ERROR:  cannot add identity to a column of only the partitioned table
 HINT:  Do not specify the ONLY keyword.
+ROLLBACK;
 ALTER TABLE pitest3
             ALTER COLUMN f3 SET NOT NULL,
             ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
index 27ca708ff196b36024ad6c39fcf3aaa14cf311e0..84c43a19a31af3034194868a0978c91cbcc84bb2 100644 (file)
@@ -418,9 +418,11 @@ ALTER TABLE pitest3_p1
             ALTER COLUMN f3 SET NOT NULL,
             ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
 -- fails, changing only the partitioned table not allowed
+BEGIN;
+ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL;
 ALTER TABLE ONLY pitest3
-            ALTER COLUMN f3 SET NOT NULL,
             ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
+ROLLBACK;
 ALTER TABLE pitest3
             ALTER COLUMN f3 SET NOT NULL,
             ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);