summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-08-08 23:23:34 +0000
committerunknown <sergefp@mysql.com>2005-08-08 23:23:34 +0000
commit502e97f875d448bcf0c0be4b2cd2c83733150427 (patch)
tree73064b0bd4446a8a5f968d160210cf32fb864a17 /sql/sql_prepare.cc
parente13fa8ebbb095970b9a5a206001eeb06273567de (diff)
downloadmariadb-git-502e97f875d448bcf0c0be4b2cd2c83733150427.tar.gz
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
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 18707cc6c87..f8b19dac3d1 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -73,6 +73,7 @@ Long data handling:
#include <m_ctype.h> // for isspace()
#include "sp_head.h"
#include "sp.h"
+#include "sp_cache.h"
#ifdef EMBEDDED_LIBRARY
/* include MYSQL_BIND headers */
#include <mysql.h>
@@ -1729,6 +1730,8 @@ 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.
@@ -1978,6 +1981,8 @@ 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);