From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Peter Geoghegan <pg(at)heroku(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: ON CONFLICT issues around whole row vars, |
Date: | 2015-09-20 00:11:09 |
Message-ID: | 20150920001109.GA3844@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
To recap for other readers: There's a problem with ON CONFLICT when the
SET or ON CONFLICT ... WHERE clause references excluded.* (i.e. as a
whole row var). The problem is that setrefs.c in
fix_join_expr_mutator() currently won't find a matching entry in the
indexed tlist and thus error out with
elog(ERROR, "variable not found in subplan target lists");
The reason is that the targetlist we build the index list on just
contains the attributes in excluded.*.
Peter's patch upthread fixes this by pulling expressions from
onConflictSet/Where into the targetlist. I disliked this - much less
than initially - a bit because that seems a bit crufty given that we're
not actually getting data from a child node. This is different to
RETURNING where the targetlist massaging is actually important to get
the data up the tree.
An actually trivial, although not all that pretty, fix is to simply
accept wholerow references in fix_join_expr_mutator(), even if not in
the targetlist. As far as I can see the problem right now really can
only be hit for whole row references.
A variant of the second approach is to have a fix_onconflict_expr()
mutator that has such special handler.
Any opinions on either approach?
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-09-20 00:15:11 | Update count mismatch - internal error |
Previous Message | Tom Lane | 2015-09-19 14:46:08 | Re: TABLESAMPLE patch is really in pretty sad shape |