On 2017/12/01 11:27, Simon Riggs wrote: > On 24 November 2017 at 13:45, Amit Langote > <langote_amit...@lab.ntt.co.jp> wrote: > >>> Why? There is no caller that needs information. >> >> It is to be used if and when ExecInsert() calls >> ExecCheckIndexConstraints() in the code path to handle ON CONFLICT DO >> NOTHING that we're intending to support in some cases. Note that it will >> only check conflicts for the individual leaf partitions using whatever >> constraint-enforcing indexes they might have. > > So we should have 2 patches. One for now that does DO NOTHING and > another that adds the change that depends upon Alvaro's work.
Yes, I'd think so. It won't be until the patch at [1] to add support to define UNIQUE indexes on partitioned tables is committed that we could support specifying conflict_target on partitioned tables. Even then, it would take at least some executor changes to actually make it work, but at least the planner won't complain that there are no indexes. If I try Alvaro's patch today and see what happens when conflict_target is specified, still get an error but now it's the executor: create table p (a int, b char) partition by list (a); create table p1 partition of p (b unique) for values in (1); -- on HEAD (before applying the patch on this thread) insert into p values (1) on conflict (a) do nothing; ERROR: ON CONFLICT clause is not supported with partitioned tables -- after applying the patch on this thread (no indexes yet) insert into p values (1) on conflict (a) do nothing; ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification -- after applying Alvaro's patch at [1] create unique index on p (a); -- but, the executor support is missing, so... insert into p values (1) on conflict (a) do nothing; ERROR: unexpected failure to find arbiter index I will report this on that thread and we can discuss the executor changes that would be need to make it work there. Thanks, Amit [1] https://commitfest.postgresql.org/16/1365/