From: Tom Lane <tgl@sss.pgh.pa.us>
To: bryan.dicarlo@gmail.com
Cc: pgsql-bugs@lists.postgresql.org, Peter Geoghegan <pg@bowt.ie>
Subject: Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error
Date: Thu, 28 Nov 2019 13:26:33 -0500
Message-ID: <24978.1574965593@sss.pgh.pa.us> (raw)
In-Reply-To: <16140-4d29cf5390118372@postgresql.org>
References: <16140-4d29cf5390118372@postgresql.org>
PG Bug reporting form <noreply@postgresql.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bryan.dicarlo@gmail.com, pg@bowt.ie
Subject: Re: BUG #16140: View with INSERT, DO INSTEAD, and ON CONFLICT causes an error
In-Reply-To: <24978.1574965593@sss.pgh.pa.us>
References: <16140-4d29cf5390118372@postgresql.org> <24978.1574965593@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox