Commit fbab5fc5 authored by sergefp@mysql.com's avatar sergefp@mysql.com

BUG#12228: Post review fixes: Added test case, code cleanup.

parent b7474403
......@@ -37,6 +37,7 @@ Id User Host db Command Time State Info
# root localhost test Sleep # NULL
# root localhost test Query # Locked update t1, t2 set val= 1 where id1=id2
# root localhost test Query # NULL show processlist
# root localhost test Sleep # NULL
unlock tables;
drop procedure bug9486;
drop table t1, t2;
......@@ -64,3 +65,27 @@ insert into t1 (select f from v1);
drop function bug11554;
drop table t1;
drop view v1;
drop procedure if exists p1;
drop procedure if exists p2;
create table t1 (s1 int)|
create procedure p1() select * from t1|
create procedure p2()
begin
insert into t1 values (1);
call p1();
select * from t1;
end|
use test;
lock table t1 write;
call p2();
use test;
drop procedure p1;
create procedure p1() select * from t1;
unlock tables;
s1
1
s1
1
drop procedure p1;
drop procedure p2;
drop table t1;
......@@ -5,6 +5,7 @@
connect (con1root,localhost,root,,);
connect (con2root,localhost,root,,);
connect (con3root,localhost,root,,);
connection con1root;
use test;
......@@ -130,6 +131,48 @@ drop function bug11554;
drop table t1;
drop view v1;
# BUG#12228
--disable_warnings
drop procedure if exists p1;
drop procedure if exists p2;
--enable_warnings
connection con1root;
delimiter |;
create table t1 (s1 int)|
create procedure p1() select * from t1|
create procedure p2()
begin
insert into t1 values (1);
call p1();
select * from t1;
end|
delimiter ;|
connection con2root;
use test;
lock table t1 write;
connection con1root;
send call p2();
connection con3root;
use test;
drop procedure p1;
create procedure p1() select * from t1;
connection con2root;
unlock tables;
connection con1root;
# Crash will be here if we hit BUG#12228
reap;
drop procedure p1;
drop procedure p2;
drop table t1;
#
# BUG#NNNN: New bug synopsis
#
......
......@@ -122,19 +122,15 @@ void sp_cache_insert(sp_cache **cp, sp_head *sp)
{
sp_cache *c= *cp;
if (! c)
if (!c && (c= new sp_cache()))
{
ulong v;
c= new sp_cache();
pthread_mutex_lock(&Cversion_lock); // LOCK
v= Cversion;
c->version= Cversion;
pthread_mutex_unlock(&Cversion_lock); // UNLOCK
if (c)
c->version= v;
}
if (c)
{
DBUG_PRINT("info",("sp_cache: inserting: %*s", sp->m_qname.length,
DBUG_PRINT("info",("sp_cache: inserting: %*s", sp->m_qname.length,
sp->m_qname.str));
c->insert(sp);
if (*cp == NULL)
......
......@@ -46,7 +46,7 @@ class sp_cache;
sp_cache_insert();
sp_cache_invalidate();
2.2 When not holding any sp_head* pointers (at query end):
2.2 When not holding any sp_head* pointers:
sp_cache_flush_obsolete();
3. Before thread exit:
......
......@@ -5347,12 +5347,12 @@ void mysql_init_multi_delete(LEX *lex)
void mysql_parse(THD *thd, char *inBuf, uint length)
{
DBUG_ENTER("mysql_parse");
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
mysql_init_query(thd, (uchar*) inBuf, length);
if (query_cache_send_result_to_client(thd, inBuf, length) <= 0)
{
LEX *lex= thd->lex;
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
if (!yyparse((void *)thd) && ! thd->is_fatal_error)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
......
......@@ -1730,8 +1730,6 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
DBUG_ENTER("mysql_stmt_prepare");
DBUG_PRINT("prep_query", ("%s", packet));
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
/*
If this is an SQLCOM_PREPARE, we also increase Com_prepare_sql.
......@@ -1785,6 +1783,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
lex= thd->lex;
lex->safe_to_cache_query= 0;
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
error= yyparse((void *)thd) || thd->is_fatal_error ||
thd->net.report_error || init_param_array(stmt);
/*
......@@ -1981,8 +1982,6 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
Prepared_statement *stmt;
DBUG_ENTER("mysql_stmt_execute");
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
packet+= 9; /* stmt_id + 5 bytes of flags */
statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status);
......@@ -2063,6 +2062,8 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
thd->protocol= &thd->protocol_prep; // Switch to binary protocol
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR);
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
mysql_execute_command(thd);
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR);
......
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