mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Change bms_add_range to be a no-op for empty ranges
In commit 84940644de
, bms_add_range was added with an API to fail with
an error if an empty range was specified. This seems arbitrary and
unhelpful, so turn that case into a no-op instead. Callers that require
further verification on the arguments or result can apply them by
themselves.
This fixes the bug that partition pruning throws an API error for a case
involving the default partition of a default partition, as in the
included test case.
Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Diagnosed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/16590.1532622503@sss.pgh.pa.us
This commit is contained in:
@ -1180,6 +1180,21 @@ explain (costs off) select * from coercepart where a !~ all ('{ab,bc}');
|
||||
(7 rows)
|
||||
|
||||
drop table coercepart;
|
||||
CREATE TABLE part (a INT, b INT) PARTITION BY LIST (a);
|
||||
CREATE TABLE part_p1 PARTITION OF part FOR VALUES IN (-2,-1,0,1,2);
|
||||
CREATE TABLE part_p2 PARTITION OF part DEFAULT PARTITION BY RANGE(a);
|
||||
CREATE TABLE part_p2_p1 PARTITION OF part_p2 DEFAULT;
|
||||
INSERT INTO part VALUES (-1,-1), (1,1), (2,NULL), (NULL,-2),(NULL,NULL);
|
||||
EXPLAIN (COSTS OFF) SELECT tableoid::regclass as part, a, b FROM part WHERE a IS NULL ORDER BY 1, 2, 3;
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------
|
||||
Sort
|
||||
Sort Key: ((part_p2_p1.tableoid)::regclass), part_p2_p1.a, part_p2_p1.b
|
||||
-> Append
|
||||
-> Seq Scan on part_p2_p1
|
||||
Filter: (a IS NULL)
|
||||
(5 rows)
|
||||
|
||||
--
|
||||
-- some more cases
|
||||
--
|
||||
|
@ -173,6 +173,13 @@ explain (costs off) select * from coercepart where a !~ all ('{ab,bc}');
|
||||
|
||||
drop table coercepart;
|
||||
|
||||
CREATE TABLE part (a INT, b INT) PARTITION BY LIST (a);
|
||||
CREATE TABLE part_p1 PARTITION OF part FOR VALUES IN (-2,-1,0,1,2);
|
||||
CREATE TABLE part_p2 PARTITION OF part DEFAULT PARTITION BY RANGE(a);
|
||||
CREATE TABLE part_p2_p1 PARTITION OF part_p2 DEFAULT;
|
||||
INSERT INTO part VALUES (-1,-1), (1,1), (2,NULL), (NULL,-2),(NULL,NULL);
|
||||
EXPLAIN (COSTS OFF) SELECT tableoid::regclass as part, a, b FROM part WHERE a IS NULL ORDER BY 1, 2, 3;
|
||||
|
||||
--
|
||||
-- some more cases
|
||||
--
|
||||
|
Reference in New Issue
Block a user