Skip to content

Commit 8b84412

Browse files
committed
Fix wrong allocation size for chunk column stats data
Triggers an AddressSanitizer failure.
1 parent fd3c049 commit 8b84412

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/ts_catalog/chunk_column_stats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef struct ChunkRangeSpace
2424
} ChunkRangeSpace;
2525

2626
#define CHUNKRANGESPACE_SIZE(num_columns) \
27-
(sizeof(ChunkRangeSpace) + (sizeof(NameData) * (num_columns)))
27+
(sizeof(ChunkRangeSpace) + (sizeof(FormData_chunk_column_stats) * (num_columns)))
2828

2929
extern ChunkRangeSpace *ts_chunk_column_stats_range_space_scan(int32 hypertable_id, Oid ht_reloid,
3030
MemoryContext mctx);

tsl/test/expected/chunk_column_stats.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,3 +775,17 @@ SELECT * FROM attno WHERE id = 1 AND start > '2025-02-02T11:53:28Z'::date ORDER
775775
1 | Thu Jan 01 00:01:00 2026 PST
776776
1 | Thu Jan 01 00:06:00 2026 PST
777777

778+
-- Test for wrong allocation size of chunk stats storage
779+
CREATE TABLE sensor_readings(measured_at timestamptz NOT NULL, temperature int, humidity int);
780+
SELECT create_hypertable('sensor_readings', 'measured_at');
781+
create_hypertable
782+
-------------------------------
783+
(10,public,sensor_readings,t)
784+
785+
SELECT enable_chunk_skipping('sensor_readings', 'temperature');
786+
enable_chunk_skipping
787+
-----------------------
788+
(17,t)
789+
790+
RESET timescaledb.enable_chunk_skipping;
791+
RESET timescaledb.enable_chunk_skipping;

tsl/test/sql/chunk_column_stats.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,12 @@ SELECT count(compress_chunk(ch)) FROM show_chunks('attno') ch;
351351

352352
SELECT * FROM attno WHERE id = 1 AND start > '2025-02-02T11:53:28Z'::date ORDER BY start;
353353

354+
355+
-- Test for wrong allocation size of chunk stats storage
356+
CREATE TABLE sensor_readings(measured_at timestamptz NOT NULL, temperature int, humidity int);
357+
SELECT create_hypertable('sensor_readings', 'measured_at');
358+
SELECT enable_chunk_skipping('sensor_readings', 'temperature');
359+
RESET timescaledb.enable_chunk_skipping;
360+
361+
362+
RESET timescaledb.enable_chunk_skipping;

0 commit comments

Comments
 (0)