aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-10-28 11:58:29 +0900
committerMichael Paquier <michael@paquier.xyz>2019-10-28 11:58:29 +0900
commit5e5f32284d691d0be71d6859c1de9b0367b26584 (patch)
tree529ccc807adf9a95186db9dfe4e925ff96eb9bad /src/backend
parent9f0172bba75028a7a5b1a470406adcc2af0f3b86 (diff)
downloadpostgresql-5e5f32284d691d0be71d6859c1de9b0367b26584.tar.gz
postgresql-5e5f32284d691d0be71d6859c1de9b0367b26584.zip
Fix dependency handling at swap phase of REINDEX CONCURRENTLY
When swapping the dependencies of the old and new indexes, the code has been correctly switching all links in pg_depend from the old to the new index for both referencing and referenced entries. However it forgot the fact that the new index may itself have existing entries in pg_depend, like references to the parent table attributes. This resulted in duplicated entries in pg_depend after running REINDEX CONCURRENTLY. Fix this problem by removing any existing entries in pg_depend for the new index before switching the dependencies of the old index to the new one. More regression tests are added to check the consistency of entries in pg_depend for indexes, including partitions. Author: Michael Paquier Discussion: https://postgr.es/m/20191025064318.GF8671@paquier.xyz Backpatch-through: 12
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/catalog/index.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 345628c42b9..2fe080863fe 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1668,8 +1668,12 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
}
/*
- * Move all dependencies of and on the old index to the new one
+ * Move all dependencies of and on the old index to the new one. First
+ * remove any dependencies that the new index may have to provide an
+ * initial clean state for the dependency switch, and then move all the
+ * dependencies from the old index to the new one.
*/
+ deleteDependencyRecordsFor(RelationRelationId, newIndexId, false);
changeDependenciesOf(RelationRelationId, oldIndexId, newIndexId);
changeDependenciesOn(RelationRelationId, oldIndexId, newIndexId);