Commit 502e97f8 authored by unknown's avatar unknown
Browse files

Fix for BUG#12228: SP cache code:

* Cleanup SP Cache code, now SP Cache only deletes sp_head objects in 
  sp_cache_flush_obsolete() invalidates all pointers to routines in the cache.
* Use new SP Cache use contract in the code.

There is no test case because it doesn't seem to be possible to cause thread races to end
the same way they end in heavy-load test. This patch removes the crash in heavy test.


mysql-test/r/type_bit.result:
  Drop the tables this test tries to create
mysql-test/r/view.result:
  Drop function this test creates
mysql-test/t/type_bit.test:
  Drop the tables this test tries to create
mysql-test/t/view.test:
  Drop function this test creates
sql/sp.cc:
  Fix for BUG#12228: When a routine is deleted/modified, invalidate all cached SPs in all
  threads. We need to do so because sp_lex_keeper::{prelocking_tables, query_tables_own_last}
  in one SP may depend on another SP sp_lex_keeper::m_lex is using.
sql/sp_cache.cc:
  Fix for BUG#12228:
  * Move class sp_cache to here from sp_cache.h, document the functions.
  * sp_cache_insert, sp_cache_remove, sp_cache_invalidate and sp_cache_lookup must not delete
    sp_head* objects as they may be called during SP execution when sp_head objects are used.
  * Added sp_cache_flush_obsolete() function that may delete sp_head objects.
  * Removed sp_cache_remove as there is no need for it now - when we change one SP we should
    invalidate all other SPs, because sp_lex_keeper::{prelocking_tables, 
    query_tables_own_last} from one SP depend on content of another SP (used in 
    sp_lex_keeper::m_lex).
sql/sp_cache.h:
  Fix for BUG#12228:
  * Move class sp_cache to sp_cache.cc it is not needed in .h file
  * Added comments
sql/sql_parse.cc:
  Fix for BUG#12228: Call new sp_cache_flush_obsolete() function before running the query
sql/sql_prepare.cc:
  Fix for BUG#12228: Call new sp_cache_flush_obsolete() function before preparing/executing a PS
parent e13fa8eb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ select 0 + b'1111111111111111';
select 0 + b'1000000000000001';
0 + b'1000000000000001'
32769
drop table if exists t1;
drop table if exists t1,t2;
create table t1 (a bit(65));
ERROR 42000: Column length too big for column 'a' (max = 64); use BLOB or TEXT instead
create table t1 (a bit(0));
+2 −0
Original line number Diff line number Diff line
@@ -1880,6 +1880,8 @@ test.v5 check error View 'test.v5' references invalid table(s) or column(s) or f
test.v6	check	status	OK
drop view v1, v2, v3, v4, v5, v6;
drop table t2;
drop function if exists f1;
drop function if exists f2;
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
CREATE TABLE t3 (col1 time);
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ select 0 + b'1111111111111111';
select 0 + b'1000000000000001';

--disable_warnings
drop table if exists t1;
drop table if exists t1,t2;
--enable_warnings

--error 1074
+4 −0
Original line number Diff line number Diff line
@@ -1711,6 +1711,10 @@ CHECK TABLE v1, v2, v3, v4, v5, v6;
drop view v1, v2, v3, v4, v5, v6;
drop table t2;

--disable_warnings
drop function if exists f1;
drop function if exists f2;
--enable_warnings
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
CREATE TABLE t3 (col1 time);
+4 −12
Original line number Diff line number Diff line
@@ -986,13 +986,11 @@ int
sp_drop_procedure(THD *thd, sp_name *name)
{
  int ret;
  bool found;
  DBUG_ENTER("sp_drop_procedure");
  DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));

  found= sp_cache_remove(&thd->sp_proc_cache, name);
  ret= db_drop_routine(thd, TYPE_ENUM_PROCEDURE, name);
  if (!found && !ret)
  if (!ret)
    sp_cache_invalidate();
  DBUG_RETURN(ret);
}
@@ -1002,13 +1000,11 @@ int
sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics)
{
  int ret;
  bool found;
  DBUG_ENTER("sp_update_procedure");
  DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));

  found= sp_cache_remove(&thd->sp_proc_cache, name);
  ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name, chistics);
  if (!found && !ret)
  if (!ret)
    sp_cache_invalidate();
  DBUG_RETURN(ret);
}
@@ -1099,13 +1095,11 @@ int
sp_drop_function(THD *thd, sp_name *name)
{
  int ret;
  bool found;
  DBUG_ENTER("sp_drop_function");
  DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));

  found= sp_cache_remove(&thd->sp_func_cache, name);
  ret= db_drop_routine(thd, TYPE_ENUM_FUNCTION, name);
  if (!found && !ret)
  if (!ret)
    sp_cache_invalidate();
  DBUG_RETURN(ret);
}
@@ -1115,13 +1109,11 @@ int
sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics)
{
  int ret;
  bool found;
  DBUG_ENTER("sp_update_procedure");
  DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));

  found= sp_cache_remove(&thd->sp_func_cache, name);
  ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name, chistics);
  if (!found && !ret)
  if (!ret)
    sp_cache_invalidate();
  DBUG_RETURN(ret);
}
Loading