public inbox for [email protected]  
help / color / mirror / Atom feed
pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
@ 2024-02-19 23:49 David Rowley <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2024-02-19 23:49 UTC (permalink / raw)
  To: [email protected]

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/[email protected]
Backpatch-through: 12

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4c2369ac5d0a108df4d65a2886657efa010d67ca

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
@ 2024-02-19 23:50 David Rowley <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2024-02-19 23:50 UTC (permalink / raw)
  To: [email protected]

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/[email protected]
Backpatch-through: 12

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fb95cc72bfe7a31efa8a711b8094a0c41ffad291

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
@ 2024-02-19 23:50 David Rowley <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2024-02-19 23:50 UTC (permalink / raw)
  To: [email protected]

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/[email protected]
Backpatch-through: 12

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1b3495e29db6c7ca32a88d5546e7813efa71cbbb

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
@ 2024-02-19 23:51 David Rowley <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2024-02-19 23:51 UTC (permalink / raw)
  To: [email protected]

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/[email protected]
Backpatch-through: 12

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f9c8f7ccd6e34bc9222a09af3205600611bcda27

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
@ 2024-02-19 23:51 David Rowley <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2024-02-19 23:51 UTC (permalink / raw)
  To: [email protected]

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/[email protected]
Backpatch-through: 12

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3850fcca69b5db0694ceb5d1134699dc247f201e

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus
@ 2024-02-19 23:51 David Rowley <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2024-02-19 23:51 UTC (permalink / raw)
  To: [email protected]

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/[email protected]
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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2024-02-19 23:51 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 23:49 pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus David Rowley <[email protected]>
2024-02-19 23:50 pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus David Rowley <[email protected]>
2024-02-19 23:50 pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus David Rowley <[email protected]>
2024-02-19 23:51 pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus David Rowley <[email protected]>
2024-02-19 23:51 pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus David Rowley <[email protected]>
2024-02-19 23:51 pgsql: Fix incorrect pruning of NULL partition for boolean IS NOT claus David Rowley <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox