pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
@ 2023-04-14 04:20  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2023-04-14 04:20 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

Branch
------
master

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

Modified Files
--------------
src/backend/partitioning/partprune.c          |  54 +++---
src/test/regress/expected/partition_prune.out | 227 ++++++++++++++++++++++++--
src/test/regress/sql/partition_prune.sql      |  38 ++++-
3 files changed, 288 insertions(+), 31 deletions(-)



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

* pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
@ 2023-04-14 04:21  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2023-04-14 04:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0c09160e113f3b7daf9fc5370357955ab039428d

Modified Files
--------------
src/backend/partitioning/partprune.c          |  54 +++---
src/test/regress/expected/partition_prune.out | 227 ++++++++++++++++++++++++--
src/test/regress/sql/partition_prune.sql      |  38 ++++-
3 files changed, 288 insertions(+), 31 deletions(-)



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

* pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
@ 2023-04-14 04:22  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2023-04-14 04:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/partitioning/partprune.c          |  54 +++---
src/test/regress/expected/partition_prune.out | 227 ++++++++++++++++++++++++--
src/test/regress/sql/partition_prune.sql      |  38 ++++-
3 files changed, 288 insertions(+), 31 deletions(-)



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

* pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
@ 2023-04-14 04:22  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2023-04-14 04:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6848f0c67c60dc721c4e4527778f83e2c8c08d01

Modified Files
--------------
src/backend/partitioning/partprune.c          |  54 +++---
src/test/regress/expected/partition_prune.out | 227 ++++++++++++++++++++++++--
src/test/regress/sql/partition_prune.sql      |  38 ++++-
3 files changed, 288 insertions(+), 31 deletions(-)



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

* pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
@ 2023-04-14 04:23  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2023-04-14 04:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0b2e77ce288d4339836ef3c920c877352b218873

Modified Files
--------------
src/backend/partitioning/partprune.c          |  54 +++---
src/test/regress/expected/partition_prune.out | 227 ++++++++++++++++++++++++--
src/test/regress/sql/partition_prune.sql      |  38 ++++-
3 files changed, 288 insertions(+), 31 deletions(-)



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

* pgsql: Fix incorrect partition pruning logic for boolean partitioned ta
@ 2023-04-14 04:23  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2023-04-14 04:23 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix incorrect partition pruning logic for boolean partitioned tables

The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/partitioning/partprune.c          |  54 +++---
src/test/regress/expected/partition_prune.out | 227 ++++++++++++++++++++++++--
src/test/regress/sql/partition_prune.sql      |  38 ++++-
3 files changed, 289 insertions(+), 30 deletions(-)



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


end of thread, other threads:[~2023-04-14 04:23 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 04:20 pgsql: Fix incorrect partition pruning logic for boolean partitioned ta David Rowley <drowley@postgresql.org>
2023-04-14 04:21 pgsql: Fix incorrect partition pruning logic for boolean partitioned ta David Rowley <drowley@postgresql.org>
2023-04-14 04:22 pgsql: Fix incorrect partition pruning logic for boolean partitioned ta David Rowley <drowley@postgresql.org>
2023-04-14 04:22 pgsql: Fix incorrect partition pruning logic for boolean partitioned ta David Rowley <drowley@postgresql.org>
2023-04-14 04:23 pgsql: Fix incorrect partition pruning logic for boolean partitioned ta David Rowley <drowley@postgresql.org>
2023-04-14 04:23 pgsql: Fix incorrect partition pruning logic for boolean partitioned ta David Rowley <drowley@postgresql.org>

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