Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA26217; Tue, 26 May 92 21:10:10 -0700
Message-Id: <9205270410.AA26217@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: Rtree problems (Bug ?) [also: dynamic loader warning]
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mao@postgres.berkeley.edu
In-Reply-To: Your message of "Tue, 14 Apr 92 15:52:28 +0700."
             <9204141347.AA28911@postgres.Berkeley.EDU> 
Date: Tue, 26 May 92 21:09:54 PDT

first, a warning to people using the dynamic loader:  you should use
names of fifteen characters or less for the routines that you dynamically
load.  the reason for this is that the released code assumes in several
places that routine names are null-terminated, and this isn't true for
sixteen-character names.  vincent, in particular, you need to change all
occurrences of

    Overright3BoxBox
    Intersect3BoxBox
    Contained3BoxBox

to something shorter.

now, to deal with another bug, specific to the rtree extensions vincent
is doing:

> I have a problem using the R-tree with my own defined 3D box type "BOX3".
> Whenever I define an index on an attribute of this type the
> backend crashes. I think it crashes at the moment the first split occurs.

you're correct, the bug is in the node split code.  your geo-ext3.c
file contains the routine

    int
    Size3Box(box)
       BOX3     *box;
    {
       return ((int) 
	       ((box->xh-box->xl)*(box->yh-box->yl)*(box->zh-box->zl)));
    }

you should change this to

    int
    Size3Box(box)
       BOX3     *box;
    {
       if (box == (BOX3 *) NULL)
	   return(0);
       else
	   return((int) 
		  ((box->xh-box->xl)*(box->yh-box->yl)*(box->zh-box->zl)));
    }

what happens is that your intersection routine returns NULL if two boxes
don't intersect.  the quadratic-cost split algorithm from guttman's paper,
as i implemented it for postgres, computes the sizes of the union and
intersection of the n-dimensional boxes in order to choose an optimal
node split.  Size3Box() got passed the null pointer from the intersect
routine.

i'll fix the split code to check for this condition before calling
the intersect procedure.  for the time being, the change described above
will solve your problem.  i successfully ran your test program on my
system this afternoon, with these modifications.

incidentally, i'm pleased to see you folks are extending the access method
classes like this.  your code was clean, and you uncovered a genuine bug.
let me know if you have further problems -- response times should get
shorter, now that summer is here.
					mike olson
					project sequoia 2000
					uc berkeley
					mao@cs.berkeley.edu
