Content-Length: 337236 | pFad | http://github.com/postgrespro/postgres/commit/4e026be5f15994a7036eaca172126226e053f655

0C Fix ALTER TABLE error message · postgrespro/postgres@4e026be · GitHub
Skip to content

Commit 4e026be

Browse files
committed
Fix ALTER TABLE error message
This bogus error message was introduced in 2013 by commit f177cbf, because of misunderstanding the processCASbits() API; at the time, no test cases were added that would be affected by this change. Only in ca87c41 was one added (along with a couple of typos), with an XXX note that the error message was bogus. Fix the whole, add some test cases. Backpatch all the way back. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://postgr.es/m/202503041822.aobpqke3igvb@alvherre.pgsql
1 parent 56e6a31 commit 4e026be

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-
-- illegal option
1281+
-- illegal options
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
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE;
973-
-- illegal option
973+
-- illegal options
974974
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY DEFERRED;
975+
ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT;
976+
ALTER TABLE fktable ALTER CONSTRAINT 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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/4e026be5f15994a7036eaca172126226e053f655

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy