On Thu, 13 Jul 2023 at 17:01, Jeff Davis <pg...@j-davis.com> wrote: > > MERGE can end up combining old and new values in a way that doesn't > happen with INSERT/UPDATE/DELETE. For instance, a "MERGE ... RETURNING > id" would return a mix of NEW.id (for INSERT/UPDATE actions) and OLD.id > (for DELETE actions). >
Right, but allowing OLD/NEW.colname in the RETURNING list would remove that complication, and it shouldn't change how a bare colname reference behaves. > The pg_merge_action() can differentiate the old and new values, but > it's a bit more awkward. > 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. Regards, Dean