Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7bbc462

Browse files
committed
Fix ALTER TABLE error message
This bogus error message was introduced in 2013 by commitf177cbf,because of misunderstanding the processCASbits() API; at the time, notest cases were added that would be affected by this change. Only inca87c41 was one added (along with a couple of typos), with an XXXnote that the error message was bogus. Fix the whole, add some testcases.Backpatch all the way back.Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>Discussion:https://postgr.es/m/202503041822.aobpqke3igvb@alvherre.pgsql
1 parentbacbc48 commit7bbc462

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

‎src/backend/parser/gram.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,7 @@ alter_table_cmd:
26632663
n->def = (Node *) c;
26642664
c->conname =$3;
26652665
c->alterDeferrability =true;
2666-
processCASbits($4, @4,"ALTER CONSTRAINT statement",
2666+
processCASbits($4, @4,"FOREIGN KEY",
26672667
&c->deferrable,
26682668
&c->initdeferred,
26692669
NULL,NULL,NULL, yyscanner);

‎src/test/regress/expected/constraints.out

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ SELECT * FROM unique_tbl;
735735
3 | threex
736736
(5 rows)
737737

738-
--enforcibility cannot be specified or set for uniqueconstrain
738+
--enforceability cannot be specified or set for uniqueconstraint
739739
CREATE TABLE UNIQUE_EN_TBL(i int UNIQUE ENFORCED);
740740
ERROR: misplaced ENFORCED clause
741741
LINE 1: CREATE TABLE UNIQUE_EN_TBL(i int UNIQUE ENFORCED);
@@ -744,13 +744,12 @@ CREATE TABLE UNIQUE_NOTEN_TBL(i int UNIQUE NOT ENFORCED);
744744
ERROR: misplaced NOT ENFORCED clause
745745
LINE 1: CREATE TABLE UNIQUE_NOTEN_TBL(i int UNIQUE NOT ENFORCED);
746746
^
747-
-- XXX: error message is misleading here
748747
ALTER TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key ENFORCED;
749-
ERROR:ALTER CONSTRAINT statement constraints cannot be marked ENFORCED
748+
ERROR:FOREIGN KEY constraints cannot be marked ENFORCED
750749
LINE 1: ...TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key ENFORCED;
751750
^
752751
ALTER TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key NOT ENFORCED;
753-
ERROR:ALTER CONSTRAINT statement constraints cannot be marked NOT ENFORCED
752+
ERROR:FOREIGN KEY constraints cannot be marked NOT ENFORCED
754753
LINE 1: ...ABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key NOT ENFORC...
755754
^
756755
DROP TABLE unique_tbl;

‎src/test/regress/expected/foreign_key.out

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,11 +1278,19 @@ DETAIL: Key (fk)=(20) is not present in table "pktable".
12781278
COMMIT;
12791279
-- try additional syntax
12801280
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE;
1281-
-- illegaloption
1281+
-- illegaloptions
12821282
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY DEFERRED;
12831283
ERROR: constraint declared INITIALLY DEFERRED must be DEFERRABLE
12841284
LINE 1: ...e ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY ...
12851285
^
1286+
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT;
1287+
ERROR: FOREIGN KEY constraints cannot be marked NO INHERIT
1288+
LINE 1: ...ER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT...
1289+
^
1290+
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID;
1291+
ERROR: FOREIGN KEY constraints cannot be marked NOT VALID
1292+
LINE 1: ...ER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID;
1293+
^
12861294
-- test order of firing of FK triggers when several RI-induced changes need to
12871295
-- be made to the same row. This was broken by subtransaction-related
12881296
-- changes in 8.0.

‎src/test/regress/sql/constraints.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,9 @@ COMMIT;
531531

532532
SELECT*FROM unique_tbl;
533533

534-
--enforcibility cannot be specified or set for uniqueconstrain
534+
--enforceability cannot be specified or set for uniqueconstraint
535535
CREATETABLEUNIQUE_EN_TBL(iint UNIQUE ENFORCED);
536536
CREATETABLEUNIQUE_NOTEN_TBL(iint UNIQUE NOT ENFORCED);
537-
-- XXX: error message is misleading here
538537
ALTERTABLE unique_tbl ALTERCONSTRAINT unique_tbl_i_key ENFORCED;
539538
ALTERTABLE unique_tbl ALTERCONSTRAINT unique_tbl_i_key NOT ENFORCED;
540539

‎src/test/regress/sql/foreign_key.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,10 @@ COMMIT;
970970

971971
-- try additional syntax
972972
ALTERTABLE fktable ALTERCONSTRAINT fktable_fk_fkey NOT DEFERRABLE;
973-
-- illegaloption
973+
-- illegaloptions
974974
ALTERTABLE fktable ALTERCONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY DEFERRED;
975+
ALTERTABLE fktable ALTERCONSTRAINT fktable_fk_fkey NO INHERIT;
976+
ALTERTABLE fktable ALTERCONSTRAINT fktable_fk_fkey NOT VALID;
975977

976978
-- test order of firing of FK triggers when several RI-induced changes need to
977979
-- be made to the same row. This was broken by subtransaction-related

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp