Re: Minor ON CONFLICT related fixes - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Minor ON CONFLICT related fixes
Date
Msg-id CAM3SWZSVo+hX3Nhy2woE+peXyC06Cvt1KfrZ1OBqRi3oBZ_hgA@mail.gmail.com
Whole thread Raw
In response to Re: Minor ON CONFLICT related fixes  (Peter Geoghegan <pg@heroku.com>)
Responses Re: Minor ON CONFLICT related fixes  (Peter Geoghegan <pg@heroku.com>)
List pgsql-hackers
On Tue, May 12, 2015 at 4:23 PM, Peter Geoghegan <pg@heroku.com> wrote:
> Rebased version of patch is attached.

FYI, I found an unrelated bug within ruleutils.c (looks like the
targetlist kludge in set_deparse_planstate() isn't sufficiently
general):

postgres=# explain insert into upsert as u values('Bat', 'Bar') on
conflict (key) do update set val = excluded.val where exists (select 1
from upsert ii where ii.key = excluded.key);
ERROR:  XX000: bogus varno: 65000
LOCATION:  get_variable, ruleutils.c:5916

Obviously Vars of varno INNER_VAR are not expected here -- the subplan
makes set_deparse_planstate() not prepare get_variable() in the same
way that it prepares similar though simpler cases (e.g. no
subquery/subplan).

I don't have any bright ideas about how to fix this offhand. I believe
in principle that we ought to be able to fish through parent planstate
within set_deparse_planstate(), just in case it is called under these
circumstances, but that's pretty ugly, and is usually going to be
unnecessary. Doesn't look like there is a good way to delay the work
till get_variable() can see what looks like this case, either.
-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: pg_audit documentation fixes
Next
From: Magnus Hagander
Date:
Subject: Re: pg_audit documentation fixes