Commit 43785537 authored by unknown's avatar unknown

Revised BUG#5000: SPs can be created with no default database.

Now simply give an error if no database. (The "global SP feature" will be
done using PATH instead.)


mysql-test/r/sp-error.result:
  Removed test cases for undone "feature".
mysql-test/t/sp-error.test:
  Removed test cases for undone "feature".
sql/sql_parse.cc:
  Check if created procedure/function has a database; give error if not.
sql/sql_yacc.yy:
  Undid the "global SP feature".
parent 3ed9e668
delete from mysql.proc; delete from mysql.proc;
create function .f1() returns int return 1;
create procedure .p1() select 1, database();
create procedure p1() select 2, database();
alter procedure .p1 sql security invoker;
select .f1();
.f1()
1
call .p1();
1 database()
1 test
call p1();
2 database()
2 test
select f1();
ERROR 42000: FUNCTION test.f1 does not exist
select db,name,type,security_type from mysql.proc;
db name type security_type
f1 FUNCTION DEFINER
p1 PROCEDURE INVOKER
test p1 PROCEDURE DEFINER
drop function .f1;
drop procedure .p1;
drop procedure p1;
create procedure syntaxerror(t int)| create procedure syntaxerror(t int)|
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 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
create procedure syntaxerror(t int)| create procedure syntaxerror(t int)|
......
...@@ -5,29 +5,6 @@ ...@@ -5,29 +5,6 @@
# Make sure we don't have any procedures left. # Make sure we don't have any procedures left.
delete from mysql.proc; delete from mysql.proc;
# A test of "global" procedures, i.e. not belonging to any database.
create function .f1() returns int return 1;
create procedure .p1() select 1, database();
create procedure p1() select 2, database();
alter procedure .p1 sql security invoker;
# This is ok:
select .f1();
call .p1();
call p1();
# This is not ok:
--error 1305
select f1();
select db,name,type,security_type from mysql.proc;
drop function .f1;
drop procedure .p1;
drop procedure p1;
delimiter |; delimiter |;
# This should give three syntax errors (sometimes crashed; bug #643) # This should give three syntax errors (sometimes crashed; bug #643)
......
...@@ -3611,13 +3611,24 @@ purposes internal to the MySQL server", MYF(0)); ...@@ -3611,13 +3611,24 @@ purposes internal to the MySQL server", MYF(0));
case SQLCOM_CREATE_PROCEDURE: case SQLCOM_CREATE_PROCEDURE:
case SQLCOM_CREATE_SPFUNCTION: case SQLCOM_CREATE_SPFUNCTION:
{ {
uint namelen;
char *name;
if (!lex->sphead) if (!lex->sphead)
{ {
res= -1; // Shouldn't happen res= -1; // Shouldn't happen
break; break;
} }
uint namelen;
char *name= lex->sphead->name(&namelen); if (! lex->sphead->m_db.str)
{
send_error(thd,ER_NO_DB_ERROR);
delete lex->sphead;
lex->sphead= 0;
goto error;
}
name= lex->sphead->name(&namelen);
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
if (lex->sphead->m_type == TYPE_ENUM_FUNCTION) if (lex->sphead->m_type == TYPE_ENUM_FUNCTION)
{ {
...@@ -3627,7 +3638,7 @@ purposes internal to the MySQL server", MYF(0)); ...@@ -3627,7 +3638,7 @@ purposes internal to the MySQL server", MYF(0));
{ {
net_printf(thd, ER_UDF_EXISTS, name); net_printf(thd, ER_UDF_EXISTS, name);
delete lex->sphead; delete lex->sphead;
lex->sphead=0; lex->sphead= 0;
goto error; goto error;
} }
} }
...@@ -3637,7 +3648,7 @@ purposes internal to the MySQL server", MYF(0)); ...@@ -3637,7 +3648,7 @@ purposes internal to the MySQL server", MYF(0));
{ {
net_printf(thd, ER_SP_NORETURN, name); net_printf(thd, ER_SP_NORETURN, name);
delete lex->sphead; delete lex->sphead;
lex->sphead=0; lex->sphead= 0;
goto error; goto error;
} }
......
...@@ -1272,12 +1272,7 @@ create: ...@@ -1272,12 +1272,7 @@ create:
; ;
sp_name: sp_name:
'.' IDENT_sys IDENT_sys '.' IDENT_sys
{
$$= new sp_name($2);
$$->init_qname(YYTHD);
}
| IDENT_sys '.' IDENT_sys
{ {
$$= new sp_name($1, $3); $$= new sp_name($1, $3);
$$->init_qname(YYTHD); $$->init_qname(YYTHD);
...@@ -4460,18 +4455,6 @@ simple_expr: ...@@ -4460,18 +4455,6 @@ simple_expr:
{ $$= new Item_func_round($3,$5,1); } { $$= new Item_func_round($3,$5,1); }
| TRUE_SYM | TRUE_SYM
{ $$= new Item_int((char*) "TRUE",1,1); } { $$= new Item_int((char*) "TRUE",1,1); }
| '.' ident '(' udf_expr_list ')'
{
LEX *lex= Lex;
sp_name *name= new sp_name($2);
name->init_qname(YYTHD);
sp_add_fun_to_lex(Lex, name);
if ($4)
$$= new Item_func_sp(name, *$4);
else
$$= new Item_func_sp(name);
}
| ident '.' ident '(' udf_expr_list ')' | ident '.' ident '(' udf_expr_list ')'
{ {
LEX *lex= Lex; LEX *lex= Lex;
......
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