File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -289,7 +289,10 @@ tsl_compact_chunk(PG_FUNCTION_ARGS)
289289 }
290290
291291 int max_batches = PG_GETARG_INT32 (1 );
292- Assert (max_batches >= 0 );
292+ if (max_batches < 0 )
293+ ereport (ERROR ,
294+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
295+ errmsg ("max_batches must be greater than or equal to 0" )));
293296
294297 uncompressed_relid = compact_chunk_impl (chunk , max_batches );
295298
Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ SELECT DISTINCT _timescaledb_functions.chunk_status_text(chunk) FROM show_chunks
115115-------------------
116116 {COMPRESSED}
117117
118+ -- compact_chunk with negative max_batches must fail
119+ \set ON_ERROR_STOP 0
120+ SELECT _timescaledb_functions.compact_chunk(chunk, -1) FROM show_chunks('metrics') chunk;
121+ ERROR: max_batches must be greater than or equal to 0
122+ \set ON_ERROR_STOP 1
118123-- compact an uncompressed chunk
119124-- Create a new uncompressed chunk for a different time range by
120125-- inserting with direct compress insert disabled.
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ ORDER BY _ts_meta_min_1;
7676-- Status should not contain UNORDERED flag
7777SELECT DISTINCT _timescaledb_functions .chunk_status_text (chunk) FROM show_chunks(' metrics' ) chunk;
7878
79+ -- compact_chunk with negative max_batches must fail
80+ \set ON_ERROR_STOP 0
81+ SELECT _timescaledb_functions .compact_chunk (chunk, - 1 ) FROM show_chunks(' metrics' ) chunk;
82+ \set ON_ERROR_STOP 1
83+
7984-- compact an uncompressed chunk
8085-- Create a new uncompressed chunk for a different time range by
8186-- inserting with direct compress insert disabled.
You can’t perform that action at this time.
0 commit comments