hacky_partitioning_hotfix.diff
text/x-patch
Filename: hacky_partitioning_hotfix.diff
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/catalog/partition.c | 10 | 2 |
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 219d380..119a41d 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -950,7 +950,8 @@ RelationGetPartitionDispatchInfo(Relation rel, int lockmode, *parted_rels; ListCell *lc; int i, - k; + k, + children_so_far = 0; /* * Lock partitions and make a list of the partitioned ones to prepare @@ -1026,11 +1027,18 @@ RelationGetPartitionDispatchInfo(Relation rel, int lockmode, * We can assign indexes this way because of the way * parted_rels has been generated. */ - pd[i]->indexes[j] = -(i + 1 + m); + pd[i]->indexes[j] = -(1 + m + children_so_far); m++; } } i++; + + /* + * Children of this parent are placed + * after all children of all previous parents, + * so we have to take this into account. + */ + children_so_far += partdesc->nparts; } return pd;