summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@sun.com>2010-04-14 13:53:59 +0400
committerSergey Vojtovich <svoj@sun.com>2010-04-14 13:53:59 +0400
commitb89feb5b28176daa27c4a3bdc32f2c70f6a996e2 (patch)
treeb63efe0cd130b6f27ed369fb7438cca073cabe69 /sql/sql_class.cc
parent8a96640e87360f5e588f51fe99e51d8d6d481ae3 (diff)
downloadmariadb-git-b89feb5b28176daa27c4a3bdc32f2c70f6a996e2.tar.gz
BUG#39053 - UNISTALL PLUGIN does not allow the storage engine
to cleanup open connections It was possible to UNINSTALL storage engine plugin when binding between THD object and storage engine is still active (e.g. in the middle of transaction). To avoid unclean deactivation (uninstall) of storage engine plugin in the middle of transaction, additional storage engine plugin lock is acquired by thd_set_ha_data(). If ha_data is not null and storage engine plugin was not locked by thd_set_ha_data() in this connection before, storage engine plugin gets locked. If ha_data is null and storage engine plugin was locked by thd_set_ha_data() in this connection before, storage engine plugin lock gets released. If handlerton::close_connection() didn't reset ha_data, server does it immediately after calling handlerton::close_connection(). Note that this is just a framework fix, storage engines must switch to thd_set_ha_data() from thd_ha_data() if they want to see fit.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 266064f9f08..bf5af7141c0 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -284,6 +284,37 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton)
return (void **) &thd->ha_data[hton->slot].ha_ptr;
}
+
+/**
+ Provide a handler data getter to simplify coding
+*/
+extern "C"
+void *thd_get_ha_data(const THD *thd, const struct handlerton *hton)
+{
+ return *thd_ha_data(thd, hton);
+}
+
+
+/**
+ Provide a handler data setter to simplify coding
+ @see thd_set_ha_data() definition in plugin.h
+*/
+extern "C"
+void thd_set_ha_data(THD *thd, const struct handlerton *hton,
+ const void *ha_data)
+{
+ plugin_ref *lock= &thd->ha_data[hton->slot].lock;
+ if (ha_data && !*lock)
+ *lock= ha_lock_engine(NULL, (handlerton*) hton);
+ else if (!ha_data && *lock)
+ {
+ plugin_unlock(NULL, *lock);
+ *lock= NULL;
+ }
+ *thd_ha_data(thd, hton)= (void*) ha_data;
+}
+
+
extern "C"
long long thd_test_options(const THD *thd, long long test_options)
{