Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-12 Thread Sergei Glukhov
On 10/12/23 16:27, David Rowley wrote: I've now also pushed the fix for the incorrect logic for nullkeys in ExecInitPruningContext(). Thanks! Regards, Gluh

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-12 Thread David Rowley
On Mon, 9 Oct 2023 at 12:26, David Rowley wrote: > > On Sat, 7 Oct 2023 at 03:11, Sergei Glukhov wrote: > > I noticed that combination of prepared statement with generic plan and > > 'IS NULL' clause could lead partition pruning to crash. > > > Test case: > > -- > > set plan_cache_mode to for

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-12 Thread David Rowley
On Wed, 11 Oct 2023 at 22:59, Sergei Glukhov wrote: > > Unfortunately, I'd not long sent the last email and realised that the > > step_lastkeyno parameter is now unused and can just be removed from > > both get_steps_using_prefix() and get_steps_using_prefix_recurse(). > > This requires some comme

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-11 Thread Sergei Glukhov
On 10/11/23 13:19, David Rowley wrote: Thanks for having a look. Unfortunately, I'd not long sent the last email and realised that the step_lastkeyno parameter is now unused and can just be removed from both get_steps_using_prefix() and get_steps_using_prefix_recurse(). This requires some co

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-11 Thread David Rowley
On Wed, 11 Oct 2023 at 22:09, Sergei Glukhov wrote: > Thanks for fixing this! > > I verified that issues are fixed. Thanks for having a look. Unfortunately, I'd not long sent the last email and realised that the step_lastkeyno parameter is now unused and can just be removed from both get_steps_u

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-11 Thread Sergei Glukhov
Hi, Thanks for fixing this! I verified that issues are fixed. On 10/11/23 11:50, David Rowley wrote: I'm aiming to commit these as two separate fixes, so I'm going to go look again at the first one and wait to see if anyone wants to comment on this patch in the meantime. Regarding test case

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-11 Thread tender wang
David Rowley 于2023年10月11日周三 15:52写道: > On Wed, 11 Oct 2023 at 15:49, David Rowley wrote: > > It might have been better if PartClauseInfo could also describe IS > > NULL quals, but I feel if we do that now then it would require lots of > > careful surgery in partprune.c to account for that. Prob

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-11 Thread David Rowley
On Wed, 11 Oct 2023 at 15:49, David Rowley wrote: > It might have been better if PartClauseInfo could also describe IS > NULL quals, but I feel if we do that now then it would require lots of > careful surgery in partprune.c to account for that. Probably the fix > should be localised to get_steps

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-10 Thread tender wang
For hash partition table, if partition key is IS NULL clause, the condition in if in get_steps_using_prefix_recurse: if (cur_keyno < step_lastkeyno - 1) is not enough. Like the decode crashed case, explain select * from hp where a = 1 and b is null and c = 1; prefix list just has a = 1 clause. I

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-10 Thread David Rowley
On Tue, 10 Oct 2023 at 21:31, Sergei Glukhov wrote: > create table hp (a int, b text, c int, d int) >partition by hash (a part_test_int4_ops, b part_test_text_ops, c > part_test_int4_ops); > create table hp0 partition of hp for values with (modulus 4, remainder 0); > create table hp3 partition

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-10 Thread Sergei Glukhov
Hi David, On 10/9/23 03:26, David Rowley wrote: On Sat, 7 Oct 2023 at 03:11, Sergei Glukhov wrote: I noticed that combination of prepared statement with generic plan and 'IS NULL' clause could lead partition pruning to crash. Test case: -- set plan_cache_mode to force_generic_plan; prepar

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-10 Thread tender wang
The comment /* not needed for Consts */ may be more better close to if (!IsA(expr, Const)). Others look good to me. David Rowley 于2023年10月9日周一 07:28写道: > On Sat, 7 Oct 2023 at 03:11, Sergei Glukhov > wrote: > > I noticed that combination of prepared statement with generic plan and > > 'IS NUL

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-08 Thread David Rowley
On Sat, 7 Oct 2023 at 03:11, Sergei Glukhov wrote: > I noticed that combination of prepared statement with generic plan and > 'IS NULL' clause could lead partition pruning to crash. > Test case: > -- > set plan_cache_mode to force_generic_plan; > prepare stmt AS select * from hp where a is nu

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-06 Thread Bruce Momjian
On Fri, Oct 6, 2023 at 05:00:54PM -0400, Bruce Momjian wrote: > On Fri, Oct 6, 2023 at 06:09:45PM +0400, Sergei Glukhov wrote: > > Test case: > > -- > > set plan_cache_mode to force_generic_plan; > > prepare stmt AS select * from hp where a is null and b = $1; > > explain execute stmt('xxx');

Re: Problem, partition pruning for prepared statement with IS NULL clause.

2023-10-06 Thread Bruce Momjian
On Fri, Oct 6, 2023 at 06:09:45PM +0400, Sergei Glukhov wrote: > Test case: > -- > set plan_cache_mode to force_generic_plan; > prepare stmt AS select * from hp where a is null and b = $1; > explain execute stmt('xxx'); > -- I can confirm the crash in git master. -- Bruce Momjian