INSERT INTO hats
SELECT * FROM data
RETURNING *;
+ hat_name | hat_color
+------------+------------
+ h8 | green
+ h9 | blue
+(2 rows)
+
EXPLAIN (nodes off, costs off) WITH data(hat_name, hat_color) AS (
VALUES ('h8', 'green'),
('h9', 'blue'),
INSERT INTO hats
SELECT * FROM data
RETURNING *;
- QUERY PLAN
-----------------------------------------------------------------------
+ QUERY PLAN
+-------------------------------------------------------------------------------------------------------
Remote Subquery Scan on all
-> Insert on hat_data
Conflict Resolution: UPDATE
Conflict Arbiter Indexes: hat_data_unique_idx
- Conflict Filter: (excluded.hat_color <> 'forbidden'::bpchar)
+ Conflict Filter: ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*))
CTE data
-> Values Scan on "*VALUES*"
-> Remote Subquery Scan on all
hat_name | hat_color
------------+------------
h7 | black
- h8 | white
-(2 rows)
+ h8 | green
+ h9 | blue
+(3 rows)
DROP RULE hat_upsert ON hats;
drop table hats;