After a little bit more testing, I have verified that the problem is only 
present with postgres 7.3.x, however the fix that dave and I put in the CVS 
this morning doesn't seem to fix ALL of the problem.

The following session demonstrates the problem (if it is readable). Basically, 
the three geometries I create should give the results of the first two queries 
(6 result pairs). Those results are created using a sequence scan, because the 
table is so small that an index isn't efficient to use. When I turn off 
seqscan, the index is used to find matching rows, and ALL rows are identified 
as matching... this problem may be less prominent on a larger table, but 
clearly something is wrong. This is not a problem on postgres 7.2.x. After 
looking through the code and comparing it with the contrib/rtree_gist code to 
ensure the operator class is being created correctly, etc., I have not been 
able to locate the problem. 

I am going to leave it alone for a while and come back to it with a fresh 
outlook. If anyone else can offer a clue here, I would appreciate it...

Chris

chodgson=# create table foo (id int );
CREATE TABLE
chodgson=# select AddGeometryColumn( 'chodgson', 'foo', 'the_geom', -
1, 'GEOMETRY', 3 );
                                addgeometrycolumn
--------------------------------------------------------------------------------
-
 Geometry column the_geom added to table foo WITH a SRID of -1 and type GEOMETRY
(1 row)

chodgson=# insert into foo values( 1, 'POINT( 1 1)' );
INSERT 552524 1
chodgson=# insert into foo values( 1, 'LINESTRING( 1 1, 2 2)' );
INSERT 552525 1
chodgson=# insert into foo values( 1, 'POLYGON(( 1 1, 2 2, 3 3, 1 1))' );
INSERT 552526 1
chodgson=# create index idx_foo_geom on foo using gist(the_geom 
gist_geometry_ops);
CREATE INDEX
chodgson=# vacuum analyze;
VACUUM
chodgson=# select * from foo a, foo b where a.the_geom ~ b.the_geom;
 id |              the_geom              | id |              the_geom
----+------------------------------------+----+---------------------------------
---
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
(6 rows)

chodgson=# select * from foo a, foo b where a.the_geom @ b.the_geom;
 id |              the_geom              | id |              the_geom
----+------------------------------------+----+---------------------------------
---
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
(6 rows)

chodgson=# set enable_seqscan=off;
SET
chodgson=# select * from foo a, foo b where a.the_geom ~ b.the_geom;
 id |              the_geom              | id |              the_geom
----+------------------------------------+----+---------------------------------
---
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
(9 rows)

chodgson=# select * from foo a, foo b where a.the_geom @ b.the_geom;
 id |              the_geom              | id |              the_geom
----+------------------------------------+----+---------------------------------
---
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POINT(1 1)                 |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;LINESTRING(1 1,2 2)        |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POINT(1 1)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;LINESTRING(1 1,2 2)
  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 1)) |  1 | SRID=-1;POLYGON((1 1,2 2,3 3,1 
1))
(9 rows)





