diff options
author | Sergey Vojtovich <svoj@sun.com> | 2010-04-14 13:53:59 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@sun.com> | 2010-04-14 13:53:59 +0400 |
commit | 4aa36ee7b689c4e9f74ccdc08fa278df66042fe8 (patch) | |
tree | b63efe0cd130b6f27ed369fb7438cca073cabe69 /include | |
parent | 6eca53f1d382a247456d29794c70338f972b77a9 (diff) | |
download | mariadb-git-4aa36ee7b689c4e9f74ccdc08fa278df66042fe8.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.
include/mysql/plugin.h:
As thd_{get|set}_ha_data() have some extra logic now, they
must be implemented on server side.
include/mysql/plugin.h.pp:
As thd_{get|set}_ha_data() have some extra logic now, they
must be implemented on server side.
sql/handler.cc:
Make sure ha_data is reset and ha_data lock is released.
sql/handler.h:
hton is not supposed to be updated by ha_lock_engine(),
make it const.
sql/sql_class.cc:
As thd_{get|set}_ha_data() have some extra logic now, they
must be implemented on server side.
sql/sql_class.h:
Added ha_data lock.
Diffstat (limited to 'include')
-rw-r--r-- | include/mysql/plugin.h | 39 | ||||
-rw-r--r-- | include/mysql/plugin.h.pp | 3 |
2 files changed, 26 insertions, 16 deletions
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 58b3848b85f..55ef6070f85 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -801,30 +801,37 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd, const char *key, unsigned int key_length, int using_trx); -#ifdef __cplusplus -} -#endif -#ifdef __cplusplus /** Provide a handler data getter to simplify coding */ -inline -void * -thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton) -{ - return *thd_ha_data(thd, hton); -} +void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton); + /** Provide a handler data setter to simplify coding + + @details + Set ha_data pointer (storage engine per-connection information). + + To avoid unclean deactivation (uninstall) of storage engine plugin + in the middle of transaction, additional storage engine plugin + lock is acquired. + + 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(). */ -inline -void -thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton, - const void *ha_data) -{ - *thd_ha_data(thd, hton)= (void*) ha_data; +void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton, + const void *ha_data); +#ifdef __cplusplus } #endif diff --git a/include/mysql/plugin.h.pp b/include/mysql/plugin.h.pp index 50511f515ab..e4906ea6547 100644 --- a/include/mysql/plugin.h.pp +++ b/include/mysql/plugin.h.pp @@ -137,3 +137,6 @@ void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, const char *key, unsigned int key_length, int using_trx); +void *thd_get_ha_data(const void* thd, const struct handlerton *hton); +void thd_set_ha_data(void* thd, const struct handlerton *hton, + const void *ha_data); |