postgresql/src/backend/commands
Tom Lane c01eb619a8 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
2019-04-26 17:18:07 -04:00
..
Makefile Move vacuumlazy.c into access/heap. 2019-01-15 12:06:19 -08:00
aggregatecmds.c Implement OR REPLACE option for CREATE AGGREGATE. 2019-03-19 01:16:50 +00:00
alter.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
amcmds.c Harden tableam against nonexistant / wrong kind of AMs. 2019-04-04 17:39:39 -07:00
analyze.c tableam: VACUUM and ANALYZE support. 2019-03-30 19:25:58 -07:00
async.c Move remaining code from tqual.[ch] to heapam.h / heapam_visibility.c. 2019-01-21 17:07:10 -08:00
cluster.c Allow pg_class xid & multixid horizons to not be set. 2019-04-23 21:42:12 -07:00
collationcmds.c Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
comment.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
constraint.c tableam: Add and use scan APIs. 2019-03-11 12:46:41 -07:00
conversioncmds.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
copy.c Remove unused struct member, enforce multi_insert callback presence. 2019-04-04 17:39:39 -07:00
createas.c tableam: Add table_finish_bulk_insert(). 2019-04-01 14:41:42 -07:00
dbcommands.c Refactor the fsync queue for wider use. 2019-04-04 23:38:38 +13:00
define.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
discard.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
dropcmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
event_trigger.c Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
explain.c Add SETTINGS option to EXPLAIN, to print modified settings. 2019-04-04 00:04:31 +02:00
extension.c Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
foreigncmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
functioncmds.c Create the infrastructure for planner support functions. 2019-02-09 18:08:48 -05:00
indexcmds.c Apply stopgap fix for bug #15672. 2019-04-26 17:18:07 -04:00
lockcmds.c Fix more strcmp() calls using boolean-like comparisons for result checks 2019-04-12 10:16:49 +09:00
matview.c Fix tablespace inheritance for partitioned rels 2019-04-25 10:31:32 -04:00
opclasscmds.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
operatorcmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
policy.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
portalcmds.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
prepare.c Refactor ParamListInfo initialization 2019-03-14 13:30:09 +01:00
proclang.c Remove unnecessary use of PROCEDURAL 2019-02-25 08:38:59 +01:00
publicationcmds.c Move hash_any prototype from access/hash.h to utils/hashutils.h 2019-03-11 13:17:50 -03:00
schemacmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
seclabel.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
sequence.c tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE. 2019-03-28 20:01:43 -07:00
statscmds.c Add support for multivariate MCV lists 2019-03-27 18:32:18 +01:00
subscriptioncmds.c Replace uses of heap_open et al with the corresponding table_* function. 2019-01-21 10:51:37 -08:00
tablecmds.c Apply stopgap fix for bug #15672. 2019-04-26 17:18:07 -04:00
tablespace.c Fix tablespace inheritance for partitioned rels 2019-04-25 10:31:32 -04:00
trigger.c Fix two memory leaks around force-storing tuples in slots. 2019-04-19 11:39:56 -07:00
tsearchcmds.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
typecmds.c Generated columns 2019-03-30 08:15:57 +01:00
user.c Remove superfluous tqual.h includes. 2019-01-21 12:15:02 -08:00
vacuum.c Allow pg_class xid & multixid horizons to not be set. 2019-04-23 21:42:12 -07:00
variable.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
view.c Fix CREATE VIEW to allow zero-column views. 2019-02-17 12:37:31 -05:00