List:Internals« Previous MessageNext Message »
From:holyfoot Date:April 29 2005 10:17am
Subject:bk commit into 5.0 tree (hf:1.1915)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf 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
  1.1915 05/04/29 13:16:54 hf@deer.(none) +11 -0
  Combined fix for bugs #6553 and #8776 (both about errors on wrong data sent
  to the GEOMETRY field)

  sql/sql_base.cc
    1.236 05/04/29 13:14:56 hf@deer.(none) +4 -1
    check for -2 returned from save_in_field() added

  sql/spatial.h
    1.13 05/04/29 13:14:56 hf@deer.(none) +2 -0
    bad_geometry_data interface

  sql/spatial.cc
    1.20 05/04/29 13:14:56 hf@deer.(none) +2 -0
    bad_geometry_data instance

  sql/share/errmsg.txt
    1.29 05/04/29 13:14:56 hf@deer.(none) +2 -0
    error message added

  sql/item_geofunc.cc
    1.21 05/04/29 13:14:56 hf@deer.(none) +2 -2
    returning bad_geometry_data

  sql/field.h
    1.154 05/04/29 13:14:56 hf@deer.(none) +3 -3
    Field_geom interface fixed

  sql/field.cc
    1.257 05/04/29 13:14:56 hf@deer.(none) +30 -2
    Field_geom::store* methods modified to return -2

  mysql-test/t/gis.test
    1.18 05/04/29 13:14:56 hf@deer.(none) +14 -2
    test case fixed

  mysql-test/t/gis-rtree.test
    1.11 05/04/29 13:14:56 hf@deer.(none) +1 -1
    test case fixed

  mysql-test/r/gis.result
    1.22 05/04/29 13:14:56 hf@deer.(none) +12 -2
    Test result fixed

  mysql-test/r/gis-rtree.result
    1.12 05/04/29 13:14:56 hf@deer.(none) +1 -1
    Test result fixed

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	hf
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.0.spaerrs

--- 1.256/sql/field.cc	Thu Apr 14 14:32:18 2005
+++ 1.257/sql/field.cc	Fri Apr 29 13:14:56 2005
@@ -7267,12 +7267,38 @@
 }
 
 
+int Field_geom::store(double nr)
+{
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -2;
+}
+
+
+int Field_geom::store(longlong nr)
+{
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -2;
+}
+
+
+int Field_geom::store_decimal(const my_decimal *)
+{
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -2;
+}
+
+
 int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
 {
   if (!length)
     bzero(ptr, Field_blob::pack_length());
   else
   {
+    if (from == Geometry::bad_geometry_data.ptr())
+      goto err;
     // Check given WKB
     uint32 wkb_type;
     if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2)
@@ -7280,7 +7306,7 @@
     wkb_type= uint4korr(from + WKB_HEADER_SIZE);
     if (wkb_type < (uint32) Geometry::wkb_point ||
 	wkb_type > (uint32) Geometry::wkb_end)
-      return -1;
+      goto err;
     Field_blob::store_length(length);
     if (table->copy_blobs || length <= MAX_FIELD_WIDTH)
     {						// Must make a copy
@@ -7293,7 +7319,9 @@
 
 err:
   bzero(ptr, Field_blob::pack_length());  
-  return -1;
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -2;
 }
 
 #endif /*HAVE_SPATIAL*/

--- 1.153/sql/field.h	Thu Apr 14 14:32:18 2005
+++ 1.154/sql/field.h	Fri Apr 29 13:14:56 2005
@@ -1189,9 +1189,9 @@
   enum_field_types type() const { return FIELD_TYPE_GEOMETRY; }
   void sql_type(String &str) const;
   int  store(const char *to, uint length, CHARSET_INFO *charset);
-  int  store(double nr) { return 1; }
-  int  store(longlong nr) { return 1; }
-  int  store_decimal(const my_decimal *) { return 1; }
+  int  store(double nr);
+  int  store(longlong nr);
+  int  store_decimal(const my_decimal *);
   void get_key_image(char *buff,uint length,imagetype type);
 };
 #endif /*HAVE_SPATIAL*/

--- 1.235/sql/sql_base.cc	Thu Apr 14 10:54:50 2005
+++ 1.236/sql/sql_base.cc	Fri Apr 29 13:14:56 2005
@@ -3819,7 +3819,10 @@
     TABLE *table= rfield->table;
     if (rfield == table->next_number_field)
       table->auto_increment_field_not_null= TRUE;
-    if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
+    int save_result= value->save_in_field(rfield, 0);
+    if (save_result == -2)
+      DBUG_RETURN(TRUE);
+    if ((save_result < 0) && !ignore_errors)
     {
       my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
       DBUG_RETURN(TRUE);

--- 1.28/sql/share/errmsg.txt	Wed Apr 27 19:35:43 2005
+++ 1.29/sql/share/errmsg.txt	Fri Apr 29 13:14:56 2005
@@ -5344,3 +5344,5 @@
 	eng "OUT or INOUT argument %d for routine %s is not a variable"
 ER_SP_NO_RETSET_IN_FUNC 0A000
 	eng "Not allowed to return a result set from a function"
+ER_CANT_CREATE_GEOMETRY_OBJECT 22003 
+	eng "Cannot get geometry object from data you send to the GEOMETRY field"

--- 1.19/sql/spatial.cc	Fri Oct 22 20:31:27 2004
+++ 1.20/sql/spatial.cc	Fri Apr 29 13:14:56 2005
@@ -22,6 +22,8 @@
 
 /***************************** Gis_class_info *******************************/
 
+String Geometry::bad_geometry_data("Bad object", &my_charset_bin);
+
 Geometry::Class_info *Geometry::ci_collection[Geometry::wkb_end+1]=
 {
   NULL, NULL, NULL, NULL, NULL, NULL, NULL

--- 1.12/sql/spatial.h	Fri Oct 22 20:44:48 2004
+++ 1.13/sql/spatial.h	Fri Apr 29 13:14:56 2005
@@ -173,6 +173,8 @@
   static void operator delete(void *ptr, void *buffer)
   {}
 
+  static String bad_geometry_data;
+
   enum wkbType
   {
     wkb_point= 1,

--- 1.11/mysql-test/r/gis-rtree.result	Fri Jan 14 23:29:40 2005
+++ 1.12/mysql-test/r/gis-rtree.result	Fri Apr 29 13:14:56 2005
@@ -801,5 +801,5 @@
 INSERT INTO t1 VALUES ("Fake string");
 CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom));
 INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
-ERROR HY000: Unknown error
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
 drop table t1, t2;

--- 1.21/mysql-test/r/gis.result	Fri Dec 10 13:06:16 2004
+++ 1.22/mysql-test/r/gis.result	Fri Apr 29 13:14:56 2005
@@ -461,9 +461,9 @@
 create table t1 (a geometry not null);
 insert into t1 values (GeomFromText('Point(1 2)'));
 insert into t1 values ('Garbage');
-ERROR HY000: Unknown error
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
 insert IGNORE into t1 values ('Garbage');
-ERROR HY000: Unknown error
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
 alter table t1 add spatial index(a);
 drop table t1;
 create table t1(a geometry not null, spatial index(a));
@@ -654,4 +654,14 @@
 t1 where object_id=85984;
 object_id	geometrytype(geo)	ISSIMPLE(GEO)	ASTEXT(centroid(geo))
 85984	MULTIPOLYGON	0	POINT(-114.87787186923 36.33101763469)
+drop table t1;
+create table t1 (fl geometry);
+insert into t1 values (1);
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
+insert into t1 values (1.11);
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
+insert into t1 values ("qwerty");
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
+insert into t1 values (pointfromtext('point(1,1)'));
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
 drop table t1;

--- 1.10/mysql-test/t/gis-rtree.test	Fri Jan 14 07:10:57 2005
+++ 1.11/mysql-test/t/gis-rtree.test	Fri Apr 29 13:14:56 2005
@@ -168,6 +168,6 @@
 CREATE TABLE t1 (st varchar(100));
 INSERT INTO t1 VALUES ("Fake string");
 CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom));
---error 1105
+--error 1416
 INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
 drop table t1, t2;

--- 1.17/mysql-test/t/gis.test	Fri Oct 22 20:31:27 2004
+++ 1.18/mysql-test/t/gis.test	Fri Apr 29 13:14:56 2005
@@ -165,9 +165,9 @@
 
 create table t1 (a geometry not null);
 insert into t1 values (GeomFromText('Point(1 2)'));
--- error 1105
+-- error 1416
 insert into t1 values ('Garbage');
--- error 1105
+-- error 1416
 insert IGNORE into t1 values ('Garbage');
 alter table t1 add spatial index(a);
 
@@ -357,5 +357,17 @@
 
 select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
 t1 where object_id=85984;
+
+drop table t1;
+
+create table t1 (fl geometry);
+--error 1416
+insert into t1 values (1);
+--error 1416
+insert into t1 values (1.11);
+--error 1416
+insert into t1 values ("qwerty");
+--error 1416
+insert into t1 values (pointfromtext('point(1,1)'));
 
 drop table t1;

--- 1.20/sql/item_geofunc.cc	Tue Dec 21 14:37:34 2004
+++ 1.21/sql/item_geofunc.cc	Fri Apr 29 13:14:56 2005
@@ -55,8 +55,8 @@
     return 0;
   str->length(0);
   str->q_append(srid);
-  if ((null_value= !Geometry::create_from_wkt(&buffer, &trs, str, 0)))
-    return 0;
+  if (!Geometry::create_from_wkt(&buffer, &trs, str, 0))
+    return &Geometry::bad_geometry_data;
   return str;
 }
 
Thread
bk commit into 5.0 tree (hf:1.1915)holyfoot29 Apr