Re: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition

From: Andres Freund <andres(at)anarazel(dot)de>
To: Andy S <gatekeeper(dot)mail(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16714: INSERT ON CONFLICT DO UPDATE fails to infer constraint if it's not at top-level partition
Date: 2020-11-19 00:06:56
Message-ID: 20201119000656.4uucddwfxb3u3veq@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2020-11-19 02:49:20 +0300, Andy S wrote:
> Oh! What a gem I mined in sources:
>
> branch: REL_11_STABLE
> src/backend/executor/nodeModifyTable.c:
> * BEFORE ROW INSERT Triggers.
> *
> * Note: We fire BEFORE ROW TRIGGERS for every attempted insertion
> in an
> * INSERT ... ON CONFLICT statement. We cannot check for constraint
> * violations before firing these triggers, because they can change
> the
> * values to insert. Also, they can run arbitrary user-defined
> code with
> * side-effects that we can't cancel by just not inserting the
> tuple.
> */
>
> Still not the place where ON CONFLICT could be validated on per-row
> basis?

On conflict arbiter determination happens much earlier - and that can't,
as I have explained earlier, really be changed. We need to know which
index etc this applies to during parse analysis, not during execution
time. This happens as part of transformOnConflictClause() called from
transformInsertStmt().

Greetings,

Andres Freund

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Vik Fearing 2020-11-19 00:15:09 Re: BUG #16726: Invalid input syntax is not a useful error message
Previous Message Tom Lane 2020-11-19 00:02:34 Re: BUG #16722: PG hanging on COPY when table has close to 2^32 toasts in the table.