mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
Fix handling of Result nodes below Sort nodes in ConstraintAwareAppend
With PG 15 Result nodes can appear between Sort nodes and DecompressChunk when postgres tries to adjust the targetlist.
This commit is contained in:
parent
9c7ae3e8a9
commit
e302aa2ae9
2
.unreleased/bugfix_5742
Normal file
2
.unreleased/bugfix_5742
Normal file
@ -0,0 +1,2 @@
|
||||
Fixes: #5742 Fix Result node handling with ConstraintAwareAppend on compressed chunks
|
||||
Thanks: @xvaara for reporting an issue with Result node handling in ConstraintAwareAppend
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "compat/compat.h"
|
||||
#include "constraint_aware_append.h"
|
||||
#include "debug_assert.h"
|
||||
#include "nodes/chunk_append/transform.h"
|
||||
#include "guc.h"
|
||||
#include "utils.h"
|
||||
@ -64,8 +65,8 @@ get_plans_for_exclusion(Plan *plan)
|
||||
{
|
||||
case T_Result:
|
||||
case T_Sort:
|
||||
Assert(plan->lefttree != NULL && plan->righttree == NULL);
|
||||
return plan->lefttree;
|
||||
Ensure(plan->lefttree != NULL, "subplan is null");
|
||||
return get_plans_for_exclusion(plan->lefttree);
|
||||
|
||||
default:
|
||||
return plan;
|
||||
|
28
tsl/test/shared/expected/constraint_aware_append.out
Normal file
28
tsl/test/shared/expected/constraint_aware_append.out
Normal file
@ -0,0 +1,28 @@
|
||||
-- This file and its contents are licensed under the Timescale License.
|
||||
-- Please see the included NOTICE for copyright information and
|
||||
-- LICENSE-TIMESCALE for a copy of the license.
|
||||
-- test handling of ConstraintAwareAppend -> Sort -> Result -> Scan
|
||||
-- issue 5739
|
||||
CREATE TABLE ca_append_result(time timestamptz NULL, device text, value float);
|
||||
SELECT table_name FROM create_hypertable('ca_append_result', 'time');
|
||||
NOTICE: adding not-null constraint to column "time"
|
||||
table_name
|
||||
ca_append_result
|
||||
(1 row)
|
||||
|
||||
ALTER TABLE ca_append_result SET (timescaledb.compress);
|
||||
INSERT INTO ca_append_result SELECT '2000-01-03','d1',0.3;
|
||||
SELECT count(compress_chunk(ch)) AS compressed FROM show_chunks('ca_append_result') ch;
|
||||
compressed
|
||||
1
|
||||
(1 row)
|
||||
|
||||
INSERT INTO ca_append_result SELECT '2000-01-13','d1',0.6;
|
||||
SET enable_seqscan TO FALSE;
|
||||
SELECT time_bucket('20d',time) AS day from ca_append_result WHERE time > '1900-01-01'::text::timestamp GROUP BY day;
|
||||
day
|
||||
Sun Jan 02 16:00:00 2000 PST
|
||||
(1 row)
|
||||
|
||||
RESET enable_seqscan;
|
||||
DROP TABLE ca_append_result;
|
@ -2,6 +2,7 @@ set(TEST_FILES_SHARED
|
||||
cagg_compression.sql
|
||||
classify_relation.sql
|
||||
constify_timestamptz_op_interval.sql
|
||||
constraint_aware_append.sql
|
||||
constraint_exclusion_prepared.sql
|
||||
decompress_placeholdervar.sql
|
||||
dist_chunk.sql
|
||||
|
20
tsl/test/shared/sql/constraint_aware_append.sql
Normal file
20
tsl/test/shared/sql/constraint_aware_append.sql
Normal file
@ -0,0 +1,20 @@
|
||||
-- This file and its contents are licensed under the Timescale License.
|
||||
-- Please see the included NOTICE for copyright information and
|
||||
-- LICENSE-TIMESCALE for a copy of the license.
|
||||
|
||||
-- test handling of ConstraintAwareAppend -> Sort -> Result -> Scan
|
||||
-- issue 5739
|
||||
CREATE TABLE ca_append_result(time timestamptz NULL, device text, value float);
|
||||
SELECT table_name FROM create_hypertable('ca_append_result', 'time');
|
||||
ALTER TABLE ca_append_result SET (timescaledb.compress);
|
||||
|
||||
INSERT INTO ca_append_result SELECT '2000-01-03','d1',0.3;
|
||||
SELECT count(compress_chunk(ch)) AS compressed FROM show_chunks('ca_append_result') ch;
|
||||
INSERT INTO ca_append_result SELECT '2000-01-13','d1',0.6;
|
||||
|
||||
SET enable_seqscan TO FALSE;
|
||||
SELECT time_bucket('20d',time) AS day from ca_append_result WHERE time > '1900-01-01'::text::timestamp GROUP BY day;
|
||||
RESET enable_seqscan;
|
||||
|
||||
DROP TABLE ca_append_result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user