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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers