[PATCH v1] [BUG #19516] Skip whole-row projection shortcut for OLD/NEW returning type

Marko Grujic <marko.grujic@enterprisedb.com>

From: Marko Grujic <marko.grujic@enterprisedb.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Marko Grujic <markoog@gmail.com>
Date: 2026-06-10T10:48:20Z
Lists: pgsql-hackers

Attachments

Hi, submitting a patch for bug #19516 (held in moderation queue atm).

Looks like the root cause is that the shortcut taken
in ParseComplexProjection
loses the `varreturningtype` flag, causing it to default to
`VAR_RETURNING_DEFAULT`.

Consequently, the default RETURNING behavior is applied, which is strictly
wrong
when a user typed (old).col on INSERT/UPDATE or (new).col on DELETE.

To fix this simply skip the shortcut when varreturningtype is set to
VAR_RETURNING_OLD/VAR_RETURNING_NEW.

Also added tests that exercise this.

Thanks,
Marko

Commits

  1. Fix parsing of parenthesised OLD/NEW in RETURNING list.