summaryrefslogtreecommitdiff
path: root/sql/item_geofunc.cc
diff options
context:
space:
mode:
authorramil/ram@mysql.com/ramil.myoffice.izhnet.ru <>2007-03-05 18:22:35 +0400
committerramil/ram@mysql.com/ramil.myoffice.izhnet.ru <>2007-03-05 18:22:35 +0400
commitfe801fcf5db2f1aadcfa151e66f7e2105e8310d4 (patch)
treee8e2e1eb2f14e501eebbc3b53f140a1fd251f97e /sql/item_geofunc.cc
parentc53433f307d69c1b87d9340ff6a2e9938b436cad (diff)
parentf165316cfcaf52875d56fdf99404c1cf483cb05d (diff)
downloadmariadb-git-fe801fcf5db2f1aadcfa151e66f7e2105e8310d4.tar.gz
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into mysql.com:/home/ram/work/b26038/b26038.5.0
Diffstat (limited to 'sql/item_geofunc.cc')
-rw-r--r--sql/item_geofunc.cc36
1 files changed, 19 insertions, 17 deletions
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index a304c554211..6c012277888 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -35,6 +35,7 @@ void Item_geometry_func::fix_length_and_dec()
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::val_str(String *str)
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 *str)
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::val_str(String *str)
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::val_str(String *str)
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::val_str(String *str)
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;
}