pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcomma
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcomma
@ 2020-08-22 16:34  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-08-22 16:34 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcommands.

Commit 1281a5c90 rearranged the logic in this area rather drastically,
and it broke the case of adding a foreign key constraint in the same
ALTER that adds the pkey or unique constraint it depends on.  While
self-referential fkeys are surely a pretty niche case, this used to
work so we shouldn't break it.

To fix, reorganize the scheduling rules in ATParseTransformCmd so
that a transformed AT_AddConstraint subcommand will be delayed into
a later pass in all cases, not only when it's been spit out as a
side-effect of parsing some other command type.

Also tweak the logic so that we won't run ATParseTransformCmd twice
while doing this.  It seems to work even without that, but it's
surely wasting cycles to do so.

Per bug #16589 from Jeremy Evans.  Back-patch to v13 where the new
code was introduced.

Discussion: https://postgr.es/m/16589-31c8d981ca503896@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5b02d68e758307e0ae8fae4d7bbcd687f1dd6ce1

Modified Files
--------------
src/backend/commands/tablecmds.c          | 151 +++++++++++++++++-------------
src/test/regress/expected/alter_table.out |  36 +++++++
src/test/regress/sql/alter_table.sql      |  14 +++
3 files changed, 135 insertions(+), 66 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcomma
@ 2020-08-22 16:34  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-08-22 16:34 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcommands.

Commit 1281a5c90 rearranged the logic in this area rather drastically,
and it broke the case of adding a foreign key constraint in the same
ALTER that adds the pkey or unique constraint it depends on.  While
self-referential fkeys are surely a pretty niche case, this used to
work so we shouldn't break it.

To fix, reorganize the scheduling rules in ATParseTransformCmd so
that a transformed AT_AddConstraint subcommand will be delayed into
a later pass in all cases, not only when it's been spit out as a
side-effect of parsing some other command type.

Also tweak the logic so that we won't run ATParseTransformCmd twice
while doing this.  It seems to work even without that, but it's
surely wasting cycles to do so.

Per bug #16589 from Jeremy Evans.  Back-patch to v13 where the new
code was introduced.

Discussion: https://postgr.es/m/16589-31c8d981ca503896@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/47de6ac11b53cf24393a2ef048f9e8921163da0a

Modified Files
--------------
src/backend/commands/tablecmds.c          | 151 +++++++++++++++++-------------
src/test/regress/expected/alter_table.out |  36 +++++++
src/test/regress/sql/alter_table.sql      |  14 +++
3 files changed, 135 insertions(+), 66 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-08-22 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 16:34 pgsql: Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcomma Tom Lane <tgl@sss.pgh.pa.us>
2020-08-22 16:34 pgsql: Fix ALTER TABLE's scheduling rules for AT_AddConstraint subcomma Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox