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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 73656d8cc84..6c06167fb2a 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -833,8 +833,18 @@ DefineIndex(Oid relationId,
flags |= INDEX_CREATE_PARTITIONED;
if (stmt->primary)
flags |= INDEX_CREATE_IS_PRIMARY;
+
+ /*
+ * If the table is partitioned, and recursion was declined but partitions
+ * exist, mark the index as invalid.
+ */
if (partitioned && stmt->relation && !stmt->relation->inh)
- flags |= INDEX_CREATE_INVALID;
+ {
+ PartitionDesc pd = RelationGetPartitionDesc(rel);
+
+ if (pd->nparts != 0)
+ flags |= INDEX_CREATE_INVALID;
+ }
if (stmt->deferrable)
constr_flags |= INDEX_CONSTR_CREATE_DEFERRABLE;