aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/indexcmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r--src/backend/commands/indexcmds.c14
1 files changed, 12 insertions, 2 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 */