Re: pgsql: Reduce "Var IS [NOT] NULL" quals during constant folding - Mailing list pgsql-hackers

From Robert Haas
Subject Re: pgsql: Reduce "Var IS [NOT] NULL" quals during constant folding
Date
Msg-id CA+TgmoZy22d8Mz3z_Sjj+cb6tJQyfe=fJT-XkWmFX2eGD067iw@mail.gmail.com
Whole thread
List pgsql-hackers
On Mon, Jul 21, 2025 at 10:23 PM Richard Guo <rguo@postgresql.org> wrote:
> Reduce "Var IS [NOT] NULL" quals during constant folding

I feel like this commit message might have missed a fairly important
point here, which is that this commit made it necessary, in some set
of circumstances, for eval_const_expressions() to happen with a valid
PlannerInfo *root and with varnos already fixed. In addition to the
cases covered by 317c117d6d2 and c925ad30b04, there seems to be issues
with partition keys and partition constraints: see
set_baserel_partition_key_exprs and set_baserel_partition_constraint.
Attached are a pair of Claude-written test case that demonstrate
partition pruning failing as a result.

I'm afraid this isn't going to be all the bugs. We have expression
trees in a lot of places, and we call eval_const_expressions()
directly or indirectly in a lot of places, and it doesn't seem easy to
know what we might still have missed.

--
Robert Haas
Databricks

Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: remote_apply commit hangs when wal_receiver_status_interval = 0
Next
From: Sami Imseih
Date:
Subject: Re: pgstat: allow a stats kind to use its own dedicated dsa/dshash