mirror of
https://github.com/postgres/postgres.git
synced 2025-12-10 14:22:35 +03:00
Fix bogus logic for combining range-partitioned columns during pruning.
gen_prune_steps_from_opexps's notion of how to do this was overly complicated and underly correct. Per discussion of a report from Alan Jackson (though this fixes only one aspect of that problem). Back-patch to v11 where this code came in. Amit Langote Discussion: https://postgr.es/m/FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com
This commit is contained in:
@@ -3123,6 +3123,33 @@ select * from stable_qual_pruning
|
||||
(4 rows)
|
||||
|
||||
drop table stable_qual_pruning;
|
||||
--
|
||||
-- Check that pruning with composite range partitioning works correctly when
|
||||
-- it must ignore clauses for trailing keys once it has seen a clause with
|
||||
-- non-inclusive operator for an earlier key
|
||||
--
|
||||
create table mc3p (a int, b int, c int) partition by range (a, abs(b), c);
|
||||
create table mc3p0 partition of mc3p
|
||||
for values from (0, 0, 0) to (0, maxvalue, maxvalue);
|
||||
create table mc3p1 partition of mc3p
|
||||
for values from (1, 1, 1) to (2, minvalue, minvalue);
|
||||
create table mc3p2 partition of mc3p
|
||||
for values from (2, minvalue, minvalue) to (3, maxvalue, maxvalue);
|
||||
insert into mc3p values (0, 1, 1), (1, 1, 1), (2, 1, 1);
|
||||
explain (analyze, costs off, summary off, timing off)
|
||||
select * from mc3p where a < 3 and abs(b) = 1;
|
||||
QUERY PLAN
|
||||
-------------------------------------------------
|
||||
Append (actual rows=3 loops=1)
|
||||
-> Seq Scan on mc3p0 (actual rows=1 loops=1)
|
||||
Filter: ((a < 3) AND (abs(b) = 1))
|
||||
-> Seq Scan on mc3p1 (actual rows=1 loops=1)
|
||||
Filter: ((a < 3) AND (abs(b) = 1))
|
||||
-> Seq Scan on mc3p2 (actual rows=1 loops=1)
|
||||
Filter: ((a < 3) AND (abs(b) = 1))
|
||||
(7 rows)
|
||||
|
||||
drop table mc3p;
|
||||
-- Ensure runtime pruning works with initplans params with boolean types
|
||||
create table boolvalues (value bool not null);
|
||||
insert into boolvalues values('t'),('f');
|
||||
|
||||
@@ -792,6 +792,25 @@ select * from stable_qual_pruning
|
||||
|
||||
drop table stable_qual_pruning;
|
||||
|
||||
--
|
||||
-- Check that pruning with composite range partitioning works correctly when
|
||||
-- it must ignore clauses for trailing keys once it has seen a clause with
|
||||
-- non-inclusive operator for an earlier key
|
||||
--
|
||||
create table mc3p (a int, b int, c int) partition by range (a, abs(b), c);
|
||||
create table mc3p0 partition of mc3p
|
||||
for values from (0, 0, 0) to (0, maxvalue, maxvalue);
|
||||
create table mc3p1 partition of mc3p
|
||||
for values from (1, 1, 1) to (2, minvalue, minvalue);
|
||||
create table mc3p2 partition of mc3p
|
||||
for values from (2, minvalue, minvalue) to (3, maxvalue, maxvalue);
|
||||
insert into mc3p values (0, 1, 1), (1, 1, 1), (2, 1, 1);
|
||||
|
||||
explain (analyze, costs off, summary off, timing off)
|
||||
select * from mc3p where a < 3 and abs(b) = 1;
|
||||
|
||||
drop table mc3p;
|
||||
|
||||
-- Ensure runtime pruning works with initplans params with boolean types
|
||||
create table boolvalues (value bool not null);
|
||||
insert into boolvalues values('t'),('f');
|
||||
|
||||
Reference in New Issue
Block a user