Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error

From: Bryan DiCarlo <bryan(dot)dicarlo(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error
Date: 2019-11-28 19:21:24
Message-ID: CAGo_416nUxAa4WAHgLn3ZCryqvM-RL7_O9QkyUFBhqn24hZ38g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks Tom,

I changed it to EXCLUDED and it's working.

Thanks again.

Cheers,

Bryan

On Thu, Nov 28, 2019, 10:26 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> > When creating an updatable "complex" view, if an ON CONFLICT clause is
> > provided, an INSERT SELECT to that view will cause "ERROR: variable not
> > found in subplan target lists". Removing the ON CONFLICT clause
> eliminates
> > the error message.
>
> I believe the problem is that you wrote the ON CONFLICT clause
> incorrectly:
>
> > ON CONFLICT (slo_id, time_window, tags) DO UPDATE SET value = NEW.value
>
> You should have written "EXCLUDED.value" not "NEW.value". There is
> a bug here, but it's that the parser accepted this rule. I'm guessing
> that the parsing logic for ON CONFLICT didn't consider the possibility
> that NEW and OLD for a rule would already be in the range table.
>
> regards, tom lane
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomas Vondra 2019-11-28 21:40:30 Re: Failed assertion clauses != NIL
Previous Message Tom Lane 2019-11-28 18:26:33 Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error