mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed BUG#9902: Crash with simple stored function using user defined variables
... actually, it was a query cache problem. (It shouldn't cache such queries) mysql-test/r/sp.result: Added testcase for BUG#9902. mysql-test/t/sp.test: Added testcase for BUG#9902. sql/sql_yacc.yy: Don't cache queries which are calling stored functions.
This commit is contained in:
@ -2936,4 +2936,26 @@ select @tmp1, @tmp2|
|
|||||||
50 60
|
50 60
|
||||||
drop procedure bug9598_1|
|
drop procedure bug9598_1|
|
||||||
drop procedure bug9598_2|
|
drop procedure bug9598_2|
|
||||||
|
drop procedure if exists bug9902|
|
||||||
|
create function bug9902() returns int(11)
|
||||||
|
begin
|
||||||
|
set @x = @x + 1;
|
||||||
|
return @x;
|
||||||
|
end|
|
||||||
|
set @qcs1 = @@query_cache_size|
|
||||||
|
set global query_cache_size = 100000|
|
||||||
|
set @x = 1|
|
||||||
|
insert into t1 values ("qc", 42)|
|
||||||
|
select bug9902() from t1|
|
||||||
|
bug9902()
|
||||||
|
2
|
||||||
|
select bug9902() from t1|
|
||||||
|
bug9902()
|
||||||
|
3
|
||||||
|
select @x|
|
||||||
|
@x
|
||||||
|
3
|
||||||
|
set global query_cache_size = @qcs1|
|
||||||
|
delete from t1|
|
||||||
|
drop function bug9902|
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
@ -3603,6 +3603,31 @@ drop procedure bug9598_1|
|
|||||||
drop procedure bug9598_2|
|
drop procedure bug9598_2|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#9902: Crash with simple stored function using user defined variables
|
||||||
|
#
|
||||||
|
--disable_warnings
|
||||||
|
drop procedure if exists bug9902|
|
||||||
|
--enable_warnings
|
||||||
|
create function bug9902() returns int(11)
|
||||||
|
begin
|
||||||
|
set @x = @x + 1;
|
||||||
|
return @x;
|
||||||
|
end|
|
||||||
|
|
||||||
|
set @qcs1 = @@query_cache_size|
|
||||||
|
set global query_cache_size = 100000|
|
||||||
|
set @x = 1|
|
||||||
|
insert into t1 values ("qc", 42)|
|
||||||
|
select bug9902() from t1|
|
||||||
|
select bug9902() from t1|
|
||||||
|
select @x|
|
||||||
|
|
||||||
|
set global query_cache_size = @qcs1|
|
||||||
|
delete from t1|
|
||||||
|
drop function bug9902|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# BUG#NNNN: New bug synopsis
|
# BUG#NNNN: New bug synopsis
|
||||||
#
|
#
|
||||||
|
@ -4598,14 +4598,16 @@ simple_expr:
|
|||||||
{ $$= new Item_int((char*) "TRUE",1,1); }
|
{ $$= new Item_int((char*) "TRUE",1,1); }
|
||||||
| ident '.' ident '(' udf_expr_list ')'
|
| ident '.' ident '(' udf_expr_list ')'
|
||||||
{
|
{
|
||||||
|
LEX *lex= Lex;
|
||||||
sp_name *name= new sp_name($1, $3);
|
sp_name *name= new sp_name($1, $3);
|
||||||
|
|
||||||
name->init_qname(YYTHD);
|
name->init_qname(YYTHD);
|
||||||
sp_add_to_hash(&Lex->spfuns, name);
|
sp_add_to_hash(&lex->spfuns, name);
|
||||||
if ($5)
|
if ($5)
|
||||||
$$= new Item_func_sp(name, *$5);
|
$$= new Item_func_sp(name, *$5);
|
||||||
else
|
else
|
||||||
$$= new Item_func_sp(name);
|
$$= new Item_func_sp(name);
|
||||||
|
lex->safe_to_cache_query=0;
|
||||||
}
|
}
|
||||||
| IDENT_sys '(' udf_expr_list ')'
|
| IDENT_sys '(' udf_expr_list ')'
|
||||||
{
|
{
|
||||||
@ -4686,13 +4688,15 @@ simple_expr:
|
|||||||
else
|
else
|
||||||
#endif /* HAVE_DLOPEN */
|
#endif /* HAVE_DLOPEN */
|
||||||
{
|
{
|
||||||
|
LEX *lex= Lex;
|
||||||
sp_name *name= sp_name_current_db_new(YYTHD, $1);
|
sp_name *name= sp_name_current_db_new(YYTHD, $1);
|
||||||
|
|
||||||
sp_add_to_hash(&Lex->spfuns, name);
|
sp_add_to_hash(&lex->spfuns, name);
|
||||||
if ($3)
|
if ($3)
|
||||||
$$= new Item_func_sp(name, *$3);
|
$$= new Item_func_sp(name, *$3);
|
||||||
else
|
else
|
||||||
$$= new Item_func_sp(name);
|
$$= new Item_func_sp(name);
|
||||||
|
lex->safe_to_cache_query=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')'
|
| UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')'
|
||||||
|
Reference in New Issue
Block a user