mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-03 08:00:21 +08:00
Fix bugs in comparison functions for multirange_bsearch_match()
Two functions multirange_range_overlaps_bsearch_comparison() and multirange_range_contains_bsearch_comparison() contain bugs of returning -1 instead of 1. This commit fixes these bugs and adds corresponding regression tests.
This commit is contained in:
parent
1b3433e25f
commit
a5b81b6f00
@ -1660,7 +1660,7 @@ multirange_range_contains_bsearch_comparison(TypeCacheEntry *typcache,
|
||||
if (range_cmp_bounds(typcache, keyUpper, lower) < 0)
|
||||
return -1;
|
||||
if (range_cmp_bounds(typcache, keyLower, upper) > 0)
|
||||
return -1;
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* At this point we found overlapping range. But we have to check if it
|
||||
@ -1825,7 +1825,7 @@ multirange_range_overlaps_bsearch_comparison(TypeCacheEntry *typcache,
|
||||
if (range_cmp_bounds(typcache, keyUpper, lower) < 0)
|
||||
return -1;
|
||||
if (range_cmp_bounds(typcache, keyLower, upper) > 0)
|
||||
return -1;
|
||||
return 1;
|
||||
|
||||
*match = true;
|
||||
return 0;
|
||||
|
@ -834,6 +834,12 @@ SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && nummultirange(numrange(3
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select '{(10,20),(30,40),(50,60)}'::nummultirange && '(42,92)'::numrange;
|
||||
?column?
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- contains
|
||||
SELECT nummultirange() @> nummultirange();
|
||||
?column?
|
||||
@ -967,6 +973,12 @@ SELECT '{[1,5), [6,9)}'::nummultirange @> '{[6,7)}';
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select '{(10,20),(30,40),(50,60)}'::nummultirange @> '(52,56)'::numrange;
|
||||
?column?
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- is contained by
|
||||
SELECT nummultirange() <@ nummultirange();
|
||||
?column?
|
||||
|
@ -162,6 +162,7 @@ SELECT nummultirange(numrange(1,2), numrange(7,8)) && nummultirange(numrange(3,4
|
||||
SELECT nummultirange(numrange(3,4)) && nummultirange(numrange(1,2), numrange(3.5,8));
|
||||
SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && numrange(3,4);
|
||||
SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && nummultirange(numrange(3,4));
|
||||
select '{(10,20),(30,40),(50,60)}'::nummultirange && '(42,92)'::numrange;
|
||||
|
||||
-- contains
|
||||
SELECT nummultirange() @> nummultirange();
|
||||
@ -186,6 +187,7 @@ SELECT '{[-4,-2), [1,5)}'::nummultirange @> '{[1,5)}';
|
||||
SELECT '{[1,5), [8,9)}'::nummultirange @> '{[1,5)}';
|
||||
SELECT '{[1,5), [8,9)}'::nummultirange @> '{[6,7)}';
|
||||
SELECT '{[1,5), [6,9)}'::nummultirange @> '{[6,7)}';
|
||||
select '{(10,20),(30,40),(50,60)}'::nummultirange @> '(52,56)'::numrange;
|
||||
|
||||
-- is contained by
|
||||
SELECT nummultirange() <@ nummultirange();
|
||||
|
Loading…
Reference in New Issue
Block a user