Manual merge of 5.0-runtime to 5.1-runtime

parent a4c66084
...@@ -1226,7 +1226,7 @@ ERROR 42S02: Unknown table 'c' in field list ...@@ -1226,7 +1226,7 @@ ERROR 42S02: Unknown table 'c' in field list
drop procedure bug15091; drop procedure bug15091;
drop function if exists bug16896; drop function if exists bug16896;
create aggregate function bug16896() returns int return 1; create aggregate function bug16896() returns int return 1;
ERROR 42000: AGGREGATE is not supported for stored functions ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() returns int return 1' at line 1
DROP PROCEDURE IF EXISTS bug14702; DROP PROCEDURE IF EXISTS bug14702;
CREATE IF NOT EXISTS PROCEDURE bug14702() CREATE IF NOT EXISTS PROCEDURE bug14702()
BEGIN BEGIN
...@@ -1510,3 +1510,16 @@ FETCH cur1 INTO c; ...@@ -1510,3 +1510,16 @@ FETCH cur1 INTO c;
select c; select c;
CLOSE cur1; CLOSE cur1;
END' at line 4 END' at line 4
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest;
USE mysqltest;
DROP DATABASE mysqltest;
SELECT inexistent(), 1 + ,;
ERROR 42000: FUNCTION inexistent does not exist
SELECT inexistent();
ERROR 42000: FUNCTION inexistent does not exist
SELECT .inexistent();
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '()' at line 1
SELECT ..inexistent();
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.inexistent()' at line 1
USE test;
...@@ -6796,6 +6796,22 @@ f1() ...@@ -6796,6 +6796,22 @@ f1()
DROP TABLE t1; DROP TABLE t1;
DROP FUNCTION f1; DROP FUNCTION f1;
DROP PROCEDURE IF EXISTS db28318_a.t1;
DROP PROCEDURE IF EXISTS db28318_b.t2;
DROP DATABASE IF EXISTS db28318_a;
DROP DATABASE IF EXISTS db28318_b;
CREATE DATABASE db28318_a;
CREATE DATABASE db28318_b;
CREATE PROCEDURE db28318_a.t1() SELECT "db28318_a.t1";
CREATE PROCEDURE db28318_b.t2() CALL t1();
use db28318_a;
CALL db28318_b.t2();
ERROR 42000: PROCEDURE db28318_b.t1 does not exist
DROP PROCEDURE db28318_a.t1;
DROP PROCEDURE db28318_b.t2;
DROP DATABASE db28318_a;
DROP DATABASE db28318_b;
use test;
End of 5.0 tests End of 5.0 tests
# #
......
...@@ -95,10 +95,10 @@ FR ...@@ -95,10 +95,10 @@ FR
DROP TABLE bug19904; DROP TABLE bug19904;
CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so"; RETURNS STRING SONAME "should_not_parse.so";
ERROR HY000: Incorrect usage of SONAME and DEFINER ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNS STRING SONAME "should_not_parse.so"' at line 2
CREATE DEFINER=someone@somewhere FUNCTION should_not_parse CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so"; RETURNS STRING SONAME "should_not_parse.so";
ERROR HY000: Incorrect usage of SONAME and DEFINER ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNS STRING SONAME "should_not_parse.so"' at line 2
create table t1(f1 int); create table t1(f1 int);
insert into t1 values(1),(2); insert into t1 values(1),(2);
explain select myfunc_int(f1) from t1 order by 1; explain select myfunc_int(f1) from t1 order by 1;
...@@ -214,7 +214,7 @@ DROP FUNCTION IF EXISTS metaphon; ...@@ -214,7 +214,7 @@ DROP FUNCTION IF EXISTS metaphon;
CREATE FUNCTION metaphon(a int) RETURNS int CREATE FUNCTION metaphon(a int) RETURNS int
return 0; return 0;
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
ERROR HY000: Function 'metaphon' already exists DROP FUNCTION metaphon;
DROP FUNCTION metaphon; DROP FUNCTION metaphon;
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION metaphon(a int) RETURNS int CREATE FUNCTION metaphon(a int) RETURNS int
...@@ -334,6 +334,13 @@ Qcache_queries_in_cache 0 ...@@ -334,6 +334,13 @@ Qcache_queries_in_cache 0
drop table t1; drop table t1;
drop function metaphon; drop function metaphon;
set GLOBAL query_cache_size=default; set GLOBAL query_cache_size=default;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest;
USE mysqltest;
DROP DATABASE mysqltest;
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
DROP FUNCTION metaphon;
USE test;
CREATE TABLE const_len_bug ( CREATE TABLE const_len_bug (
str_const varchar(4000), str_const varchar(4000),
result1 varchar(4000), result1 varchar(4000),
......
...@@ -7871,6 +7871,37 @@ DROP FUNCTION f1; ...@@ -7871,6 +7871,37 @@ DROP FUNCTION f1;
########################################################################### ###########################################################################
#
# Bug#28318 (CREATE FUNCTION (UDF) requires a schema)
#
--disable_warnings
DROP PROCEDURE IF EXISTS db28318_a.t1;
DROP PROCEDURE IF EXISTS db28318_b.t2;
DROP DATABASE IF EXISTS db28318_a;
DROP DATABASE IF EXISTS db28318_b;
--enable_warnings
CREATE DATABASE db28318_a;
CREATE DATABASE db28318_b;
CREATE PROCEDURE db28318_a.t1() SELECT "db28318_a.t1";
CREATE PROCEDURE db28318_b.t2() CALL t1();
use db28318_a;
# In db28318_b.t2, t1 refers to db28318_b.t1
--error ER_SP_DOES_NOT_EXIST
CALL db28318_b.t2();
DROP PROCEDURE db28318_a.t1;
DROP PROCEDURE db28318_b.t2;
DROP DATABASE db28318_a;
DROP DATABASE db28318_b;
use test;
###########################################################################
--echo End of 5.0 tests --echo End of 5.0 tests
########################################################################### ###########################################################################
......
...@@ -206,10 +206,11 @@ DROP FUNCTION IF EXISTS metaphon; ...@@ -206,10 +206,11 @@ DROP FUNCTION IF EXISTS metaphon;
CREATE FUNCTION metaphon(a int) RETURNS int CREATE FUNCTION metaphon(a int) RETURNS int
return 0; return 0;
# this currently passes, and eclipse the stored function
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
--error ER_UDF_EXISTS
eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
DROP FUNCTION metaphon;
DROP FUNCTION metaphon; DROP FUNCTION metaphon;
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
......
...@@ -2326,6 +2326,25 @@ Item* ...@@ -2326,6 +2326,25 @@ Item*
Create_qfunc::create(THD *thd, LEX_STRING name, List<Item> *item_list) Create_qfunc::create(THD *thd, LEX_STRING name, List<Item> *item_list)
{ {
LEX_STRING db; LEX_STRING db;
if (! thd->db && ! thd->lex->sphead)
{
/*
The proper error message should be in the lines of:
Can't resolve <name>() to a function call,
because this function:
- is not a native function,
- is not a user defined function,
- can not match a qualified (read: stored) function
since no database is selected.
Reusing ER_SP_DOES_NOT_EXIST have a message consistent with
the case when a default database exist, see Create_sp_func::create().
*/
my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
"FUNCTION", name.str);
return NULL;
}
if (thd->lex->copy_db_to(&db.str, &db.length)) if (thd->lex->copy_db_to(&db.str, &db.length))
return NULL; return NULL;
......
...@@ -386,17 +386,43 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) ...@@ -386,17 +386,43 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr)
* *
*/ */
sp_name::sp_name(THD *thd, char *key, uint key_len)
{
m_sroutines_key.str= key;
m_sroutines_key.length= key_len;
m_qname.str= ++key;
m_qname.length= key_len - 1;
if ((m_name.str= strchr(m_qname.str, '.')))
{
m_db.length= m_name.str - key;
m_db.str= strmake_root(thd->mem_root, key, m_db.length);
m_name.str++;
m_name.length= m_qname.length - m_db.length - 1;
}
else
{
m_name.str= m_qname.str;
m_name.length= m_qname.length;
m_db.str= 0;
m_db.length= 0;
}
m_explicit_name= false;
}
void void
sp_name::init_qname(THD *thd) sp_name::init_qname(THD *thd)
{ {
m_sroutines_key.length= m_db.length + m_name.length + 2; const uint dot= !!m_db.length;
/* m_sroutines format: m_type + [database + dot] + name + nul */
m_sroutines_key.length= 1 + m_db.length + dot + m_name.length;
if (!(m_sroutines_key.str= (char*) thd->alloc(m_sroutines_key.length + 1))) if (!(m_sroutines_key.str= (char*) thd->alloc(m_sroutines_key.length + 1)))
return; return;
m_qname.length= m_sroutines_key.length - 1; m_qname.length= m_sroutines_key.length - 1;
m_qname.str= m_sroutines_key.str + 1; m_qname.str= m_sroutines_key.str + 1;
sprintf(m_qname.str, "%.*s.%.*s", sprintf(m_qname.str, "%.*s%.*s%.*s",
(int) m_db.length, (m_db.length ? m_db.str : ""), (int) m_db.length, (m_db.length ? m_db.str : ""),
(int) m_name.length, m_name.str); dot, ".",
(int) m_name.length, m_name.str);
} }
......
This diff is collapsed.
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