pgsql: Fix gist_box_same and gist_point_consistent to handle fuzziness

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix gist_box_same and gist_point_consistent to handle fuzziness
Дата
Msg-id E1U3wzH-0007hn-JP@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix gist_box_same and gist_point_consistent to handle fuzziness correctly.

While there's considerable doubt that we want fuzzy behavior in the
geometric operators at all (let alone as currently implemented), nobody is
stepping forward to redesign that stuff.  In the meantime it behooves us
to make sure that index searches agree with the behavior of the underlying
operators.  This patch fixes two problems in this area.

First, gist_box_same was using fuzzy equality, but it really needs to use
exact equality to prevent not-quite-identical upper index keys from being
treated as identical, which for example would prevent an existing upper
key from being extended by an amount less than epsilon.  This would result
in inconsistent indexes.  (The next release notes will need to recommend
that users reindex GiST indexes on boxes, polygons, circles, and points,
since all four opclasses use gist_box_same.)

Second, gist_point_consistent used exact comparisons for upper-page
comparisons in ~= searches, when it needs to use fuzzy comparisons to
ensure it finds all matches; and it used fuzzy comparisons for point <@ box
searches, when it needs to use exact comparisons because that's what the
<@ operator (rather inconsistently) does.

The added regression test cases illustrate all three misbehaviors.

Back-patch to all active branches.  (8.4 did not have GiST point_ops,
but it still seems prudent to apply the gist_box_same patch to it.)

Alexander Korotkov, reviewed by Noah Misch

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/4d4c00850dedb4395138d825cfa3c69545c17f0b

Modified Files
--------------
src/backend/access/gist/gistproc.c  |   56 +++++++++++++++++++++++++---------
src/test/regress/expected/point.out |   50 +++++++++++++++++++++++++++++++
src/test/regress/sql/point.sql      |   21 +++++++++++++
3 files changed, 112 insertions(+), 15 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Prevent execution of enum_recv() from SQL.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix gist_box_same and gist_point_consistent to handle fuzziness