postgresql/src
Heikki Linnakangas 1264ef31a3 Fix bugs in SP-GiST search with range type's -|- (adjacent) operator.
The consistent function contained several bugs:

* The "if (which2) { ... }"  block was broken. It compared the  argument's
lower bound against centroid's upper bound, while it was supposed to compare
the argument's upper bound against the centroid's lower bound (the comment
was correct, code was wrong). Also, it cleared bits in the "which1"
variable, while it was supposed to clear bits in "which2".

* If the argument's upper bound was equal to the centroid's lower bound, we
descended to both halves (= all quadrants). That's unnecessary, searching
the right quadrants is sufficient. This didn't lead to incorrect query
results, but was clearly wrong, and slowed down queries unnecessarily.

* In the case that argument's lower bound is adjacent to the centroid's
upper bound, we also don't need to visit all quadrants. Per similar
reasoning as previous point.

* The code where we compare the previous centroid with the current centroid
should match the code where we compare the current centroid with the
argument. The point of that code is to redo the calculation done in the
previous level, to see if we were supposed to traverse left or right (or up
or down), and if we actually did. If we moved in the different direction,
then we know there are no matches for bound.

Refactor the code and adds comments to make it more readable and easier to
reason about.

Backpatch to 9.3 where SP-GiST support for range types was introduced.
2014-07-16 09:19:06 +03:00
..
backend Fix bugs in SP-GiST search with range type's -|- (adjacent) operator. 2014-07-16 09:19:06 +03:00
bin pg_basebackup: Add more information about --max-rate option to help output 2014-07-15 15:08:16 -04:00
common pgindent run for 9.4 2014-05-06 12:12:18 -04:00
include Allow join removal in some cases involving a left join to a subquery. 2014-07-15 21:12:43 -04:00
interfaces Remove dependency on wsock32.lib in favor of ws2_32 2014-07-15 14:18:39 +02:00
makefiles Add file version information to most installed Windows binaries. 2014-07-14 14:07:52 -04:00
pl Add file version information to most installed Windows binaries. 2014-07-14 14:07:52 -04:00
port Add mkdtemp() to libpgport. 2014-06-14 09:41:13 -04:00
template Remove Alpha and Tru64 support. 2014-06-28 21:46:15 +02:00
test Allow join removal in some cases involving a left join to a subquery. 2014-07-15 21:12:43 -04:00
timezone pgindent run for 9.4 2014-05-06 12:12:18 -04:00
tools Remove dependency on wsock32.lib in favor of ws2_32 2014-07-15 14:18:39 +02:00
tutorial Adjust blank lines around PG_MODULE_MAGIC defines, for consistency 2014-07-10 14:02:08 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Support vpath builds in TAP tests 2014-07-02 21:47:07 -04:00
Makefile.shlib Remove Alpha and Tru64 support. 2014-06-28 21:46:15 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00