timescaledb/test/expected/insert_returning.out
Alexander Kuzmenkov ae6773fca6 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.
2022-08-31 14:14:34 +03:00

59 lines
2.0 KiB
Plaintext

-- 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)