From 190fb8960aab98c41d746f8a42f4a1022744a31d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Dec 2002 17:17:35 +0400 Subject: [PATCH] Spatial-related fixes sql/item_strfunc.cc: spatial function's fixes sql/spatial.cc: spatial type comperations are case-independent now sql/sql_string.h: this is a bit safer BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + sql/item_strfunc.cc | 22 +++++++++++++++------- sql/spatial.cc | 4 ++-- sql/sql_string.h | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 15f884302a1..c8834a9997e 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -21,6 +21,7 @@ heikki@donna.mysql.fi heikki@hundin.mysql.fi heikki@rescue. heikki@work.mysql.com +hf@deer.mysql.r18.ru hf@genie.(none) jani@dsl-jkl1657.dial.inet.fi jani@hynda.(none) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 473c4538ab1..0f70ca7a976 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2436,7 +2436,8 @@ General functions for spatial objects String *Item_func_geometry_from_text::val_str(String *str) { Geometry geom; - String *wkt = args[0]->val_str(str); + String arg_val; + String *wkt = args[0]->val_str(&arg_val); GTextReadStream trs(wkt->ptr(), wkt->length()); str->length(0); @@ -2454,7 +2455,8 @@ void Item_func_geometry_from_text::fix_length_and_dec() String *Item_func_as_text::val_str(String *str) { - String *wkt = args[0]->val_str(str); + String arg_val; + String *wkt = args[0]->val_str(&arg_val); Geometry geom; if ((null_value=(args[0]->null_value || @@ -2491,7 +2493,8 @@ String *Item_func_geometry_type::val_str(String *str) String *Item_func_envelope::val_str(String *str) { - String *wkb = args[0]->val_str(str); + String arg_val; + String *wkb = args[0]->val_str(&arg_val); Geometry geom; null_value = args[0]->null_value || @@ -2504,7 +2507,8 @@ String *Item_func_envelope::val_str(String *str) String *Item_func_centroid::val_str(String *str) { - String *wkb = args[0]->val_str(str); + String arg_val; + String *wkb = args[0]->val_str(&arg_val); Geometry geom; null_value = args[0]->null_value || @@ -2522,7 +2526,8 @@ String *Item_func_centroid::val_str(String *str) String *Item_func_spatial_decomp::val_str(String *str) { - String *wkb = args[0]->val_str(str); + String arg_val; + String *wkb = args[0]->val_str(&arg_val); Geometry geom; if ((null_value = (args[0]->null_value || @@ -2530,6 +2535,7 @@ String *Item_func_spatial_decomp::val_str(String *str) return 0; null_value=1; + str->length(0); switch(decomp_func) { case SP_STARTPOINT: @@ -2559,7 +2565,8 @@ ret: String *Item_func_spatial_decomp_n::val_str(String *str) { - String *wkb = args[0]->val_str(str); + String arg_val; + String *wkb = args[0]->val_str(&arg_val); long n = (long) args[1]->val_int(); Geometry geom; @@ -2639,6 +2646,7 @@ String *Item_func_point::val_str(String *str) String *Item_func_spatial_collection::val_str(String *str) { + String arg_value; uint i; null_value=1; @@ -2656,7 +2664,7 @@ String *Item_func_spatial_collection::val_str(String *str) if (args[i]->null_value) goto ret; - String *res = args[i]->val_str(str); + String *res = args[i]->val_str(&arg_value); if ( coll_type == Geometry::wkbGeometryCollection ) { diff --git a/sql/spatial.cc b/sql/spatial.cc index b21d30e4b53..1e2b9f1c512 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -44,7 +44,7 @@ static Geometry::GClassInfo ci_collection[] = IMPLEMENT_GEOM(GGeometryCollection, wkbGeometryCollection, "GEOMETRYCOLLECTION") }; -static Geometry::GClassInfo *ci_collection_end = ci_collection + sizeof(ci_collection); +static Geometry::GClassInfo *ci_collection_end = ci_collection + sizeof(ci_collection)/sizeof(ci_collection[0]); /***************************** Geometry *******************************/ @@ -66,7 +66,7 @@ Geometry::GClassInfo *Geometry::find_class(const char *name, size_t len) cur_rt < ci_collection_end; ++cur_rt) { if ((cur_rt->m_name[len] == 0) && - (strncmp(cur_rt->m_name, name, len) == 0)) + (strncasecmp(cur_rt->m_name, name, len) == 0)) { return cur_rt; } diff --git a/sql/sql_string.h b/sql/sql_string.h index d7447dd6ed6..afcc3d74530 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -225,7 +225,7 @@ public: { Ptr[str_length++] = c; } - void q_append(const uint32 &n) + void q_append(const uint32 n) { int4store(Ptr + str_length, n); str_length += 4;