prefix.patch
text/x-diff
Filename: prefix.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/partitioning/partprune.c | 4 | 2 |
| src/test/regress/expected/partition_prune.out | 9 | 0 |
| src/test/regress/sql/partition_prune.sql | 8 | 0 |
diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c
index badd31a44c..232464d1b0 100644
--- a/src/backend/partitioning/partprune.c
+++ b/src/backend/partitioning/partprune.c
@@ -1416,7 +1416,8 @@ gen_prune_steps_from_opexps(GeneratePruningStepsContext *context,
* add other <= clauses to the prefix, provided
* they're from an earlier key.
*/
- if (strat == BTLessStrategyNumber ||
+ if (strat == BTEqualStrategyNumber ||
+ strat == BTLessStrategyNumber ||
strat == BTLessEqualStrategyNumber)
{
foreach(lc1, le_clauses)
@@ -1435,7 +1436,8 @@ gen_prune_steps_from_opexps(GeneratePruningStepsContext *context,
* add other >= clauses to the prefix, provided
* they're from an earlier key.
*/
- if (strat == BTGreaterStrategyNumber ||
+ if (strat == BTEqualStrategyNumber ||
+ strat == BTGreaterStrategyNumber ||
strat == BTGreaterEqualStrategyNumber)
{
foreach(lc1, ge_clauses)
diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out
index 4315e8e0a3..d0f3b4525d 100644
--- a/src/test/regress/expected/partition_prune.out
+++ b/src/test/regress/expected/partition_prune.out
@@ -3671,3 +3671,12 @@ explain (costs off) update listp1 set a = 1 where a = 2;
reset constraint_exclusion;
reset enable_partition_pruning;
drop table listp;
+create table prefix_test (a int, b varchar)
+partition by range(a, b);
+create table prefix_test1 partition of prefix_test
+for values from (1, 'a') to (1, 'b');
+select * from prefix_test where a <= 1 and b = 'a' ;
+ a | b
+---+---
+(0 rows)
+
diff --git a/src/test/regress/sql/partition_prune.sql b/src/test/regress/sql/partition_prune.sql
index 6658455a74..3581b6a0d3 100644
--- a/src/test/regress/sql/partition_prune.sql
+++ b/src/test/regress/sql/partition_prune.sql
@@ -1050,3 +1050,11 @@ reset constraint_exclusion;
reset enable_partition_pruning;
drop table listp;
+
+create table prefix_test (a int, b varchar)
+partition by range(a, b);
+
+create table prefix_test1 partition of prefix_test
+for values from (1, 'a') to (1, 'b');
+
+select * from prefix_test where a <= 1 and b = 'a' ;