mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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".
This commit is contained in:
@ -1,27 +1,4 @@
|
||||
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)|
|
||||
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)|
|
||||
|
@ -5,29 +5,6 @@
|
||||
# Make sure we don't have any procedures left.
|
||||
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 |;
|
||||
|
||||
# This should give three syntax errors (sometimes crashed; bug #643)
|
||||
|
@ -3611,13 +3611,24 @@ purposes internal to the MySQL server", MYF(0));
|
||||
case SQLCOM_CREATE_PROCEDURE:
|
||||
case SQLCOM_CREATE_SPFUNCTION:
|
||||
{
|
||||
uint namelen;
|
||||
char *name;
|
||||
|
||||
if (!lex->sphead)
|
||||
{
|
||||
res= -1; // Shouldn't happen
|
||||
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
|
||||
if (lex->sphead->m_type == TYPE_ENUM_FUNCTION)
|
||||
{
|
||||
|
@ -1272,12 +1272,7 @@ create:
|
||||
;
|
||||
|
||||
sp_name:
|
||||
'.' IDENT_sys
|
||||
{
|
||||
$$= new sp_name($2);
|
||||
$$->init_qname(YYTHD);
|
||||
}
|
||||
| IDENT_sys '.' IDENT_sys
|
||||
IDENT_sys '.' IDENT_sys
|
||||
{
|
||||
$$= new sp_name($1, $3);
|
||||
$$->init_qname(YYTHD);
|
||||
@ -4460,18 +4455,6 @@ simple_expr:
|
||||
{ $$= new Item_func_round($3,$5,1); }
|
||||
| TRUE_SYM
|
||||
{ $$= 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 ')'
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
|
Reference in New Issue
Block a user