]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix runtime partition pruning for HASH partitioned tables
authorDavid Rowley <drowley@postgresql.org>
Thu, 12 Oct 2023 12:13:59 +0000 (01:13 +1300)
committerDavid Rowley <drowley@postgresql.org>
Thu, 12 Oct 2023 12:13:59 +0000 (01:13 +1300)
commitd26f33c3243669e95498039b2ffd92b296cfdcb2
tree2084602c1f91a275d9956138c44ff641cac2c89b
parent952e0b26c305126c8698af9f3fb3fa6d8ac07bf1
Fix runtime partition pruning for HASH partitioned tables

This could only affect HASH partitioned tables with at least 2 partition
key columns.

If partition pruning was delayed until execution and the query contained
an IS NULL qual on one of the partitioned keys, and some subsequent
partitioned key was being compared to a non-Const, then this could result
in a crash due to the incorrect keyno being used to calculate the
stateidx for the expression evaluation code.

Here we fix this by properly skipping partitioned keys which have a
nullkey set.  Effectively, this must be the same as what's going on
inside perform_pruning_base_step().

Sergei Glukhov also provided a patch, but that's not what's being used
here.

Reported-by: Sergei Glukhov
Reviewed-by: tender wang, Sergei Glukhov
Discussion: https://postgr.es/m/d05b26fa-af54-27e1-f693-6c31590802fa@postgrespro.ru
Backpatch-through: 11, where runtime partition pruning was added.
src/backend/executor/execPartition.c
src/test/regress/expected/partition_prune.out
src/test/regress/sql/partition_prune.sql