]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Apply stopgap fix for bug #15672.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Apr 2019 21:18:07 +0000 (17:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Apr 2019 21:18:07 +0000 (17:18 -0400)
commit02c359eeda50a71c951371c9d3e920ff8f514008
treefecdc3979ea2aac305e7ea75ea95b9e1e24b88de
parent53f48a2abb7b13a866d62e68e6ecfb11b637b0b1
Apply stopgap fix for bug #15672.

Fix DefineIndex so that it doesn't attempt to pass down a to-be-reused
index relfilenode to a child index creation, and fix TryReuseIndex
to not think that reuse is sensible for a partitioned index.

In v11, this fixes a problem where ALTER TABLE on a partitioned table
could assign the same relfilenode to several different child indexes,
causing very nasty catalog corruption --- in fact, attempting to DROP
the partitioned table then leads not only to a database crash, but to
inability to restart because the same crash will recur during WAL replay.

Either of these two changes would be enough to prevent the failure, but
since neither action could possibly be sane, let's put in both changes
for future-proofing.

In HEAD, no such bug manifests, but that's just an accidental consequence
of having changed the pg_class representation of partitioned indexes to
have relfilenode = 0.  Both of these changes still seem like smart
future-proofing.

This is only a stop-gap because the code for ALTER TABLE on a partitioned
table with a no-op type change still leaves a great deal to be desired.
As the added regression tests show, it gets things wrong for comments on
child indexes/constraints, and it is regenerating child indexes it doesn't
have to.  However, fixing those problems will take more work which may not
get back-patched into v11.  We need a fix for the corruption problem now.

Per bug #15672 from Jianing Yang.

Patch by me, regression test cases based on work by Amit Langote,
who also did a lot of the investigative work.

Discussion: https://postgr.es/m/15672-b9fa7db32698269f@postgresql.org
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/test/regress/expected/alter_table.out
src/test/regress/sql/alter_table.sql