mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 10:11:29 +08:00
Fix joins in RETURNING
To make it work, it is enough to properly pass the parent of the PlanState while initializing the projection in RETURNING clause.
This commit is contained in:
parent
1fa8373931
commit
ae6773fca6
@ -20,6 +20,7 @@ accidentally triggering the load of a previous DB version.**
|
||||
* #4575 Fix use of `get_partition_hash` and `get_partition_for_key` inside an IMMUTABLE function
|
||||
* #4611 Fix a potential OOM when loading large data sets into a hypertable
|
||||
* #4646 Fix time_bucket_ng origin handling
|
||||
* #4647 Fix the error "SubPlan found with no parent plan" that occurred if using joins in RETURNING clause.
|
||||
|
||||
**Thanks**
|
||||
@AlmiS for reporting error on `get_partition_hash` executed inside an IMMUTABLE function
|
||||
@ -28,6 +29,7 @@ accidentally triggering the load of a previous DB version.**
|
||||
@michaelkitson for reporting permission errors using default privileges on Continuous Aggregates
|
||||
@ninjaltd and @mrksngl for reporting a potential OOM when loading large data sets into a hypertable
|
||||
@ssmoss for reporting an issue with time_bucket_ng origin handling
|
||||
@mwahlhuetter for reporting error in joins in RETURNING clause
|
||||
|
||||
## 2.7.2 (2022-07-26)
|
||||
|
||||
|
@ -160,7 +160,7 @@ get_adjusted_projection_info_returning(ProjectionInfo *orig, List *returning_cla
|
||||
return ExecBuildProjectionInfo(returning_clauses,
|
||||
orig->pi_exprContext,
|
||||
orig->pi_state.resultslot,
|
||||
NULL,
|
||||
orig->pi_state.parent,
|
||||
chunk_desc);
|
||||
}
|
||||
|
||||
|
58
test/expected/insert_returning.out
Normal file
58
test/expected/insert_returning.out
Normal file
@ -0,0 +1,58 @@
|
||||
-- This file and its contents are licensed under the Apache License 2.0.
|
||||
-- Please see the included NOTICE for copyright information and
|
||||
-- LICENSE-APACHE for a copy of the license.
|
||||
CREATE TABLE standard_table (
|
||||
standard_id integer PRIMARY KEY,
|
||||
name text not null
|
||||
);
|
||||
CREATE TABLE hypertable (
|
||||
time timestamptz not null,
|
||||
name text not null,
|
||||
standard_id integer not null
|
||||
);
|
||||
select * from create_hypertable('hypertable', 'time');
|
||||
hypertable_id | schema_name | table_name | created
|
||||
---------------+-------------+------------+---------
|
||||
1 | public | hypertable | t
|
||||
(1 row)
|
||||
|
||||
INSERT INTO standard_table (standard_id, name)
|
||||
VALUES (1, 'standard_1');
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2021-01-01 01:01:01+00', 'hypertable_1', 1);
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2022-02-02 02:02:02+00', 'hypertable_2', 1)
|
||||
RETURNING *, EXISTS (
|
||||
SELECT *
|
||||
FROM standard_table
|
||||
WHERE standard_table.standard_id = hypertable.standard_id
|
||||
);
|
||||
time | name | standard_id | exists
|
||||
------------------------------+--------------+-------------+--------
|
||||
Tue Feb 01 18:02:02 2022 PST | hypertable_2 | 1 | t
|
||||
(1 row)
|
||||
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2023-03-03 03:03:03+00', 'hypertable_3', 1)
|
||||
RETURNING *, EXISTS (
|
||||
SELECT *
|
||||
FROM standard_table
|
||||
WHERE standard_table.standard_id = hypertable.standard_id
|
||||
);
|
||||
time | name | standard_id | exists
|
||||
------------------------------+--------------+-------------+--------
|
||||
Thu Mar 02 19:03:03 2023 PST | hypertable_3 | 1 | t
|
||||
(1 row)
|
||||
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2024-04-04 04:04:04+00', 'hypertable_4', 2)
|
||||
RETURNING *, EXISTS (
|
||||
SELECT *
|
||||
FROM standard_table
|
||||
WHERE standard_table.standard_id = hypertable.standard_id
|
||||
);
|
||||
time | name | standard_id | exists
|
||||
------------------------------+--------------+-------------+--------
|
||||
Wed Apr 03 21:04:04 2024 PDT | hypertable_4 | 2 | f
|
||||
(1 row)
|
||||
|
@ -26,6 +26,7 @@ set(TEST_FILES
|
||||
information_views.sql
|
||||
insert_many.sql
|
||||
insert_single.sql
|
||||
insert_returning.sql
|
||||
lateral.sql
|
||||
misc.sql
|
||||
parallel.sql
|
||||
|
46
test/sql/insert_returning.sql
Normal file
46
test/sql/insert_returning.sql
Normal file
@ -0,0 +1,46 @@
|
||||
-- This file and its contents are licensed under the Apache License 2.0.
|
||||
-- Please see the included NOTICE for copyright information and
|
||||
-- LICENSE-APACHE for a copy of the license.
|
||||
|
||||
CREATE TABLE standard_table (
|
||||
standard_id integer PRIMARY KEY,
|
||||
name text not null
|
||||
);
|
||||
|
||||
CREATE TABLE hypertable (
|
||||
time timestamptz not null,
|
||||
name text not null,
|
||||
standard_id integer not null
|
||||
);
|
||||
|
||||
select * from create_hypertable('hypertable', 'time');
|
||||
|
||||
INSERT INTO standard_table (standard_id, name)
|
||||
VALUES (1, 'standard_1');
|
||||
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2021-01-01 01:01:01+00', 'hypertable_1', 1);
|
||||
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2022-02-02 02:02:02+00', 'hypertable_2', 1)
|
||||
RETURNING *, EXISTS (
|
||||
SELECT *
|
||||
FROM standard_table
|
||||
WHERE standard_table.standard_id = hypertable.standard_id
|
||||
);
|
||||
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2023-03-03 03:03:03+00', 'hypertable_3', 1)
|
||||
RETURNING *, EXISTS (
|
||||
SELECT *
|
||||
FROM standard_table
|
||||
WHERE standard_table.standard_id = hypertable.standard_id
|
||||
);
|
||||
|
||||
INSERT INTO hypertable (time, name, standard_id)
|
||||
VALUES ('2024-04-04 04:04:04+00', 'hypertable_4', 2)
|
||||
RETURNING *, EXISTS (
|
||||
SELECT *
|
||||
FROM standard_table
|
||||
WHERE standard_table.standard_id = hypertable.standard_id
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user