diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 75329b3624..da962c4375 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -975,7 +975,7 @@ get_partition_dispatch_recurse(Relation rel, Relation parent, * array element belongs to a leaf partition or a subpartitioned table. * For leaf partitions we store the 0-based index into *leaf_part_oids, * and for sub-partitioned tables we store a negative version of the - * 1-based index into the *pds list. When searching, if we see a negative + * 0-based index into the *pds list. When searching, if we see a negative * value, the search must continue in the corresponding sub-partition; * otherwise, we've identified the correct partition. */ @@ -986,8 +986,8 @@ get_partition_dispatch_recurse(Relation rel, Relation parent, if (get_rel_relkind(partrelid) != RELKIND_PARTITIONED_TABLE) { + pd->indexes[i] = list_length(*leaf_part_oids); *leaf_part_oids = lappend_oid(*leaf_part_oids, partrelid); - pd->indexes[i] = list_length(*leaf_part_oids) - 1; } else {