summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kroki@mysql.com>2006-06-30 00:24:47 +0400
committerunknown <kroki@mysql.com>2006-06-30 00:24:47 +0400
commit9bbfa9fbf1e614ebeb211693d8e89043b631e20f (patch)
tree7998710a377ccdbd0dad2866064e860d6ef34850
parentc4cffdbfe9d8749fb020c46180423d59520a2c98 (diff)
parent8368f437a79976c77ea82b953052fdb6e08a68fc (diff)
downloadmariadb-git-9bbfa9fbf1e614ebeb211693d8e89043b631e20f.tar.gz
Merge mysql.com:/home/tomash/src/mysql_ab/mysql-5.0
into mysql.com:/home/tomash/src/mysql_ab/mysql-5.0-bug20230
-rw-r--r--mysql-test/r/information_schema.result52
-rw-r--r--mysql-test/t/information_schema.test36
-rw-r--r--sql/sp_head.cc18
-rw-r--r--sql/sql_show.cc3
4 files changed, 96 insertions, 13 deletions
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 64969fcdf44..a2feba7ad5d 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -294,26 +294,26 @@ show create function sub1;
ERROR 42000: FUNCTION sub1 does not exist
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
-sel2
-sub1
+sel2 NULL
+sub1 NULL
grant all privileges on test.* to mysqltest_1@localhost;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
-sel2
-sub1
+sel2 NULL
+sub1 NULL
create function sub2(i int) returns int
return i+1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
-sel2
-sub1
+sel2 NULL
+sub1 NULL
sub2 return i+1
show create procedure sel2;
Procedure sql_mode Create Procedure
-sel2
+sel2 NULL
show create function sub1;
Function sql_mode Create Function
-sub1
+sub1 NULL
show create function sub2;
Function sql_mode Create Function
sub2 CREATE DEFINER=`mysqltest_1`@`localhost` FUNCTION `sub2`(i int) RETURNS int(11)
@@ -1134,3 +1134,39 @@ concat(@a, table_name) @a table_name
.t1 . t1
.t2 . t2
drop table t1,t2;
+DROP PROCEDURE IF EXISTS p1;
+DROP FUNCTION IF EXISTS f1;
+CREATE PROCEDURE p1() SET @a= 1;
+CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
+CREATE USER mysql_bug20230@localhost;
+GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
+GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;
+SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
+ROUTINE_NAME ROUTINE_DEFINITION
+f1 RETURN @a + 1
+p1 SET @a= 1
+SHOW CREATE PROCEDURE p1;
+Procedure sql_mode Create Procedure
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
+SET @a= 1
+SHOW CREATE FUNCTION f1;
+Function sql_mode Create Function
+f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
+RETURN @a + 1
+SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
+ROUTINE_NAME ROUTINE_DEFINITION
+f1 NULL
+p1 NULL
+SHOW CREATE PROCEDURE p1;
+Procedure sql_mode Create Procedure
+p1 NULL
+SHOW CREATE FUNCTION f1;
+Function sql_mode Create Function
+f1 NULL
+CALL p1();
+SELECT f1();
+f1()
+2
+DROP FUNCTION f1;
+DROP PROCEDURE p1;
+DROP USER mysql_bug20230@localhost;
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 0bcd9ef8c0b..a2e19112cf9 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -852,3 +852,39 @@ create table t2(f1 char(5));
select concat(@a, table_name), @a, table_name
from information_schema.tables where table_schema = 'test';
drop table t1,t2;
+
+
+#
+# Bug#20230: routine_definition is not null
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE PROCEDURE p1() SET @a= 1;
+CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
+CREATE USER mysql_bug20230@localhost;
+GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
+GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;
+
+SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
+SHOW CREATE PROCEDURE p1;
+SHOW CREATE FUNCTION f1;
+
+connect (conn1, localhost, mysql_bug20230,,);
+
+SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
+SHOW CREATE PROCEDURE p1;
+SHOW CREATE FUNCTION f1;
+CALL p1();
+SELECT f1();
+
+disconnect conn1;
+connection default;
+
+DROP FUNCTION f1;
+DROP PROCEDURE p1;
+DROP USER mysql_bug20230@localhost;
+
+# End of 5.0 tests.
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index b3b99557b63..9965c48935a 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1869,8 +1869,11 @@ sp_head::show_create_procedure(THD *thd)
field_list.push_back(new Item_empty_string("Procedure", NAME_LEN));
field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
// 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Procedure",
- max(buffer.length(), 1024)));
+ Item_empty_string *definition=
+ new Item_empty_string("Create Procedure", max(buffer.length(),1024));
+ definition->maybe_null= TRUE;
+ field_list.push_back(definition);
+
if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF))
DBUG_RETURN(1);
@@ -1879,6 +1882,8 @@ sp_head::show_create_procedure(THD *thd)
protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info);
if (full_access)
protocol->store(m_defstr.str, m_defstr.length, system_charset_info);
+ else
+ protocol->store_null();
res= protocol->write();
send_eof(thd);
@@ -1934,8 +1939,11 @@ sp_head::show_create_function(THD *thd)
&sql_mode_len);
field_list.push_back(new Item_empty_string("Function",NAME_LEN));
field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
- field_list.push_back(new Item_empty_string("Create Function",
- max(buffer.length(),1024)));
+ Item_empty_string *definition=
+ new Item_empty_string("Create Function", max(buffer.length(),1024));
+ definition->maybe_null= TRUE;
+ field_list.push_back(definition);
+
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1);
@@ -1944,6 +1952,8 @@ sp_head::show_create_function(THD *thd)
protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info);
if (full_access)
protocol->store(m_defstr.str, m_defstr.length, system_charset_info);
+ else
+ protocol->store_null();
res= protocol->write();
send_eof(thd);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 60d50c415d5..2c7a9b05cd9 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2916,6 +2916,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
{
get_field(thd->mem_root, proc_table->field[10], &tmp_string);
table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
+ table->field[7]->set_notnull();
}
table->field[6]->store(STRING_WITH_LEN("SQL"), cs);
table->field[10]->store(STRING_WITH_LEN("SQL"), cs);
@@ -4069,7 +4070,7 @@ ST_FIELD_INFO proc_fields_info[]=
{"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"DTD_IDENTIFIER", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0},
- {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
{"EXTERNAL_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"EXTERNAL_LANGUAGE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"PARAMETER_STYLE", 8, MYSQL_TYPE_STRING, 0, 0, 0},