aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-10-29 11:08:16 +0900
committerMichael Paquier <michael@paquier.xyz>2019-10-29 11:08:16 +0900
commiteae1ba65fab4790c350264714b5eb7581c5e62be (patch)
tree161f62d7f0fc28d91e81c3f118b8f9b8a55e849e /src
parent43e43771bc4b03a9e33be7261cc84dc7f65ae9ef (diff)
downloadpostgresql-eae1ba65fab4790c350264714b5eb7581c5e62be.tar.gz
postgresql-eae1ba65fab4790c350264714b5eb7581c5e62be.zip
Fix handling of pg_class.relispartition at swap phase in REINDEX CONCURRENTLY
When cancelling REINDEX CONCURRENTLY after swapping the old and new indexes (for example interruption at step 5), the old index remains around and is marked as invalid. The old index should also be manually droppable to clean up the parent relation from any invalid indexes still remaining. For a partition index reindexed, pg_class.relispartition was not getting updated, causing the index to not be droppable as DROP INDEX would look for dependencies in a partition tree, which do not exist anymore after the swap phase is done. The fix here is simple: when swapping the old and new indexes, make sure that pg_class.relispartition is correctly switched, similarly to what is done for the index name. Reported-by: Justin Pryzby Author: Michael Paquier Discussion: https://postgr.es/m/20191015164047.GA22729@telsasoft.com Backpatch-through: 12
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/index.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 2fe080863fe..4ae65915ac4 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1462,6 +1462,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
newIndexTuple;
Form_pg_index oldIndexForm,
newIndexForm;
+ bool isPartition;
Oid indexConstraintOid;
List *constraintOids = NIL;
ListCell *lc;
@@ -1491,8 +1492,10 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname));
namestrcpy(&oldClassForm->relname, oldName);
- /* Copy partition flag to track inheritance properly */
+ /* Swap the partition flags to track inheritance properly */
+ isPartition = newClassForm->relispartition;
newClassForm->relispartition = oldClassForm->relispartition;
+ oldClassForm->relispartition = isPartition;
CatalogTupleUpdate(pg_class, &oldClassTuple->t_self, oldClassTuple);
CatalogTupleUpdate(pg_class, &newClassTuple->t_self, newClassTuple);