Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-07-05 13:18:54+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 13:18:53+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
mysql-test/r/gis-rtree.result@stripped, 2007-07-05 13:18:53+03:00, gkodinov@stripped +13 -0
Bug #29070: test case
mysql-test/t/gis-rtree.test@stripped, 2007-07-05 13:18:53+03:00, gkodinov@stripped +19 -0
Bug #29070: test case
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 13:18:53 +03:00
@@ -82,8 +82,8 @@ uint sp_make_key(register MI_INFO *info,
}
else if (keyseg->type == HA_KEYTYPE_DOUBLE)
{
- double nr;
- get_double(&nr, pos);
+ double nr;
+ float8get(nr, pos);
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);
}
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);
+ float8get(mbr_val, (const byte*) mbr);
(*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)
float8store((char*) mbr, ord);
mbr++;
}
diff -Nrup a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
--- a/mysql-test/r/gis-rtree.result 2007-03-15 14:21:41 +02:00
+++ b/mysql-test/r/gis-rtree.result 2007-07-05 13:18:53 +03:00
@@ -1444,3 +1444,16 @@ OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1;
+CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
+INSERT INTO t1 VALUES (1, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+INSERT INTO t1 VALUES (2, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+SELECT COUNT(*) FROM t1 WHERE
+MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
+MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+COUNT(*)
+2
+DROP TABLE t1;
+End of 5.0 tests.
diff -Nrup a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
--- a/mysql-test/t/gis-rtree.test 2007-03-08 11:04:58 +02:00
+++ b/mysql-test/t/gis-rtree.test 2007-07-05 13:18:53 +03:00
@@ -827,3 +827,22 @@ INSERT INTO t1 (b) SELECT b FROM t1;
OPTIMIZE TABLE t1;
DROP TABLE t1;
+
+
+#
+# Bug #29070: Error in spatial index
+#
+
+CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
+INSERT INTO t1 VALUES (1, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+INSERT INTO t1 VALUES (2, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+
+# must return the same number as the next select
+SELECT COUNT(*) FROM t1 WHERE
+ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
+ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2516) BUG#29070 | kgeorge | 5 Jul |