mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-19 20:24:46 +08:00
Fix unused sort in dimension partition lookup
Dimension partition lookups use binary search to find the partition to place a chunk in. However, in the code, an array of partitions might not be sorted because the sort happened on a copy of the array instead of the main array. This change fixes the issue to ensure the array is sorted and binary search works properly.
This commit is contained in:
parent
f862212c8c
commit
40a6c4cf87
@ -181,9 +181,12 @@ ts_dimension_partition_info_get(int32 dimension_id)
|
|||||||
|
|
||||||
dpi = palloc0(sizeof(DimensionPartitionInfo));
|
dpi = palloc0(sizeof(DimensionPartitionInfo));
|
||||||
dpi->num_partitions = count;
|
dpi->num_partitions = count;
|
||||||
|
|
||||||
|
/* Reallocate the partitions array to use the exact size and save some
|
||||||
|
* memory */
|
||||||
dpi->partitions = palloc0(sizeof(DimensionPartition *) * count);
|
dpi->partitions = palloc0(sizeof(DimensionPartition *) * count);
|
||||||
memcpy(dpi->partitions, partitions, sizeof(DimensionPartition *) * count);
|
memcpy(dpi->partitions, partitions, sizeof(DimensionPartition *) * count);
|
||||||
qsort(partitions, count, sizeof(DimensionPartition *), dimpart_cmp);
|
qsort(dpi->partitions, count, sizeof(DimensionPartition *), dimpart_cmp);
|
||||||
pfree(partitions);
|
pfree(partitions);
|
||||||
|
|
||||||
return dpi;
|
return dpi;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user