Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e89f4c6

Browse files
committed
Fix test case to do what it intends to
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 6995863.
1 parent 3ca43db commit e89f4c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/test/regress/expected/identity.out

+4-2
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,13 @@ ALTER TABLE pitest3_p1
756756
ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
757757
ERROR: cannot add identity to a column of a partition
758758
-- fails, changing only the partitioned table not allowed
759+
BEGIN;
760+
ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL;
759761
ALTER TABLE ONLY pitest3
760-
ALTER COLUMN f3 SET NOT NULL,
761762
ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
762-
ERROR: constraint must be added to child tables too
763+
ERROR: cannot add identity to a column of only the partitioned table
763764
HINT: Do not specify the ONLY keyword.
765+
ROLLBACK;
764766
ALTER TABLE pitest3
765767
ALTER COLUMN f3 SET NOT NULL,
766768
ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);

src/test/regress/sql/identity.sql

+3-1
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,11 @@ ALTER TABLE pitest3_p1
418418
ALTER COLUMN f3 SET NOT NULL,
419419
ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
420420
-- fails, changing only the partitioned table not allowed
421+
BEGIN;
422+
ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL;
421423
ALTER TABLE ONLY pitest3
422-
ALTER COLUMN f3 SET NOT NULL,
423424
ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);
425+
ROLLBACK;
424426
ALTER TABLE pitest3
425427
ALTER COLUMN f3 SET NOT NULL,
426428
ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3);

0 commit comments

Comments
 (0)