List:Commits« Previous MessageNext Message »
From:kgeorge Date:July 9 2007 10:24am
Subject:bk commit into 5.0 tree (gkodinov:1.2516) BUG#29070
View as plain text  
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-09 13:24:04+03:00, gkodinov@stripped +3 -0
  Bug #29070: Error in spatial index
  1. Threat MBR for a key as double[] and convert it only
  when about to store it on disk.
  2. Remove the redundant function get_double().

  myisam/sp_key.c@stripped, 2007-07-09 13:24:03+03:00, gkodinov@stripped +15 -13
    Bug #29070: 
    1. threat MBR for a key as double[] and convert it only
    when about to store it on disk.
    2. remove the redundant function get_double() 

  mysql-test/r/gis-rtree.result@stripped, 2007-07-09 13:24:03+03:00, gkodinov@stripped +13 -0
    Bug #29070: test case

  mysql-test/t/gis-rtree.test@stripped, 2007-07-09 13:24:03+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-09 13:24:03 +03:00
@@ -31,11 +31,6 @@ static int sp_get_geometry_mbr(uchar *(*
                               double *mbr, int top);
 static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr);
 
-static void get_double(double *d, const byte *pos)
-{
-  float8get(*d, pos);
-}
-  
 uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
 		 const byte *record, my_off_t filepos)
 {
@@ -70,8 +65,7 @@ uint sp_make_key(register MI_INFO *info,
 #ifdef HAVE_ISNAN
       if (keyseg->type == HA_KEYTYPE_FLOAT)
       {
-	float nr;
-	float4get(nr, pos);
+	float nr= (float)mbr[i];
 	if (isnan(nr))
 	{
 	  /* Replace NAN with zero */
@@ -82,8 +76,7 @@ uint sp_make_key(register MI_INFO *info,
       }
       else if (keyseg->type == HA_KEYTYPE_DOUBLE)
       {
-	double nr;
-	get_double(&nr, pos);
+        double nr= mbr[i];
 	if (isnan(nr))
 	{
  	  bzero(key, length);
@@ -116,6 +109,8 @@ stored in "well-known binary representat
 static int sp_mbr_from_wkb(uchar *wkb, uint size, uint n_dims, double *mbr)
 {
   uint i;
+  int res;
+  double *mbr_end= mbr + n_dims * 2;
 
   for (i=0; i < n_dims; ++i)
   {
@@ -123,7 +118,14 @@ static int sp_mbr_from_wkb(uchar *wkb, u
     mbr[i * 2 + 1] = -DBL_MAX;
   }
 
-  return sp_get_geometry_mbr(&wkb, wkb + size, n_dims, mbr, 1);
+  if (!(res= sp_get_geometry_mbr(&wkb, wkb + size, n_dims, mbr, 1)))
+    for (; mbr < mbr_end; mbr++)
+    {
+      double val= *mbr;
+      char *mbr_ptr= (char *) mbr;
+      float8store(mbr_ptr, val);
+    }
+  return res;
 }
 
 /*
@@ -141,13 +143,13 @@ static int sp_add_point_to_mbr(uchar *(*
   {
     if ((*wkb) > end - 8)
       return -1;
-    get_double(&ord, (const byte*) *wkb);
+    float8get(ord, (const byte*) *wkb);
     (*wkb)+= 8;
     if (ord < *mbr)
-      float8store((char*) mbr, ord);
+      *mbr= ord;
     mbr++;
     if (ord > *mbr)
-      float8store((char*) mbr, ord);
+      *mbr= ord;
     mbr++;
   }
   return 0;
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-09 13:24:03 +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-09 13:24:03 +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#29070kgeorge9 Jul