Commit b37b52a3 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-4922 Stored Procedure - Geometry parameter not working.

  Fhe GEOMETRY field should be handled just as the BLOB field. So that was fiexed in field_conv.
  One additional bug was found and fixed meanwhile - thet the geometry field subtypes
  should also be merged for UNION command.
parent 69ed429a
......@@ -934,7 +934,7 @@ LINESTRING(0 0,1 1,2 2)
create table t2 as select f2 as a from t1 union select f3 from t1;
desc t2;
Field Type Null Key Default Extra
a point YES NULL
a geometry YES NULL
select AsText(a) from t2;
AsText(a)
POINT(1 1)
......
......@@ -7629,6 +7629,14 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
return -1;
}
Field::geometry_type Field_geom::geometry_type_merge(geometry_type a,
geometry_type b)
{
if (a == b)
return a;
return Field::GEOM_GEOMETRY;
}
#endif /*HAVE_SPATIAL*/
/****************************************************************************
......
......@@ -1998,6 +1998,7 @@ class Field_geom :public Field_blob {
int reset(void) { return Field_blob::reset() || !maybe_null(); }
geometry_type get_geometry_type() { return geom_type; };
static geometry_type geometry_type_merge(geometry_type, geometry_type);
};
#endif /*HAVE_SPATIAL*/
......
......@@ -828,8 +828,9 @@ Copy_field::get_copy_func(Field *to,Field *from)
int field_conv(Field *to,Field *from)
{
bool blob_type_dest= to->flags & BLOB_FLAG;
if (to->real_type() == from->real_type() &&
!(to->type() == MYSQL_TYPE_BLOB && to->table->copy_blobs))
!(blob_type_dest && to->table->copy_blobs))
{
if (to->pack_length() == from->pack_length() &&
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
......@@ -858,7 +859,7 @@ int field_conv(Field *to,Field *from)
return 0;
}
}
if (to->type() == MYSQL_TYPE_BLOB)
if (blob_type_dest)
{ // Be sure the value is stored
Field_blob *blob=(Field_blob*) to;
from->val_str(&blob->value);
......
......@@ -9486,6 +9486,11 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
item_decimals= 0;
decimals= max(decimals, item_decimals);
}
if (fld_type == FIELD_TYPE_GEOMETRY)
geometry_type=
Field_geom::geometry_type_merge(geometry_type, item->get_geometry_type());
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
{
decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment