[postgis-users] Re: bug in bbox containment operators

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Tue Feb 10 03:08:12 PST 2004


Hi Dave/Greg,

Isn't this the same as the bug I had a look at last year? (see
http://postgis.refractions.net/pipermail/postgis-users/2003-March/002177
.html).

>From what I remember, the problem was that the box_overlap() routine
(which is borrowed from the in-built Rtree PostgreSQL implementation)
doesn't seem to function as you would expect - hence I wrote my own
implementation! I guess the box_contained() is another version of the
function that Dave is trying to see if this fixes the problem. The files
mentioned in the email above are still available at
http://www.zen9662.zen.co.uk/postgis/. IIRC, while the cause was
determined, no fix was implemented in PostGIS.

Another option may be to indicate in the operator class that @ is a
lossy operator, i.e. by adding the RECHECK clause to the operator class
(see the third paragraph on
http://www.postgresql.org/docs/7.3/static/xindex-opclass-features.html).
This would force PostgreSQL to apply the original operator to the
results returned from the index which should solve the problem. The bad
thing about this is that it still leaves the faulty box_overlap()
routine in place which IMHO should be corrected, as an overlap routine
which doesn't correctly calculate an overlap is clearly broken in my
book.


Hope this helps,

Mark.


---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net 
> [mailto:postgis-users-bounces at postgis.refractions.net] On 
> Behalf Of Greg Janée
> Sent: 09 February 2004 23:42
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Re: bug in bbox containment operators
> 
> 
> David Blasby wrote:
> >If this all works, then try removing the index ("DROP INDEX <index 
> >name>")
> >from your table and running your query again.
> >
> >If this gives the correct answer, then its a problem with the RTree
> >implementation.
> 
> The above all worked as you suggested.  The original 
> problematic query 
> works fine when the index is removed.
> 
> >Try this fix:
> >
> >Modify postgis_gist_72.c, line about 204 that is currently:
> >     case RTContainsStrategyNumber:
> >       retval = DatumGetBool( DirectFunctionCall2( box_contain,
> > PointerGetDatum(key), PointerGetDatum(query) ) );
> >
> >change the "box_contain" to "box_contained", recompile, 
> install, create 
> >an
> >index on your table, vacuum analyse and re-try your query.
> >
> >Does that fix it?
> 
> Nope.  Tried the above, but we still see the same bad 
> behavior.  8-( -Greg
> 
> _______________________________________________
> postgis-users mailing list postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 





More information about the postgis-users mailing list