Commit 6cca9a0f authored by unknown's avatar unknown

Fix for bug #10499 (Function creation with GEOMETRY return)


mysql-test/r/gis.result:
  test result fixed
mysql-test/t/gis.test:
  test case
sql/sp_head.cc:
  m_geom_returns is sent to make_field
sql/sp_head.h:
  m_geom_returns declared
sql/sql_yacc.yy:
  m_geom_returns initializing added
parent e13fa8eb
...@@ -670,3 +670,12 @@ create trigger t1_bu before update on t1 for each row set new.s1 = null; ...@@ -670,3 +670,12 @@ create trigger t1_bu before update on t1 for each row set new.s1 = null;
insert into t1 values (null,null); insert into t1 values (null,null);
ERROR 23000: Column 's1' cannot be null ERROR 23000: Column 's1' cannot be null
drop table t1; drop table t1;
create function fn3 () returns point return GeomFromText("point(1 1)");
show create function fn3;
Function sql_mode Create Function
fn3 CREATE FUNCTION `test`.`fn3`() RETURNS point
return GeomFromText("point(1 1)")
select astext(fn3());
astext(fn3())
POINT(1 1)
drop function fn3;
...@@ -383,3 +383,12 @@ create trigger t1_bu before update on t1 for each row set new.s1 = null; ...@@ -383,3 +383,12 @@ create trigger t1_bu before update on t1 for each row set new.s1 = null;
--error 1048 --error 1048
insert into t1 values (null,null); insert into t1 values (null,null);
drop table t1; drop table t1;
#
# Bug #10499 (function creation with GEOMETRY datatype)
#
create function fn3 () returns point return GeomFromText("point(1 1)");
show create function fn3;
select astext(fn3());
drop function fn3;
...@@ -558,7 +558,7 @@ sp_head::make_field(uint max_length, const char *name, TABLE *dummy) ...@@ -558,7 +558,7 @@ sp_head::make_field(uint max_length, const char *name, TABLE *dummy)
field= ::make_field((char *)0, field= ::make_field((char *)0,
!m_returns_len ? max_length : m_returns_len, !m_returns_len ? max_length : m_returns_len,
(uchar *)"", 0, m_returns_pack, m_returns, m_returns_cs, (uchar *)"", 0, m_returns_pack, m_returns, m_returns_cs,
(enum Field::geometry_type)0, Field::NONE, m_geom_returns, Field::NONE,
m_returns_typelib, m_returns_typelib,
name ? name : (const char *)m_name.str, dummy); name ? name : (const char *)m_name.str, dummy);
thd->mem_root= tmp_mem_root; thd->mem_root= tmp_mem_root;
......
...@@ -110,6 +110,7 @@ public: ...@@ -110,6 +110,7 @@ public:
int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
enum enum_field_types m_returns; // For FUNCTIONs only enum enum_field_types m_returns; // For FUNCTIONs only
Field::geometry_type m_geom_returns;
CHARSET_INFO *m_returns_cs; // For FUNCTIONs only CHARSET_INFO *m_returns_cs; // For FUNCTIONs only
TYPELIB *m_returns_typelib; // For FUNCTIONs only TYPELIB *m_returns_typelib; // For FUNCTIONs only
uint m_returns_len; // For FUNCTIONs only uint m_returns_len; // For FUNCTIONs only
......
...@@ -1437,7 +1437,7 @@ create_function_tail: ...@@ -1437,7 +1437,7 @@ create_function_tail:
sp_prepare_create_field(YYTHD, new_field); sp_prepare_create_field(YYTHD, new_field);
if (prepare_create_field(new_field, &unused1, &unused2, &unused2, if (prepare_create_field(new_field, &unused1, &unused2, &unused2,
0)) HA_CAN_GEOMETRY))
YYABORT; YYABORT;
sp->m_returns= new_field->sql_type; sp->m_returns= new_field->sql_type;
...@@ -1445,6 +1445,7 @@ create_function_tail: ...@@ -1445,6 +1445,7 @@ create_function_tail:
sp->m_returns_len= new_field->length; sp->m_returns_len= new_field->length;
sp->m_returns_pack= new_field->pack_flag; sp->m_returns_pack= new_field->pack_flag;
sp->m_returns_typelib= new_field->interval; sp->m_returns_typelib= new_field->interval;
sp->m_geom_returns= new_field->geom_type;
new_field->interval= NULL; new_field->interval= NULL;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics)); bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
......
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