Re: Bug: var_is_nonnullable() gives wrong results for old/new in RETURNING

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Tender Wang <tndrwang@gmail.com>
Cc: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-10T06:58:31Z
Lists: pgsql-hackers
On Fri, Apr 10, 2026 at 2:48 PM Richard Guo <guofenglinux@gmail.com> wrote:
> The patch also LGTM.  I also checked if has_notnull_forced_var() has
> the same issue, but it doesn't: Vars with non-default returning type
> only appear in the RETURNING clause, so they never show up in WHERE/ON
> clauses.

I pushed the patch after a bit cosmetic tweaks.  I also decided to put
the test cases in returning.sql, which I think is a better place.

Thanks for the report and the patch.

- Richard



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix var_is_nonnullable() to account for varreturningtype