List:Commits« Previous MessageNext Message »
From:ramil Date:March 5 2007 2:22pm
Subject:bk commit into 5.0 tree (ramil:1.2463)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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-03-05 18:22:35+04:00, ramil@stripped +3 -0
  Merge rkalimullin@stripped:/home/bk/mysql-5.0-maint
  into  mysql.com:/home/ram/work/b26038/b26038.5.0
  MERGE: 1.2417.2.2

  sql/item_geofunc.cc@stripped, 2007-03-05 18:22:31+04:00, ramil@stripped +0 -0
    Auto merged
    MERGE: 1.27.1.4

  sql/spatial.cc@stripped, 2007-03-05 18:22:31+04:00, ramil@stripped +0 -0
    Auto merged
    MERGE: 1.27.1.2

  sql/spatial.h@stripped, 2007-03-05 18:22:31+04:00, ramil@stripped +0 -0
    Auto merged
    MERGE: 1.20.1.3

# 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:	ramil
# Host:	ramil.myoffice.izhnet.ru
# Root:	/home/ram/work/b26038/b26038.5.0/RESYNC

--- 1.30/sql/spatial.cc	2007-03-05 18:22:41 +04:00
+++ 1.31/sql/spatial.cc	2007-03-05 18:22:41 +04:00
@@ -213,23 +213,24 @@ static uint32 wkb_get_uint(const char *p
 }
 
 
-int Geometry::create_from_wkb(Geometry_buffer *buffer,
-                              const char *wkb, uint32 len, String *res)
+Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer,
+                                    const char *wkb, uint32 len, String *res)
 {
   uint32 geom_type;
   Geometry *geom;
 
   if (len < WKB_HEADER_SIZE)
-    return 1;
+    return NULL;
   geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]);
   if (!(geom= create_by_typeid(buffer, (int) geom_type)) ||
       res->reserve(WKB_HEADER_SIZE, 512))
-    return 1;
+    return NULL;
 
   res->q_append((char) wkb_ndr);
   res->q_append(geom_type);
-  return geom->init_from_wkb(wkb+WKB_HEADER_SIZE, len - WKB_HEADER_SIZE,
-                             (wkbByteOrder) wkb[0], res);
+
+  return geom->init_from_wkb(wkb + WKB_HEADER_SIZE, len - WKB_HEADER_SIZE,
+                             (wkbByteOrder) wkb[0], res) ? geom : NULL;
 }
 
 

--- 1.23/sql/spatial.h	2007-03-05 18:22:41 +04:00
+++ 1.24/sql/spatial.h	2007-03-05 18:22:41 +04:00
@@ -246,8 +246,8 @@ public:
   static Geometry *create_from_wkt(Geometry_buffer *buffer,
 				   Gis_read_stream *trs, String *wkt,
 				   bool init_stream=1);
-  static int create_from_wkb(Geometry_buffer *buffer,
-                             const char *wkb, uint32 len, String *res);
+  static Geometry *create_from_wkb(Geometry_buffer *buffer, const char *wkb, 
+                                   uint32 len, String *res);
   int as_wkt(String *wkt, const char **end)
   {
     uint32 len= get_class_info()->m_name.length;

--- 1.30/sql/item_geofunc.cc	2007-03-05 18:22:41 +04:00
+++ 1.31/sql/item_geofunc.cc	2007-03-05 18:22:41 +04:00
@@ -35,6 +35,7 @@ void Item_geometry_func::fix_length_and_
   collation.set(&my_charset_bin);
   decimals=0;
   max_length=MAX_BLOB_WIDTH;
+  maybe_null= 1;
 }
 
 int Item_geometry_func::get_geometry_type() const
@@ -63,11 +64,8 @@ String *Item_func_geometry_from_text::va
     return 0;
   str->length(0);
   str->q_append(srid);
-  if (!Geometry::create_from_wkt(&buffer, &trs, str, 0))
-    /* We shouldn't return NULL here as NULL is a legal spatial object     */
-    /*  Geometry::bad_spatial_data will produce error message beeing stored*/
-    /*  in GEOMETRY field                                                  */
-    return &Geometry::bad_geometry_data;
+  if ((null_value= !Geometry::create_from_wkt(&buffer, &trs, str, 0)))
+    return 0;
   return str;
 }
 
@@ -121,6 +119,7 @@ String *Item_func_as_wkt::val_str(String
 void Item_func_as_wkt::fix_length_and_dec()
 {
   max_length=MAX_BLOB_WIDTH;
+  maybe_null= 1;
 }
 
 
@@ -386,7 +385,8 @@ String *Item_func_spatial_collection::va
   for (i= 0; i < arg_count; ++i)
   {
     String *res= args[i]->val_str(&arg_value);
-    if (args[i]->null_value)
+    uint32 len;
+    if (args[i]->null_value || ((len= res->length()) < WKB_HEADER_SIZE))
       goto err;
 
     if (coll_type == Geometry::wkb_geometrycollection)
@@ -395,13 +395,12 @@ String *Item_func_spatial_collection::va
 	In the case of GeometryCollection we don't need any checkings
 	for item types, so just copy them into target collection
       */
-      if (str->append(res->ptr(), res->length(), (uint32) 512))
+      if (str->append(res->ptr(), len, (uint32) 512))
         goto err;
     }
     else
     {
       enum Geometry::wkbType wkb_type;
-      uint32 len=res->length();
       const char *data= res->ptr() + 1;
 
       /*
@@ -409,8 +408,6 @@ String *Item_func_spatial_collection::va
 	are of specific type, let's do this checking now
       */
 
-      if (len < 5)
-        goto err;
       wkb_type= (Geometry::wkbType) uint4korr(data);
       data+= 4;
       len-= 5;
@@ -532,9 +529,13 @@ longlong Item_func_spatial_rel::val_int(
 longlong Item_func_isempty::val_int()
 {
   DBUG_ASSERT(fixed == 1);
-  String tmp; 
-  null_value=0;
-  return args[0]->null_value ? 1 : 0;
+  String tmp;
+  String *swkb= args[0]->val_str(&tmp);
+  Geometry_buffer buffer;
+  
+  null_value= args[0]->null_value ||
+              !(Geometry::construct(&buffer, swkb->ptr(), swkb->length()));
+  return null_value ? 1 : 0;
 }
 
 
@@ -542,10 +543,11 @@ longlong Item_func_issimple::val_int()
 {
   DBUG_ASSERT(fixed == 1);
   String tmp;
-  String *wkb=args[0]->val_str(&tmp);
-
-  if ((null_value= (!wkb || args[0]->null_value)))
-    return 0;
+  String *swkb= args[0]->val_str(&tmp);
+  Geometry_buffer buffer;
+  
+  null_value= args[0]->null_value ||
+              !(Geometry::construct(&buffer, swkb->ptr(), swkb->length()));
   /* TODO: Ramil or Holyfoot, add real IsSimple calculation */
   return 0;
 }
Thread
bk commit into 5.0 tree (ramil:1.2463)ramil5 Mar