We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 415dc20 commit 677f74eCopy full SHA for 677f74e
src/backend/commands/indexcmds.c
@@ -1163,15 +1163,17 @@ DefineIndex(Oid relationId,
1163
1164
if (partitioned)
1165
{
1166
+ PartitionDesc partdesc;
1167
+
1168
/*
1169
* Unless caller specified to skip this step (via ONLY), process each
1170
* partition to make sure they all contain a corresponding index.
1171
*
1172
* If we're called internally (no stmt->relation), recurse always.
1173
*/
- if (!stmt->relation || stmt->relation->inh)
1174
+ partdesc = RelationGetPartitionDesc(rel);
1175
+ if ((!stmt->relation || stmt->relation->inh) && partdesc->nparts > 0)
1176
- PartitionDesc partdesc = RelationGetPartitionDesc(rel);
1177
int nparts = partdesc->nparts;
1178
Oid *part_oids = palloc(sizeof(Oid) * nparts);
1179
bool invalidate_parent = false;
0 commit comments