mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
bug #14807 (GeomFromText() should return MYSQL_TYPE_GEOMETRY)
we didn't have code creating GEOMETRY-type fields from Items (expression results) So i added this code mysql-test/r/gis.result: test result fixed mysql-test/t/gis.test: testcase added sql/item_geofunc.cc: Item_geometry_func::tmp_table_field implemented sql/item_geofunc.h: tmp_table_field() and get_geometry_type() declared
This commit is contained in:
@ -574,11 +574,11 @@ INSERT INTO t1 VALUES(GeomFromText('POINT(367894677 368542487)'));
|
|||||||
INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
|
INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
|
||||||
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
|
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 select POINT(1,3);
|
create table t1 select GeomFromWKB(POINT(1,3));
|
||||||
show create table t1;
|
show create table t1;
|
||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`POINT(1,3)` longblob NOT NULL
|
`GeomFromWKB(POINT(1,3))` geometry NOT NULL default ''
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
drop table t1;
|
drop table t1;
|
||||||
CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
|
CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
|
||||||
@ -704,3 +704,8 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
|
|||||||
def asbinary(g) 252 8192 0 Y 128 0 63
|
def asbinary(g) 252 8192 0 Y 128 0 63
|
||||||
asbinary(g)
|
asbinary(g)
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
create table t1 select GeomFromText('point(1 1)');
|
||||||
|
desc t1;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
GeomFromText('point(1 1)') geometry NO
|
||||||
|
drop table t1;
|
||||||
|
@ -281,7 +281,7 @@ INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
|
|||||||
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
|
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
create table t1 select POINT(1,3);
|
create table t1 select GeomFromWKB(POINT(1,3));
|
||||||
show create table t1;
|
show create table t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
@ -416,3 +416,9 @@ select * from t1;
|
|||||||
select asbinary(g) from t1;
|
select asbinary(g) from t1;
|
||||||
--disable_metadata
|
--disable_metadata
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
|
||||||
|
create table t1 select GeomFromText('point(1 1)');
|
||||||
|
desc t1;
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@
|
|||||||
#ifdef HAVE_SPATIAL
|
#ifdef HAVE_SPATIAL
|
||||||
#include <m_ctype.h>
|
#include <m_ctype.h>
|
||||||
|
|
||||||
|
Field *Item_geometry_func::tmp_table_field(TABLE *t_arg)
|
||||||
|
{
|
||||||
|
return new Field_geom(max_length, maybe_null, name, t_arg,
|
||||||
|
(Field::geometry_type) get_geometry_type());
|
||||||
|
}
|
||||||
|
|
||||||
void Item_geometry_func::fix_length_and_dec()
|
void Item_geometry_func::fix_length_and_dec()
|
||||||
{
|
{
|
||||||
collation.set(&my_charset_bin);
|
collation.set(&my_charset_bin);
|
||||||
@ -32,6 +38,10 @@ void Item_geometry_func::fix_length_and_dec()
|
|||||||
max_length=MAX_BLOB_WIDTH;
|
max_length=MAX_BLOB_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Item_geometry_func::get_geometry_type() const
|
||||||
|
{
|
||||||
|
return (int)Field::GEOM_GEOMETRY;
|
||||||
|
}
|
||||||
|
|
||||||
String *Item_func_geometry_from_text::val_str(String *str)
|
String *Item_func_geometry_from_text::val_str(String *str)
|
||||||
{
|
{
|
||||||
@ -152,6 +162,12 @@ String *Item_func_geometry_type::val_str(String *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Item_func_envelope::get_geometry_type() const
|
||||||
|
{
|
||||||
|
return (int) Field::GEOM_POLYGON;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String *Item_func_envelope::val_str(String *str)
|
String *Item_func_envelope::val_str(String *str)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
@ -176,6 +192,12 @@ String *Item_func_envelope::val_str(String *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Item_func_centroid::get_geometry_type() const
|
||||||
|
{
|
||||||
|
return (int) Field::GEOM_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String *Item_func_centroid::val_str(String *str)
|
String *Item_func_centroid::val_str(String *str)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
@ -310,6 +332,12 @@ err:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
int Item_func_point::get_geometry_type() const
|
||||||
|
{
|
||||||
|
return (int) Field::GEOM_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String *Item_func_point::val_str(String *str)
|
String *Item_func_point::val_str(String *str)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
|
@ -33,6 +33,8 @@ public:
|
|||||||
Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
|
Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
|
||||||
void fix_length_and_dec();
|
void fix_length_and_dec();
|
||||||
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
|
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
|
||||||
|
Field *tmp_table_field(TABLE *t_arg);
|
||||||
|
virtual int get_geometry_type() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_geometry_from_text: public Item_geometry_func
|
class Item_func_geometry_from_text: public Item_geometry_func
|
||||||
@ -89,6 +91,7 @@ public:
|
|||||||
Item_func_centroid(Item *a): Item_geometry_func(a) {}
|
Item_func_centroid(Item *a): Item_geometry_func(a) {}
|
||||||
const char *func_name() const { return "centroid"; }
|
const char *func_name() const { return "centroid"; }
|
||||||
String *val_str(String *);
|
String *val_str(String *);
|
||||||
|
int get_geometry_type() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_envelope: public Item_geometry_func
|
class Item_func_envelope: public Item_geometry_func
|
||||||
@ -97,6 +100,7 @@ public:
|
|||||||
Item_func_envelope(Item *a): Item_geometry_func(a) {}
|
Item_func_envelope(Item *a): Item_geometry_func(a) {}
|
||||||
const char *func_name() const { return "envelope"; }
|
const char *func_name() const { return "envelope"; }
|
||||||
String *val_str(String *);
|
String *val_str(String *);
|
||||||
|
int get_geometry_type() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_point: public Item_geometry_func
|
class Item_func_point: public Item_geometry_func
|
||||||
@ -106,6 +110,7 @@ public:
|
|||||||
Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {}
|
Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {}
|
||||||
const char *func_name() const { return "point"; }
|
const char *func_name() const { return "point"; }
|
||||||
String *val_str(String *);
|
String *val_str(String *);
|
||||||
|
int get_geometry_type() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_spatial_decomp: public Item_geometry_func
|
class Item_func_spatial_decomp: public Item_geometry_func
|
||||||
|
Reference in New Issue
Block a user