Skip to content

Commit b37b52a

Browse files
author
Alexey Botchkov
committed
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.
1 parent 69ed429 commit b37b52a

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

mysql-test/r/gis.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ LINESTRING(0 0,1 1,2 2)
934934
create table t2 as select f2 as a from t1 union select f3 from t1;
935935
desc t2;
936936
Field Type Null Key Default Extra
937-
a point YES NULL
937+
a geometry YES NULL
938938
select AsText(a) from t2;
939939
AsText(a)
940940
POINT(1 1)

sql/field.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7629,6 +7629,14 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
76297629
return -1;
76307630
}
76317631

7632+
Field::geometry_type Field_geom::geometry_type_merge(geometry_type a,
7633+
geometry_type b)
7634+
{
7635+
if (a == b)
7636+
return a;
7637+
return Field::GEOM_GEOMETRY;
7638+
}
7639+
76327640
#endif /*HAVE_SPATIAL*/
76337641

76347642
/****************************************************************************

sql/field.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,7 @@ class Field_geom :public Field_blob {
19981998
int reset(void) { return Field_blob::reset() || !maybe_null(); }
19991999

20002000
geometry_type get_geometry_type() { return geom_type; };
2001+
static geometry_type geometry_type_merge(geometry_type, geometry_type);
20012002
};
20022003
#endif /*HAVE_SPATIAL*/
20032004

sql/field_conv.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,9 @@ Copy_field::get_copy_func(Field *to,Field *from)
828828

829829
int field_conv(Field *to,Field *from)
830830
{
831+
bool blob_type_dest= to->flags & BLOB_FLAG;
831832
if (to->real_type() == from->real_type() &&
832-
!(to->type() == MYSQL_TYPE_BLOB && to->table->copy_blobs))
833+
!(blob_type_dest && to->table->copy_blobs))
833834
{
834835
if (to->pack_length() == from->pack_length() &&
835836
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
@@ -858,7 +859,7 @@ int field_conv(Field *to,Field *from)
858859
return 0;
859860
}
860861
}
861-
if (to->type() == MYSQL_TYPE_BLOB)
862+
if (blob_type_dest)
862863
{ // Be sure the value is stored
863864
Field_blob *blob=(Field_blob*) to;
864865
from->val_str(&blob->value);

sql/item.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9486,6 +9486,11 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
94869486
item_decimals= 0;
94879487
decimals= max(decimals, item_decimals);
94889488
}
9489+
9490+
if (fld_type == FIELD_TYPE_GEOMETRY)
9491+
geometry_type=
9492+
Field_geom::geometry_type_merge(geometry_type, item->get_geometry_type());
9493+
94899494
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
94909495
{
94919496
decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);

0 commit comments

Comments
 (0)