On Thu, 2023-07-13 at 18:01 +0100, Dean Rasheed wrote: > For some use cases, I can imagine allowing OLD/NEW.colname would mean > you wouldn't need pg_merge_action() (if the column was NOT NULL), so > I > think the features should work well together.
For use cases where a user could do it either way, which would you expect to be the "typical" way (assuming we supported the new/old)? MERGE ... RETURNING pg_merge_action(), id, val; or MERGE ... RETURNING id, OLD.val, NEW.val; ? I am still bothered that pg_merge_action() is so context-sensitive. "SELECT pg_merge_action()" by itself doesn't make any sense, but it's allowed in the v8 patch. We could make that a runtime error, which would be better, but it feels like it's structurally wrong. This is not an objection, but it's just making me think harder about alternatives. Maybe instead of a function it could be a special table reference like: MERGE ... RETURNING MERGE.action, MERGE.action_number, id, val? Regards, Jeff Davis