diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c new file mode 100644 index 09e911d..9895e19 *** a/src/backend/access/gist/gistproc.c --- b/src/backend/access/gist/gistproc.c *************** gist_box_picksplit(PG_FUNCTION_ARGS) *** 836,842 **** } /* ! * Equality method * * This is used for both boxes and points. */ --- 836,843 ---- } /* ! * Equality method. Returns true only when boxes are exact same. We can't ! * ignore small extents because of index consistency. * * This is used for both boxes and points. */ *************** gist_box_same(PG_FUNCTION_ARGS) *** 848,856 **** bool *result = (bool *) PG_GETARG_POINTER(2); if (b1 && b2) ! *result = DatumGetBool(DirectFunctionCall2(box_same, ! PointerGetDatum(b1), ! PointerGetDatum(b2))); else *result = (b1 == NULL && b2 == NULL) ? TRUE : FALSE; PG_RETURN_POINTER(result); --- 849,857 ---- bool *result = (bool *) PG_GETARG_POINTER(2); if (b1 && b2) ! *result = (b1->low.x == b2->low.x && b1->low.y == b2->low.y && ! b1->high.x == b2->high.x && b1->high.y == b2->high.y) ! ? TRUE : FALSE; else *result = (b1 == NULL && b2 == NULL) ? TRUE : FALSE; PG_RETURN_POINTER(result); *************** gist_point_consistent_internal(StrategyN *** 1301,1308 **** } else { ! result = (query->x <= key->high.x && query->x >= key->low.x && ! query->y <= key->high.y && query->y >= key->low.y); } break; default: --- 1302,1311 ---- } else { ! result = (FPle(query->x, key->high.x) && ! FPge(query->x, key->low.x) && ! FPle(query->y, key->high.y) && ! FPge(query->y, key->low.y)); } break; default: *************** gist_point_consistent(PG_FUNCTION_ARGS) *** 1337,1349 **** *recheck = false; break; case BoxStrategyNumberGroup: ! result = DatumGetBool(DirectFunctionCall5( ! gist_box_consistent, ! PointerGetDatum(entry), ! PG_GETARG_DATUM(1), ! Int16GetDatum(RTOverlapStrategyNumber), ! 0, PointerGetDatum(recheck))); ! break; case PolygonStrategyNumberGroup: { POLYGON *query = PG_GETARG_POLYGON_P(1); --- 1340,1369 ---- *recheck = false; break; case BoxStrategyNumberGroup: ! { ! /* ! * This code repeats logic of on_ob which checks if point is ! * contained in box using strict comparison rather than FP* ! * functions. We could use box_overlap for internal pages, but ! * it implements fuzzy comparison using FP* functions which ! * leads to redundant result. That's why we implement strict ! * overlap checking for internal pages here. However, when box ! * is reduced to point overlap becomes the same as containment. ! * That's why we use same comparison for leaf and internal ! * pages. ! */ ! BOX *query, *key; ! ! query = PG_GETARG_BOX_P(1); ! key = DatumGetBoxP(entry->key); ! ! *recheck = false; ! result = key->high.x >= query->low.x && ! key->low.x <= query->high.x && ! key->high.y >= query->low.y && ! key->low.y <= query->high.y; ! break; ! } case PolygonStrategyNumberGroup: { POLYGON *query = PG_GETARG_POLYGON_P(1); diff --git a/src/test/regress/expected/point.out b/src/test/regress/expected/point.out new file mode 100644 index 7929229..2aee076 *** a/src/test/regress/expected/point.out --- b/src/test/regress/expected/point.out *************** SELECT '' AS three, p1.f1 AS point1, p2. *** 245,247 **** --- 245,271 ---- | (5.1,34.5) | (10,10) | 24.9851956166046 (3 rows) + -- Testing GiST indexes provides same behaviour as sequential scan + SET enable_seqscan TO false; + CREATE TABLE POINT_GIST_TBL(f1 point); + INSERT INTO POINT_GIST_TBL (SELECT '(0,0)' FROM generate_series(0,1000)); + CREATE INDEX POINT_GIST_TBL_INDEX ON POINT_GIST_TBL USING gist (f1); + INSERT INTO POINT_GIST_TBL VALUES ('(0.0000009,0.0000009)'); + SELECT COUNT(*) FROM POINT_GIST_TBL WHERE f1 ~= '(0.0000009,0.0000009)'::point; + count + ------- + 1002 + (1 row) + + SELECT COUNT(*) FROM POINT_GIST_TBL WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box; + count + ------- + 1 + (1 row) + + SELECT COUNT(*) FROM POINT_GIST_TBL WHERE f1 ~= '(0.0000018,0.0000018)'::point; + count + ------- + 1 + (1 row) + diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out new file mode 100644 index 3f04442..b9536d1 *** a/src/test/regress/expected/sanity_check.out --- b/src/test/regress/expected/sanity_check.out *************** SELECT relname, relhasindex *** 134,139 **** --- 134,140 ---- pg_ts_template | t pg_type | t pg_user_mapping | t + point_gist_tbl | t point_tbl | t polygon_tbl | t quad_point_tbl | t *************** SELECT relname, relhasindex *** 166,172 **** timetz_tbl | f tinterval_tbl | f varchar_tbl | f ! (155 rows) -- -- another sanity check: every system catalog that has OIDs should have --- 167,173 ---- timetz_tbl | f tinterval_tbl | f varchar_tbl | f ! (156 rows) -- -- another sanity check: every system catalog that has OIDs should have diff --git a/src/test/regress/output/misc.source b/src/test/regress/output/misc.source new file mode 100644 index 4353d0b..1d0fc40 *** a/src/test/regress/output/misc.source --- b/src/test/regress/output/misc.source *************** SELECT user_relns() AS user_relns *** 656,661 **** --- 656,662 ---- onek2 path_tbl person + point_gist_tbl point_tbl polygon_tbl quad_point_tbl *************** SELECT user_relns() AS user_relns *** 686,692 **** toyemp varchar_tbl xacttest ! (108 rows) SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))); name --- 687,693 ---- toyemp varchar_tbl xacttest ! (109 rows) SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))); name diff --git a/src/test/regress/sql/point.sql b/src/test/regress/sql/point.sql new file mode 100644 index 1b62b10..36bff19 *** a/src/test/regress/sql/point.sql --- b/src/test/regress/sql/point.sql *************** SELECT '' AS three, p1.f1 AS point1, p2. *** 80,82 **** --- 80,93 ---- FROM POINT_TBL p1, POINT_TBL p2 WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 and p1.f1 >^ p2.f1 ORDER BY distance; + + -- Testing GiST indexes provides same behaviour as sequential scan + SET enable_seqscan TO false; + CREATE TABLE POINT_GIST_TBL(f1 point); + INSERT INTO POINT_GIST_TBL (SELECT '(0,0)' FROM generate_series(0,1000)); + CREATE INDEX POINT_GIST_TBL_INDEX ON POINT_GIST_TBL USING gist (f1); + INSERT INTO POINT_GIST_TBL VALUES ('(0.0000009,0.0000009)'); + SELECT COUNT(*) FROM POINT_GIST_TBL WHERE f1 ~= '(0.0000009,0.0000009)'::point; + SELECT COUNT(*) FROM POINT_GIST_TBL WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box; + SELECT COUNT(*) FROM POINT_GIST_TBL WHERE f1 ~= '(0.0000018,0.0000018)'::point; +