Hi.
While reviewing ON CONFLICT DO SELECT, I found an elog(ERROR) behavior, which
may a bug. It is also unclear whether ``INSERT tableoid::regclass`` is
expected to
return "hat_data" or "hats". The following test case is copied from
src/test/regress/sql/rules.sql
----------
DROP TABLE IF EXISTS hats, hat_data;
CREATE TABLE hats (hat_name char(10) primary key, hat_color char(10));
CREATE TABLE hat_data (hat_name char(10), hat_color char(10));
CREATE UNIQUE INDEX hat_data_unique_idx on hat_data (hat_name COLLATE
"C" bpchar_pattern_ops);
CREATE RULE hat_upsert AS ON INSERT TO hats
DO INSTEAD
INSERT INTO hat_data VALUES (
NEW.hat_name,
NEW.hat_color)
ON CONFLICT (hat_name)
DO UPDATE
SET hat_name = hat_data.hat_name, hat_color = excluded.hat_color
WHERE excluded.hat_color <> 'forbidden' AND hat_data.* != excluded.*
RETURNING *;
INSERT INTO hats VALUES ('h8', 'black') RETURNING *, tableoid::regclass;
ERROR: could not find replacement targetlist entry for attno -6
--
jian
https://www.enterprisedb.com/