On Tue, May 12, 2015 at 4:23 PM, Peter Geoghegan <p...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers