pgsql: Apply stopgap fix for bug #15672.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Apply stopgap fix for bug #15672.
Дата
Msg-id E1hK8EZ-0005B7-6b@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c01eb619a83aed460b9ead50831265f2acde3c57

Modified Files
--------------
src/backend/commands/indexcmds.c          | 14 ++++-
src/backend/commands/tablecmds.c          |  4 +-
src/test/regress/expected/alter_table.out | 88 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 63 ++++++++++++++++++++++
4 files changed, 166 insertions(+), 3 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: pg_dump: store unused attribs as NULL instead of '\0'
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Update key words table for version 12