pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix ALTER/TYPE on columns referenced by FKs in partitioned table
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix ALTER/TYPE on columns referenced by FKs in partitioned table
@ 2018-09-14 17:25  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2018-09-14 17:25 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix ALTER/TYPE on columns referenced by FKs in partitioned tables

When ALTER TABLE ... SET DATA TYPE affects a column referenced by
constraints and indexes, it drop those constraints and indexes and
recreates them afterwards, so that the definitions match the new data
type.  The original code did this by dropping one object at a time
(commit 077db40fa1f3 of May 2004), which worked fine because the
dependencies between the objects were pretty straightforward, and
ordering the objects in a specific way was enough to make this work.
However, when there are foreign key constraints in partitioned tables,
the dependencies are no longer so straightforward, and we were getting
errors when attempted:
  ERROR:  cache lookup failed for constraint 16398

This can be fixed by doing all the drops in one pass instead, using
performMultipleDeletions (introduced by df18c51f2955 of Aug 2006).  With
this change we can also remove the code to carefully order the list of
objects to be deleted.

Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAKcux6nWS_m+s=1Udk_U9B+QY7pA-Ac58qR5BdUfOyrwnWHDew@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/20bef2c3110af295501919bac463b87ac58876de

Modified Files
--------------
src/backend/commands/tablecmds.c          | 71 +++++++++++--------------------
src/test/regress/expected/foreign_key.out | 12 ++++++
src/test/regress/sql/foreign_key.sql      | 11 +++++
3 files changed, 47 insertions(+), 47 deletions(-)



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

* pgsql: Fix ALTER/TYPE on columns referenced by FKs in partitioned table
@ 2018-09-14 17:25  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2018-09-14 17:25 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix ALTER/TYPE on columns referenced by FKs in partitioned tables

When ALTER TABLE ... SET DATA TYPE affects a column referenced by
constraints and indexes, it drop those constraints and indexes and
recreates them afterwards, so that the definitions match the new data
type.  The original code did this by dropping one object at a time
(commit 077db40fa1f3 of May 2004), which worked fine because the
dependencies between the objects were pretty straightforward, and
ordering the objects in a specific way was enough to make this work.
However, when there are foreign key constraints in partitioned tables,
the dependencies are no longer so straightforward, and we were getting
errors when attempted:
  ERROR:  cache lookup failed for constraint 16398

This can be fixed by doing all the drops in one pass instead, using
performMultipleDeletions (introduced by df18c51f2955 of Aug 2006).  With
this change we can also remove the code to carefully order the list of
objects to be deleted.

Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAKcux6nWS_m+s=1Udk_U9B+QY7pA-Ac58qR5BdUfOyrwnWHDew@mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6009bad9134782babfc45c6bae6cfbca7f4899d0

Modified Files
--------------
src/backend/commands/tablecmds.c          | 71 +++++++++++--------------------
src/test/regress/expected/foreign_key.out | 12 ++++++
src/test/regress/sql/foreign_key.sql      | 11 +++++
3 files changed, 47 insertions(+), 47 deletions(-)



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


end of thread, other threads:[~2018-09-14 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14 17:25 pgsql: Fix ALTER/TYPE on columns referenced by FKs in partitioned table Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-09-14 17:25 pgsql: Fix ALTER/TYPE on columns referenced by FKs in partitioned table Alvaro Herrera <alvherre@alvh.no-ip.org>

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