aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/indexcmds.c14
-rw-r--r--src/backend/commands/tablecmds.c4
2 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index ed19f77ba0a..cb5d91e7640 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -1151,6 +1151,18 @@ DefineIndex(Oid relationId,
ListCell *lc;
/*
+ * We can't use the same index name for the child index,
+ * so clear idxname to let the recursive invocation choose
+ * a new name. Likewise, the existing target relation
+ * field is wrong, and if indexOid or oldNode are set,
+ * they mustn't be applied to the child either.
+ */
+ childStmt->idxname = NULL;
+ childStmt->relation = NULL;
+ childStmt->indexOid = InvalidOid;
+ childStmt->oldNode = InvalidOid;
+
+ /*
* Adjust any Vars (both in expressions and in the index's
* WHERE clause) to match the partition's column numbering
* in case it's different from the parent's.
@@ -1181,8 +1193,6 @@ DefineIndex(Oid relationId,
if (found_whole_row)
elog(ERROR, "cannot convert whole-row table reference");
- childStmt->idxname = NULL;
- childStmt->relation = NULL;
DefineIndex(childRelid, childStmt,
InvalidOid, /* no predefined OID */
indexRelationId, /* this is our child */
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index b2f8189fa16..14fcad9034b 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -11452,7 +11452,9 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
{
Relation irel = index_open(oldId, NoLock);
- stmt->oldNode = irel->rd_node.relNode;
+ /* If it's a partitioned index, there is no storage to share. */
+ if (irel->rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
+ stmt->oldNode = irel->rd_node.relNode;
index_close(irel, NoLock);
}
}