use RelationGetPartitionDesc to be more safe

For getting the partition desc, we should use RelationGetPartitionDesc
method so that even if it is NULL, it will be created in the method.
pull/3857/head
Sait Talha Nisanci 2020-05-29 10:47:13 +03:00
parent a3c470b2b8
commit dec2b28d49
1 changed files with 4 additions and 4 deletions

View File

@ -287,14 +287,14 @@ PartitionList(Oid parentRelationId)
ereport(ERROR, (errmsg("\"%s\" is not a parent table", relationName)));
}
PartitionDesc partDesc = RelationGetPartitionDesc(rel);
Assert(partDesc != NULL);
Assert(rel->rd_partdesc != NULL);
int partitionCount = rel->rd_partdesc->nparts;
int partitionCount = partDesc->nparts;
for (int partitionIndex = 0; partitionIndex < partitionCount; ++partitionIndex)
{
partitionList =
lappend_oid(partitionList, rel->rd_partdesc->oids[partitionIndex]);
lappend_oid(partitionList, partDesc->oids[partitionIndex]);
}
/* keep the lock */