Hi!
On Jul 05, kgeorge@stripped wrote:
> ChangeSet@stripped, 2007-07-05 16:06:51+03:00, gkodinov@stripped +3 -0
> Bug #29070: Error in spatial index
> The MBR for a key is stored on disk. Therefore it must be in
> platform independent byte order.
> Fixed by reading and writing to/from the MBR in platform
> independent byte order.
>
> myisam/sp_key.c@stripped, 2007-07-05 16:06:50+03:00, gkodinov@stripped +13 -8
> Bug #29070: since the MBR for a key is stored on disk it must be in
> platform independent byte order and must be treated consistently
> as such
>
> diff -Nrup a/myisam/sp_key.c b/myisam/sp_key.c
> --- a/myisam/sp_key.c 2006-12-23 21:04:06 +02:00
> +++ b/myisam/sp_key.c 2007-07-05 16:06:50 +03:00
> @@ -83,7 +83,7 @@ uint sp_make_key(register MI_INFO *info,
> else if (keyseg->type == HA_KEYTYPE_DOUBLE)
> {
> double nr;
> - get_double(&nr, pos);
> + float8get(nr, pos);
I don't undestand it.
get_double(), as far as I can see uses float8get().
> if (isnan(nr))
> {
> bzero(key, length);
> @@ -116,11 +116,14 @@ stored in "well-known binary representat
> static int sp_mbr_from_wkb(uchar *wkb, uint size, uint n_dims, double *mbr)
> {
> uint i;
> + double dbl_max= DBL_MAX, neg_dbl_max= -DBL_MAX;
>
> for (i=0; i < n_dims; ++i)
> {
> - mbr[i * 2] = DBL_MAX;
> - mbr[i * 2 + 1] = -DBL_MAX;
> + char *mbr_ptr= (char *) (mbr + (i * 2));
> + float8store(mbr_ptr, dbl_max);
> + mbr_ptr+= sizeof(double);
> + float8store(mbr_ptr, neg_dbl_max);
I don't get it either.
mbr[] is an array of doubles, not a byte array. Why do you use
float8store to store doubles in it ?
(and mbr[] values ARE used as doubles later, e.g. they're compared as
doubles. Swapping the bytes in them simply won't work)
> }
>
> return sp_get_geometry_mbr(&wkb, wkb + size, n_dims, mbr, 1);
> @@ -134,19 +137,21 @@ static int sp_add_point_to_mbr(uchar *(*
> uchar byte_order __attribute__((unused)),
> double *mbr)
> {
> - double ord;
> + double ord, mbr_val;
> double *mbr_end= mbr + n_dims * 2;
>
> while (mbr < mbr_end)
> {
> if ((*wkb) > end - 8)
> return -1;
> - get_double(&ord, (const byte*) *wkb);
> + float8get(ord, (const byte*) *wkb);
And here. get_double == float8get
> + float8get(mbr_val, (const byte*) mbr);
And here. you don't need float8get to read a double from double*.
> (*wkb)+= 8;
> - if (ord < *mbr)
> + if (ord < mbr_val)
> float8store((char*) mbr, ord);
> mbr++;
> - if (ord > *mbr)
> + float8get(mbr_val, (const byte*) mbr);
> + if (ord > mbr_val)
same here
> float8store((char*) mbr, ord);
> mbr++;
> }
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Radlkoferstr. 2, D-81373 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140