Commit 6b9ec78b authored by unknown's avatar unknown
Browse files

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


mysql-test/r/sp-threads.result:
  Testcase for BUG#12228
mysql-test/t/sp-threads.test:
  Testcase for BUG#12228
sql/sp_cache.cc:
  BUG#12228: Post-review fixes: small code cleanup
sql/sp_cache.h:
  BUG#12228: Post-review fixes: fixed the comment
sql/sql_parse.cc:
  BUG#12228: Post-review fixes: in mysql_parse, flush obsolete SPs from the caches only if 
   the query hasn't been handled by the query cache.
sql/sql_prepare.cc:
  BUG#12228: Post-review fixes: in mysql_stmt_prepare/execute, flush SP caches 
   "closer to the execution"
parent 08cadd81
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -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;
+43 −0
Original line number Diff line number Diff line
@@ -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
#
+3 −7
Original line number Diff line number Diff line
@@ -122,15 +122,11 @@ 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)
  {
+1 −1
Original line number Diff line number Diff line
@@ -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:
+2 −2
Original line number Diff line number Diff line
@@ -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
Loading