|
| 1 | +-- This file and its contents are licensed under the Timescale License. |
| 2 | +-- Please see the included NOTICE for copyright information and |
| 3 | +-- LICENSE-TIMESCALE for a copy of the license. |
| 4 | + |
| 5 | +-- Tests for body buffer overflow in columnar_result_set_row with |
| 6 | +-- DT_ArrowText type. When vectorized text functions produce large |
| 7 | +-- results, the body buffer growth computation could overflow int32, |
| 8 | +-- and the total buffer size can exceed MaxAllocSize. |
| 9 | + |
| 10 | +set max_parallel_workers_per_gather to 0; |
| 11 | + |
| 12 | +create table t_textoverflow (time timestamptz, a text); |
| 13 | + |
| 14 | +select table_name from create_hypertable('t_textoverflow', 'time', |
| 15 | + chunk_time_interval => interval '1 year'); |
| 16 | + |
| 17 | +insert into t_textoverflow |
| 18 | +select '2020-01-01'::timestamptz + i * interval '1 hour', |
| 19 | + repeat('x', 100000) |
| 20 | +from generate_series(1, 10) i; |
| 21 | + |
| 22 | +alter table t_textoverflow set ( |
| 23 | + timescaledb.compress, |
| 24 | + timescaledb.compress_orderby = 'time' |
| 25 | +); |
| 26 | +select count(compress_chunk(c)) from show_chunks('t_textoverflow') c; |
| 27 | + |
| 28 | +set timescaledb.debug_require_vector_agg to 'require'; |
| 29 | +select sum(length(a || a)) from t_textoverflow; |
| 30 | +reset timescaledb.debug_require_vector_agg; |
| 31 | + |
| 32 | +drop table t_textoverflow cascade; |
| 33 | + |
| 34 | +-- When the actual data doesn't fit into MaxAllocSize, produce an error message |
| 35 | +-- instead of erroring out in palloc. |
| 36 | +create table t_text_overflow (time timestamptz not null, text_col text not null); |
| 37 | + |
| 38 | +select table_name from create_hypertable('t_text_overflow', 'time', |
| 39 | + chunk_time_interval => interval '1 year'); |
| 40 | + |
| 41 | +insert into t_text_overflow |
| 42 | +select '2020-01-01'::timestamptz + i * interval '1 hour', 'a' |
| 43 | +from generate_series(1, 1000) i; |
| 44 | + |
| 45 | +alter table t_text_overflow set ( |
| 46 | + timescaledb.compress, |
| 47 | + timescaledb.compress_orderby = 'time' |
| 48 | +); |
| 49 | +select count(compress_chunk(c)) from show_chunks('t_text_overflow') c; |
| 50 | + |
| 51 | +set timescaledb.debug_require_vector_agg to 'require'; |
| 52 | +select count(text_col || repeat('x', 2000000)) from t_text_overflow; |
| 53 | +reset timescaledb.debug_require_vector_agg; |
| 54 | + |
| 55 | +drop table t_text_overflow cascade; |
| 56 | + |
| 57 | +reset max_parallel_workers_per_gather; |
0 commit comments