Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy - Mailing list pgsql-bugs

From David Rowley
Subject Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy
Date
Msg-id CAApHDvqdnpebVXsxT4BouGFHkCX+4pupr+rxckgkxRprj+kzow@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Fri, 16 Feb 2024 at 05:28, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> What seems to be happening is that gen_prune_step_op is getting
> op_is_ne = true and doing this:
>
>         /*
>          * For clauses that contain an <> operator, set opstrategy to
>          * InvalidStrategy to signal get_matching_list_bounds to do the right
>          * thing.
>          */
>         opstep->opstrategy = op_is_ne ? InvalidStrategy : opstrategy;
>
> but then we're failing in get_matching_range_bounds, ie somebody
> taught get_matching_list_bounds to do the right thing but not
> any of the other code paths.

hmm, yeah. I'm just trying to wrap my head around if this can even
work for RANGE partitioned tables.

> I'm also wondering how we got there in the first place.  It looks like
> match_boolean_partition_clause thinks it can translate "b IS NOT true"
> to "b <> true", which is flat wrong --- it gives the wrong result for
> null.

Thought I'd fixed that in e0693faf7, but looks like I only tested it
with DEFAULT partitions, not NULL partitions. A fairly simple fix for
that part:

                /* Always include the default partition if any. */
                result->scan_default = partition_bound_has_default(boundinfo);

+               /* Likewise for the NULL partition, if any */
+               result->scan_null = partition_bound_accepts_nulls(boundinfo);

I'll look at the RANGE <> bool stuff.

David



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18343: Incorrect description in postgresql.conf for max_parallel_workers_per_gather
Next
From: PG Bug reporting form
Date:
Subject: BUG #18346: pg restore issue with generated cloumn in Postgres v13.14