mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Reject opclass options in ON CONFLICT clause
It's as pointless as ASC/DESC and NULLS FIRST/LAST are, so reject all of them in the same way. While at it, normalize the others' error messages to have less translatable strings. Add tests for these errors. Noticed while reviewing recent INSERT ON CONFLICT patches. Author: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/202511271516.oiefpvn3z27m@alvherre.pgsql
This commit is contained in:
@@ -2,6 +2,19 @@
|
||||
-- insert...on conflict do unique index inference
|
||||
--
|
||||
create table insertconflicttest(key int4, fruit text);
|
||||
-- invalid clauses
|
||||
insert into insertconflicttest values (1) on conflict (key int4_ops (fillfactor=10)) do nothing;
|
||||
ERROR: operator class options are not allowed in ON CONFLICT clause
|
||||
LINE 1: ...rt into insertconflicttest values (1) on conflict (key int4_...
|
||||
^
|
||||
insert into insertconflicttest values (1) on conflict (key asc) do nothing;
|
||||
ERROR: ASC/DESC is not allowed in ON CONFLICT clause
|
||||
LINE 1: ...rt into insertconflicttest values (1) on conflict (key asc) ...
|
||||
^
|
||||
insert into insertconflicttest values (1) on conflict (key nulls last) do nothing;
|
||||
ERROR: NULLS FIRST/LAST is not allowed in ON CONFLICT clause
|
||||
LINE 1: ...rt into insertconflicttest values (1) on conflict (key nulls...
|
||||
^
|
||||
-- These things should work through a view, as well
|
||||
create view insertconflictview as select * from insertconflicttest;
|
||||
--
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
--
|
||||
create table insertconflicttest(key int4, fruit text);
|
||||
|
||||
-- invalid clauses
|
||||
insert into insertconflicttest values (1) on conflict (key int4_ops (fillfactor=10)) do nothing;
|
||||
insert into insertconflicttest values (1) on conflict (key asc) do nothing;
|
||||
insert into insertconflicttest values (1) on conflict (key nulls last) do nothing;
|
||||
|
||||
-- These things should work through a view, as well
|
||||
create view insertconflictview as select * from insertconflicttest;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user