*/
if (nvalues == 0)
{
- /* ignore key space not covered by any partitions */
- if (partindices[minoff] < 0)
- minoff++;
- if (partindices[maxoff] < 0)
- maxoff--;
-
result->scan_default = partition_bound_has_default(boundinfo);
- Assert(partindices[minoff] >= 0 &&
- partindices[maxoff] >= 0);
+ Assert(partindices[minoff] >= -1 &&
+ partindices[maxoff] >= -1);
result->bound_offsets = bms_add_range(NULL, minoff, maxoff);
return result;
Filter: (((a = 1) AND (a = 3)) OR ((a > 1) AND (a = 15)))
(11 rows)
+-- Test cases for range partitioned tables with IN clauses.
+create table rangepart (a int) partition by range (a);
+create table rangepart1 partition of rangepart for values from (0) to (10);
+create table rangepart2 partition of rangepart for values from (10) to (20);
+create table rangepart_def partition of rangepart default;
+-- Ensure we scan all apart from the default partition
+explain (costs off) select * from rangepart where a in(5,15);
+ QUERY PLAN
+-------------------------------------------------
+ Append
+ -> Seq Scan on rangepart1 rangepart_1
+ Filter: (a = ANY ('{5,15}'::integer[]))
+ -> Seq Scan on rangepart2 rangepart_2
+ Filter: (a = ANY ('{5,15}'::integer[]))
+(5 rows)
+
+-- Ensure we scan only the default
+explain (costs off) select * from rangepart where a in(20,21);
+ QUERY PLAN
+--------------------------------------------
+ Seq Scan on rangepart_def rangepart
+ Filter: (a = ANY ('{20,21}'::integer[]))
+(2 rows)
+
+-- Ensure we scan only the default
+explain (costs off) select * from rangepart where a in(-1,20);
+ QUERY PLAN
+--------------------------------------------
+ Seq Scan on rangepart_def rangepart
+ Filter: (a = ANY ('{-1,20}'::integer[]))
+(2 rows)
+
+-- Ensure we scan all partitions
+explain (costs off) select * from rangepart where a is not null and a in(-1,5,15,20);
+ QUERY PLAN
+-----------------------------------------------------------------------------
+ Append
+ -> Seq Scan on rangepart1 rangepart_1
+ Filter: ((a IS NOT NULL) AND (a = ANY ('{-1,5,15,20}'::integer[])))
+ -> Seq Scan on rangepart2 rangepart_2
+ Filter: ((a IS NOT NULL) AND (a = ANY ('{-1,5,15,20}'::integer[])))
+ -> Seq Scan on rangepart_def rangepart_3
+ Filter: ((a IS NOT NULL) AND (a = ANY ('{-1,5,15,20}'::integer[])))
+(7 rows)
+
+drop table rangepart;
-- multi-column keys
create table mc3p (a int, b int, c int) partition by range (a, abs(b), c);
create table mc3p_default partition of mc3p default;
explain (costs off) select * from rlp where a = 1 and a = 3; /* empty */
explain (costs off) select * from rlp where (a = 1 and a = 3) or (a > 1 and a = 15);
+-- Test cases for range partitioned tables with IN clauses.
+create table rangepart (a int) partition by range (a);
+create table rangepart1 partition of rangepart for values from (0) to (10);
+create table rangepart2 partition of rangepart for values from (10) to (20);
+create table rangepart_def partition of rangepart default;
+
+-- Ensure we scan all apart from the default partition
+explain (costs off) select * from rangepart where a in(5,15);
+
+-- Ensure we scan only the default
+explain (costs off) select * from rangepart where a in(20,21);
+
+-- Ensure we scan only the default
+explain (costs off) select * from rangepart where a in(-1,20);
+
+-- Ensure we scan all partitions
+explain (costs off) select * from rangepart where a is not null and a in(-1,5,15,20);
+
+drop table rangepart;
+
-- multi-column keys
create table mc3p (a int, b int, c int) partition by range (a, abs(b), c);
create table mc3p_default partition of mc3p default;