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

Commit4e026be

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 parent56e6a31 commit4e026be

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

‎src/backend/parser/gram.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2649,7 +2649,7 @@ alter_table_cmd:
26492649
n->def = (Node *) c;
26502650
c->contype = CONSTR_FOREIGN;/* others not supported, yet*/
26512651
c->conname =$3;
2652-
processCASbits($4, @4,"ALTER CONSTRAINT statement",
2652+
processCASbits($4, @4,"FOREIGN KEY",
26532653
&c->deferrable,
26542654
&c->initdeferred,
26552655
NULL,NULL, yyscanner);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,11 +1278,15 @@ 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+
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID;
1289+
ERROR: FOREIGN KEY constraints cannot be marked NOT VALID
12861290
-- test order of firing of FK triggers when several RI-induced changes need to
12871291
-- be made to the same row. This was broken by subtransaction-related
12881292
-- changes in 8.0.

‎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