pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus

Поиск
Список
Период
Сортировка
От David Rowley
Тема pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
Дата
Msg-id E1rcDQN-0075E6-JT@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix incorrect pruning of NULL partition for boolean IS NOT clauses

Partition pruning wrongly assumed that, for a table partitioned on a
boolean column, a clause in the form "boolcol IS NOT false" and "boolcol
IS NOT true" could be inverted to correspondingly become "boolcol IS true"
and "boolcol IS false".  These are not equivalent as the NOT version
matches the opposite boolean value *and* NULLs.  This incorrect assumption
meant that partition pruning pruned away partitions that could contain
NULL values.

Here we fix this by correctly not pruning partitions which could store
NULLs.

To be affected by this, the table must be partitioned by a NULLable boolean
column and queries would have to contain "boolcol IS NOT false" or "boolcol
IS NOT true".  This could result in queries filtering out NULL values
with a LIST partitioned table and "ERROR:  invalid strategy number 0"
for RANGE and HASH partitioned tables.

Reported-by: Alexander Lakhin
Bug: #18344
Discussion: https://postgr.es/m/18344-8d3f00bada6d09c6@postgresql.org
Backpatch-through: 12

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3ffcd24c29c60e913c9f5f4c0911180c9f3b9897

Modified Files
--------------
src/backend/partitioning/partprune.c          |  56 +++++++++++++-
src/test/regress/expected/partition_prune.out | 103 ++++++++++++++++++++++++++
src/test/regress/sql/partition_prune.sql      |  30 ++++++++
3 files changed, 187 insertions(+), 2 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: doc: Use system-username instead of system-user