public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tender Wang <[email protected]>
To: SATYANARAYANA NARLAPURAM <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Richard Guo <[email protected]>
Subject: Re: Bug: var_is_nonnullable() gives wrong results for old/new in RETURNING
Date: Fri, 10 Apr 2026 09:29:48 +0800
Message-ID: <CAHewXN=9mf6NCeHE=7jUVhM_Ur=oW8R7hgfQwcvyWCSLC8VERw@mail.gmail.com> (raw)
In-Reply-To: <CAHg+QDfaAipL6YzOq2H=gAhKBbcUTYmfbAv+W1zueOfRKH43FQ@mail.gmail.com>
References: <CAHg+QDfaAipL6YzOq2H=gAhKBbcUTYmfbAv+W1zueOfRKH43FQ@mail.gmail.com>
SATYANARAYANA NARLAPURAM <[email protected]> 于2026年4月10日周五 02:43写道:
>
> Hi hackers,
>
> It appears the optimizer incorrectly simplifies old.<col> IS NULL to FALSE in RETURNING clauses when the underlying column has a NOT NULL constraint.
>
> The issue is that var_is_nonnullable() in clauses.c doesn't check Var.varreturningtype. It sees a NOT NULL column and concludes the Var can never be NULL.
> But this assumption is wrong for old.* and new.* references. Because the old tuple doesn't exist on INSERT, and the new tuple doesn't exist on DELETE
> I am not super familiar with this area, so I attempted to fix this as in the patch attached.
Yes, the current var_is_nonnullable() ignores this case. The
attached patch seems ok to me.
Add Richard to the cc list. He may know more about this.
--
Thanks,
Tender Wang
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Bug: var_is_nonnullable() gives wrong results for old/new in RETURNING
In-Reply-To: <CAHewXN=9mf6NCeHE=7jUVhM_Ur=oW8R7hgfQwcvyWCSLC8VERw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox