Commit f1030783 authored by michael's avatar michael

branches/zip:

rb://53

Improve innodb_supports_xa system variable handling and 
reduces the number of retrievals of the value from MySQL.

Approved by: Marko, over IM
parent a4523090
...@@ -607,6 +607,19 @@ thd_is_select( ...@@ -607,6 +607,19 @@ thd_is_select(
return(thd_sql_command((const THD*) thd) == SQLCOM_SELECT); return(thd_sql_command((const THD*) thd) == SQLCOM_SELECT);
} }
/**********************************************************************
Returns true if the thread has XA support. */
extern "C" UNIV_INTERN
ibool
thd_supports_xa(
/*============*/
/* out: true if thd has XA support */
void* thd) /* in: thread handle (THD*), or NULL to query
the global innodb_supports_xa */
{
return(THDVAR((THD*) thd, support_xa));
}
/********************************************************************** /**********************************************************************
Returns true if the thread is executing in innodb_strict_mode. */ Returns true if the thread is executing in innodb_strict_mode. */
extern "C" UNIV_INTERN extern "C" UNIV_INTERN
...@@ -1238,9 +1251,6 @@ check_trx_exists( ...@@ -1238,9 +1251,6 @@ check_trx_exists(
trx->mysql_thd = thd; trx->mysql_thd = thd;
trx->mysql_query_str = thd_query(thd); trx->mysql_query_str = thd_query(thd);
/* Update the info whether we should skip XA steps that eat
CPU time */
trx->support_xa = THDVAR(thd, support_xa);
} else { } else {
if (trx->magic_n != TRX_MAGIC_N) { if (trx->magic_n != TRX_MAGIC_N) {
mem_analyze_corruption(trx); mem_analyze_corruption(trx);
...@@ -2299,9 +2309,6 @@ innobase_commit( ...@@ -2299,9 +2309,6 @@ innobase_commit(
trx = check_trx_exists(thd); trx = check_trx_exists(thd);
/* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = THDVAR(thd, support_xa);
/* Since we will reserve the kernel mutex, we have to release /* Since we will reserve the kernel mutex, we have to release
the search system latch first to obey the latching order. */ the search system latch first to obey the latching order. */
...@@ -2428,9 +2435,6 @@ innobase_rollback( ...@@ -2428,9 +2435,6 @@ innobase_rollback(
trx = check_trx_exists(thd); trx = check_trx_exists(thd);
/* Update the info whether we should skip XA steps that eat CPU time */
trx->support_xa = THDVAR(thd, support_xa);
/* Release a possible FIFO ticket and search latch. Since we will /* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ first to obey the latching order. */
...@@ -8843,7 +8847,10 @@ innobase_xa_prepare( ...@@ -8843,7 +8847,10 @@ innobase_xa_prepare(
trx->active_trans = 2; trx->active_trans = 2;
} }
if (!THDVAR(thd, support_xa)) { /* we use support_xa value as it was seen at transaction start
time, not the current session variable value. Any possible changes
to the session variable take effect only in the next transaction */
if (!trx->support_xa) {
return(0); return(0);
} }
......
...@@ -206,6 +206,16 @@ innobase_get_charset( ...@@ -206,6 +206,16 @@ innobase_get_charset(
/* out: connection character set */ /* out: connection character set */
void* mysql_thd); /* in: MySQL thread handle */ void* mysql_thd); /* in: MySQL thread handle */
/**********************************************************************
Returns true if the thread supports XA,
global value of innodb_supports_xa if thd is NULL. */
ibool
thd_supports_xa(
/*============*/
/* out: true if thd supports XA */
void* thd); /* in: thread handle (THD*) */
/********************************************************************** /**********************************************************************
Returns true if the thread is executing in innodb_strict_mode. */ Returns true if the thread is executing in innodb_strict_mode. */
......
...@@ -694,6 +694,15 @@ trx_start( ...@@ -694,6 +694,15 @@ trx_start(
{ {
ibool ret; ibool ret;
/* Update the info whether we should skip XA steps that eat CPU time
For the duration of the transaction trx->support_xa is not reread
from thd so any changes in the value take effect in the next
transaction. This is to avoid a scenario where some undo
generated by a transaction, has XA stuff, and other undo,
generated by the same transaction, doesn't
*/
trx->support_xa = thd_supports_xa(trx->mysql_thd);
mutex_enter(&kernel_mutex); mutex_enter(&kernel_mutex);
ret = trx_start_low(trx, rseg_id); ret = trx_start_low(trx, rseg_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment