Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5966bce

Browse files
committed
Make GiST index searches smarter about queries against empty ranges.
In the cases where the result of the called proc is negated, we shouldexplicitly test both inputs for empty, to ensure we'll never return "true"for an unsatisfiable query. In other cases we can rely on the called procto say the right thing.
1 parent6c8768c commit5966bce

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎src/backend/utils/adt/rangetypes_gist.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,13 @@ range_gist_consistent_int(FmgrInfo *flinfo, StrategyNumber strategy,
444444
switch (strategy)
445445
{
446446
caseRANGESTRAT_BEFORE:
447-
if (RangeIsEmpty(key))
447+
if (RangeIsEmpty(key)||RangeIsEmpty(DatumGetRangeType(query)))
448448
return false;
449449
proc=range_overright;
450450
negate= true;
451451
break;
452452
caseRANGESTRAT_OVERLEFT:
453-
if (RangeIsEmpty(key))
453+
if (RangeIsEmpty(key)||RangeIsEmpty(DatumGetRangeType(query)))
454454
return false;
455455
proc=range_after;
456456
negate= true;
@@ -459,13 +459,13 @@ range_gist_consistent_int(FmgrInfo *flinfo, StrategyNumber strategy,
459459
proc=range_overlaps;
460460
break;
461461
caseRANGESTRAT_OVERRIGHT:
462-
if (RangeIsEmpty(key))
462+
if (RangeIsEmpty(key)||RangeIsEmpty(DatumGetRangeType(query)))
463463
return false;
464464
proc=range_before;
465465
negate= true;
466466
break;
467467
caseRANGESTRAT_AFTER:
468-
if (RangeIsEmpty(key))
468+
if (RangeIsEmpty(key)||RangeIsEmpty(DatumGetRangeType(query)))
469469
return false;
470470
proc=range_overleft;
471471
negate= true;
@@ -483,6 +483,11 @@ range_gist_consistent_int(FmgrInfo *flinfo, StrategyNumber strategy,
483483
proc=range_contains;
484484
break;
485485
caseRANGESTRAT_CONTAINED_BY:
486+
/*
487+
* Ideally we'd apply range_overlaps here, but at present it
488+
* might fail to find empty ranges in the index, which should
489+
* be reported as being contained by anything. This needs work.
490+
*/
486491
return true;
487492
break;
488493
caseRANGESTRAT_CONTAINS_ELEM:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp