Re: Reduce "Var IS [NOT] NULL" quals during constant folding

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>, Tender Wang <tndrwang(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Reduce "Var IS [NOT] NULL" quals during constant folding
Date: 2025-09-08 13:07:55
Message-ID: CAEG8a3LrKxGUEV_gnZbVau0r9=ePAb1CVTkQmRpCygdpz3DArA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 8, 2025 at 4:21 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>
> On Sun, Sep 7, 2025 at 8:12 PM Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
> > While reading this thread, I found that it uses *Relids* to collect NOT NULL
> > attribute numbers, I think this might be an oversight, since ISTM that
> > Relids is used to represent the index of the relation in the range table.
>
> Nice catch; it's better to use Bitmapset * rather than Relids in this
> scenario. That was my oversight; will fix it.
>
> > So I think it would be better to be consistent, anyway I post a trivial patch
> > if the community agrees with me.
>
> Your patch misses one spot: the notnullattnums in
> get_relation_notnullatts() should also be fixed. Otherwise it LGTM.

True, attached v2 adds that missing spot, thanks for the review.

>
> - Richard

--
Regards
Junwang Zhao

Attachment Content-Type Size
v2-0001-use-Bitmapset-to-represent-not-null-attr-nums.patch application/octet-stream 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Holger Hoffstätte 2025-09-08 13:20:38 [PATCH] jit: fix build with LLVM-21
Previous Message Aleksander Alekseev 2025-09-08 12:50:07 Re: [BUG] PostgreSQL crashes with ThreadSanitizer during early initialization