pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix RANGE partition pruning with multiple boolean partition keys
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix RANGE partition pruning with multiple boolean partition keys
@ 2019-07-12 07:11 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2019-07-12 07:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix RANGE partition pruning with multiple boolean partition keys

match_clause_to_partition_key incorrectly would return
PARTCLAUSE_UNSUPPORTED if a bool qual could not be matched to the current
partition key.  This was a problem, as it causes the calling function to
discard the qual and not try to match it to any other partition key.  If
there was another partition key which did match this qual, then the qual
would not be checked again and we could fail to prune some partitions.

The worst this could do was to cause partitions not to be pruned when they
could have been, so there was no danger of incorrect query results here.

Fix this by changing match_boolean_partition_clause to have it return a
PartClauseMatchStatus rather than a boolean value.  This allows it to
communicate if the qual is unsupported or if it just does not match this
particular partition key, previously these two cases were treated the
same.  Now, if match_clause_to_partition_key is unable to match the qual
to any other qual type then we can simply return the value from the
match_boolean_partition_clause call so that the calling function properly
treats the qual as either unmatched or unsupported.

Reported-by: Rares Salcudean
Reviewed-by: Amit Langote
Backpatch-through: 11 where partition pruning was introduced
Discussion: https://postgr.es/m/CAHp_FN2xwEznH6oyS0hNTuUUZKp5PvegcVv=Co6nBXJ+mC7Y5w@mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/757f1baa8c13ffe7abd7b0f49f787a1c007cdf89

Modified Files
--------------
src/backend/partitioning/partprune.c          | 50 ++++++++++++++++++++-------
src/test/regress/expected/partition_prune.out | 16 ++++++++-
src/test/regress/sql/partition_prune.sql      | 11 +++++-
3 files changed, 62 insertions(+), 15 deletions(-)



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

* pgsql: Fix RANGE partition pruning with multiple boolean partition keys
@ 2019-07-12 07:12 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2019-07-12 07:12 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix RANGE partition pruning with multiple boolean partition keys

match_clause_to_partition_key incorrectly would return
PARTCLAUSE_UNSUPPORTED if a bool qual could not be matched to the current
partition key.  This was a problem, as it causes the calling function to
discard the qual and not try to match it to any other partition key.  If
there was another partition key which did match this qual, then the qual
would not be checked again and we could fail to prune some partitions.

The worst this could do was to cause partitions not to be pruned when they
could have been, so there was no danger of incorrect query results here.

Fix this by changing match_boolean_partition_clause to have it return a
PartClauseMatchStatus rather than a boolean value.  This allows it to
communicate if the qual is unsupported or if it just does not match this
particular partition key, previously these two cases were treated the
same.  Now, if match_clause_to_partition_key is unable to match the qual
to any other qual type then we can simply return the value from the
match_boolean_partition_clause call so that the calling function properly
treats the qual as either unmatched or unsupported.

Reported-by: Rares Salcudean
Reviewed-by: Amit Langote
Backpatch-through: 11 where partition pruning was introduced
Discussion: https://postgr.es/m/CAHp_FN2xwEznH6oyS0hNTuUUZKp5PvegcVv=Co6nBXJ+mC7Y5w@mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/30a268ed2e2944b3902d3e10a9876e498a0c12b9

Modified Files
--------------
src/backend/partitioning/partprune.c          | 50 ++++++++++++++++++++-------
src/test/regress/expected/partition_prune.out | 15 +++++++-
src/test/regress/sql/partition_prune.sql      | 11 +++++-
3 files changed, 61 insertions(+), 15 deletions(-)



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

* pgsql: Fix RANGE partition pruning with multiple boolean partition keys
@ 2019-07-12 07:13 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2019-07-12 07:13 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix RANGE partition pruning with multiple boolean partition keys

match_clause_to_partition_key incorrectly would return
PARTCLAUSE_UNSUPPORTED if a bool qual could not be matched to the current
partition key.  This was a problem, as it causes the calling function to
discard the qual and not try to match it to any other partition key.  If
there was another partition key which did match this qual, then the qual
would not be checked again and we could fail to prune some partitions.

The worst this could do was to cause partitions not to be pruned when they
could have been, so there was no danger of incorrect query results here.

Fix this by changing match_boolean_partition_clause to have it return a
PartClauseMatchStatus rather than a boolean value.  This allows it to
communicate if the qual is unsupported or if it just does not match this
particular partition key, previously these two cases were treated the
same.  Now, if match_clause_to_partition_key is unable to match the qual
to any other qual type then we can simply return the value from the
match_boolean_partition_clause call so that the calling function properly
treats the qual as either unmatched or unsupported.

Reported-by: Rares Salcudean
Reviewed-by: Amit Langote
Backpatch-through: 11 where partition pruning was introduced
Discussion: https://postgr.es/m/CAHp_FN2xwEznH6oyS0hNTuUUZKp5PvegcVv=Co6nBXJ+mC7Y5w@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/partitioning/partprune.c          | 50 ++++++++++++++++++++-------
src/test/regress/expected/partition_prune.out | 15 +++++++-
src/test/regress/sql/partition_prune.sql      | 11 +++++-
3 files changed, 61 insertions(+), 15 deletions(-)



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


end of thread, other threads:[~2019-07-12 07:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 07:11 pgsql: Fix RANGE partition pruning with multiple boolean partition keys David Rowley <drowley@postgresql.org>
2019-07-12 07:12 pgsql: Fix RANGE partition pruning with multiple boolean partition keys David Rowley <drowley@postgresql.org>
2019-07-12 07:13 pgsql: Fix RANGE partition pruning with multiple boolean partition keys 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