Prevent reindex of invalid indexes on TOAST tables
authorMichael Paquier <michael@paquier.xyz>
Tue, 10 Mar 2020 06:38:17 +0000 (15:38 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 10 Mar 2020 06:38:17 +0000 (15:38 +0900)
commit61d7c7bce3686ec02bd64abac742dd35ed9b9b01
tree586d95a23ea39401f0e280a9721cafc7c212ba71
parent71e0d0a73773b3985db658d3c5366ce5ceef76ae
Prevent reindex of invalid indexes on TOAST tables

Such indexes can only be duplicated leftovers of a previously failed
REINDEX CONCURRENTLY command, and a valid equivalent is guaranteed to
exist.  As toast indexes can only be dropped if invalid, reindexing
these would lead to useless duplicated indexes that can't be dropped
anymore, except if the parent relation is dropped.

Thanks to Justin Pryzby for reminding that this problem was reported
long ago during the review of the original patch of REINDEX
CONCURRENTLY, but the issue was never addressed.

Reported-by: Sergei Kornilov, Justin Pryzby
Author: Julien Rouhaud
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/36712441546604286%40sas1-890ba5c2334a.qloud-c.yandex.net
Discussion: https://postgr.es/m/20200216190835.GA21832@telsasoft.com
Backpatch-through: 12
src/backend/catalog/index.c
src/backend/commands/indexcmds.c
src/backend/utils/cache/lsyscache.c
src/include/utils/lsyscache.h