]> granicus.if.org Git - postgresql/commit
Fix assorted oversights in range selectivity estimation.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 30 Jan 2015 17:30:43 +0000 (12:30 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 30 Jan 2015 17:30:43 +0000 (12:30 -0500)
commit527ff8baf259263cc861b2058385d92829d1ba28
treeea31e96bd5283431b7c1cd513742e7cdd562db5c
parentcc609c46fbf0d0e8a7995207c07286c6248eb732
Fix assorted oversights in range selectivity estimation.

calc_rangesel() failed outright when comparing range variables to empty
constant ranges with < or >=, as a result of missing cases in a switch.
It also produced a bogus estimate for > comparison to an empty range.

On top of that, the >= and > cases were mislabeled throughout.  For
nonempty constant ranges, they managed to produce the right answers
anyway as a result of counterbalancing typos.

Also, default_range_selectivity() omitted cases for elem <@ range,
range &< range, and range &> range, so that rather dubious defaults
were applied for these operators.

In passing, rearrange the code in rangesel() so that the elem <@ range
case is handled in a less opaque fashion.

Report and patch by Emre Hasegeli, some additional work by me
src/backend/utils/adt/rangetypes_selfuncs.c
src/include/catalog/pg_operator.h
src/test/regress/expected/rangetypes.out
src/test/regress/sql/rangetypes.sql