1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00

Fix deparsing of ON CONFLICT arbiter WHERE clauses.

The parser doesn't allow qualification of column names appearing in
these clauses, but ruleutils.c would sometimes qualify them, leading
to dump/reload failures.  Per bug #13891 from Onder Kalaci.

(In passing, make stanzas in ruleutils.c that save/restore varprefix
more consistent.)

Peter Geoghegan
This commit is contained in:
Tom Lane
2016-02-07 14:57:24 -05:00
parent 1d76c97250
commit cc2ca9319a
2 changed files with 18 additions and 5 deletions

View File

@@ -2846,7 +2846,7 @@ SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename;
CREATE RULE hat_nosert AS +
ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
VALUES (new.hat_name, new.hat_color) ON CONFLICT(hat_name COLLATE "C" bpchar_pattern_ops)+
WHERE (hat_data.hat_color = 'green'::bpchar) DO NOTHING +
WHERE (hat_color = 'green'::bpchar) DO NOTHING +
RETURNING hat_data.hat_name, +
hat_data.hat_color;
(1 row)
@@ -2871,7 +2871,7 @@ SELECT tablename, rulename, definition FROM pg_rules
hats | hat_nosert | CREATE RULE hat_nosert AS +
| | ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
| | VALUES (new.hat_name, new.hat_color) ON CONFLICT(hat_name COLLATE "C" bpchar_pattern_ops)+
| | WHERE (hat_data.hat_color = 'green'::bpchar) DO NOTHING +
| | WHERE (hat_color = 'green'::bpchar) DO NOTHING +
| | RETURNING hat_data.hat_name, +
| | hat_data.hat_color;
(1 row)