| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | Sergey Shinderuk <s(dot)shinderuk(at)postgrespro(dot)ru>, pgsql-bugs(at)lists(dot)postgresql(dot)org, David Rowley <dgrowleyml(at)gmail(dot)com> |
| Subject: | Re: BUG #19412: Wrong query result with not null constraint |
| Date: | 2026-02-19 18:25:48 |
| Message-ID: | 2663915.1771525548@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> On Wed, Feb 18, 2026 at 9:03 PM Sergey Shinderuk
> <s(dot)shinderuk(at)postgrespro(dot)ru> wrote:
>> I'm not familiar with the code, just curios. There is a long comment
>> above saying "You might think we need to adjust var->varnullingrels, but
>> that shouldn't need any changes." Doesn't it need an update?
> No, I don't think we need to update it. That comment explains why
> varnullingrels do not require translation (since they are outer join
> relids, not baserel relids). It's unrelated to what this patch does,
> which is about propagating varnullingrels into the translated Var.
I agree with this fix: I think the code is like it is simply because
it didn't occur to me that the child Vars could have any nullingrel
bits yet. However, I don't agree that that comment needs no updates.
I suggest something like
- * Below, we just propagate var->varnullingrels into the translated
- * Var.
+ * Below, we just merge var->varnullingrels into the translated
+ * Var. (We must merge not just copy: the child Var could have
+ * some nullingrel bits set already, and we mustn't drop those.)
Also, I think I'd then drop the comment you added adjacent to the
actual update; it seems redundant if the earlier comment says this.
I agree with back-patching to v16. This particular example doesn't
misbehave in versions that don't have the drop-allegedly-redundant-
NOT-NULL-tests logic, but the varnullingrels are certainly wrong
all the way back, so possibly there are other examples that do
misbehave in v16.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hüseyin Demir | 2026-02-20 06:52:33 | Re: BUG #19393: pg_upgrade fails with duplicate key violation when CHECK constraint named *_not_null exists |
| Previous Message | Kirill Reshke | 2026-02-19 17:34:29 | Re: Error "could not access status of transaction" - version 14.21 |