Commit ef579d89 authored by BohuTANG's avatar BohuTANG

DB-310 add tokudb_support_xa variable

this variable scope is Global, Session
type is boolean and default value is TRUE
parent 507da246
'#--------------------begin------------------------#'
SET @session_start_value = @@session.tokudb_support_xa;
SELECT @session_start_value;
@session_start_value
1
SET @global_start_value = @@global.tokudb_support_xa;
SELECT @global_start_value;
@global_start_value
1
SET @@session.tokudb_support_xa = 0;
SET @@session.tokudb_support_xa = DEFAULT;
SELECT @@session.tokudb_support_xa;
@@session.tokudb_support_xa
1
SET @@global.tokudb_support_xa = 0;
SET @@global.tokudb_support_xa = DEFAULT;
SELECT @@global.tokudb_support_xa;
@@global.tokudb_support_xa
1
'#--------------------case#1 valid set support_xa------------------------#'
SET @@session.tokudb_support_xa = 0;
SELECT @@session.tokudb_support_xa;
@@session.tokudb_support_xa
0
SET @@session.tokudb_support_xa = 1;
SELECT @@session.tokudb_support_xa;
@@session.tokudb_support_xa
1
SET @@global.tokudb_support_xa = 0;
SELECT @@global.tokudb_support_xa;
@@global.tokudb_support_xa
0
SET @@global.tokudb_support_xa = 1;
SELECT @@global.tokudb_support_xa;
@@global.tokudb_support_xa
1
'#--------------------case#2 invalid set support_xa------------------------#'
SET @@session.tokudb_support_xa = -0.6;
ERROR 42000: Incorrect argument type to variable 'tokudb_support_xa'
SET @@session.tokudb_support_xa = 1.6;
ERROR 42000: Incorrect argument type to variable 'tokudb_support_xa'
SET @@session.tokudb_support_xa = "T";
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of 'T'
SET @@session.tokudb_support_xa = "Y";
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of 'Y'
SET @@session.tokudb_support_xa = OF;
SELECT @@session.tokudb_support_xa;
@@session.tokudb_support_xa
0
SET @@global.tokudb_support_xa = 2;
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of '2'
SET @@global.tokudb_support_xa = "T";
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of 'T'
SET @@global.tokudb_support_xa = "Y";
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of 'Y'
'#--------------------case#3 xa.test port from tokudb_mariadb/xa.test ------------------------#'
'#--------------------xa.test with tokudb_support_xa OFF ------------------------#'
SET @@global.tokudb_support_xa = OFF;
SELECT @@global.tokudb_support_xa;
@@global.tokudb_support_xa
0
create table t1 (a int) engine=tokudb;
xa start 'test1';
insert t1 values (10);
xa end 'test1';
xa prepare 'test1';
xa rollback 'test1';
select * from t1;
a
xa start 'test2';
xa start 'test-bad';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
insert t1 values (20);
xa prepare 'test2';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
xa end 'test2';
xa prepare 'test2';
xa commit 'test2';
select * from t1;
a
20
xa start 'testa','testb';
insert t1 values (30);
commit;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
xa end 'testa','testb';
begin;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
create table t2 (a int);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
xa start 'testa','testb';
ERROR XAE08: XAER_DUPID: The XID already exists
xa start 'testa','testb', 123;
ERROR XAE08: XAER_DUPID: The XID already exists
xa start 0x7465737462, 0x2030405060, 0xb;
insert t1 values (40);
xa end 'testb',' 0@P`',11;
xa prepare 'testb',0x2030405060,11;
start transaction;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
xa recover;
formatID gtrid_length bqual_length data
11 5 5 testb 0@P`
xa prepare 'testa','testb';
xa recover;
formatID gtrid_length bqual_length data
11 5 5 testb 0@P`
1 5 5 testatestb
xa commit 'testb',0x2030405060,11;
ERROR XAE04: XAER_NOTA: Unknown XID
xa rollback 'testa','testb';
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
select * from t1;
a
20
drop table t1;
'#--------------------end------------------------#'
SET @@session.tokudb_support_xa = @session_start_value;
SELECT @@session.tokudb_support_xa;
@@session.tokudb_support_xa
1
SET @@global.tokudb_support_xa = @global_start_value;
SELECT @@global.tokudb_support_xa;
@@global.tokudb_support_xa
1
--source include/load_sysvars.inc
let $engine=TokuDB;
--echo '#--------------------begin------------------------#'
SET @session_start_value = @@session.tokudb_support_xa;
SELECT @session_start_value;
SET @global_start_value = @@global.tokudb_support_xa;
SELECT @global_start_value;
SET @@session.tokudb_support_xa = 0;
SET @@session.tokudb_support_xa = DEFAULT;
SELECT @@session.tokudb_support_xa;
SET @@global.tokudb_support_xa = 0;
SET @@global.tokudb_support_xa = DEFAULT;
SELECT @@global.tokudb_support_xa;
--echo '#--------------------case#1 valid set support_xa------------------------#'
# for session
SET @@session.tokudb_support_xa = 0;
SELECT @@session.tokudb_support_xa;
SET @@session.tokudb_support_xa = 1;
SELECT @@session.tokudb_support_xa;
# for global
SET @@global.tokudb_support_xa = 0;
SELECT @@global.tokudb_support_xa;
SET @@global.tokudb_support_xa = 1;
SELECT @@global.tokudb_support_xa;
--echo '#--------------------case#2 invalid set support_xa------------------------#'
# for session
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.tokudb_support_xa = -0.6;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.tokudb_support_xa = 1.6;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.tokudb_support_xa = "T";
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.tokudb_support_xa = "Y";
SET @@session.tokudb_support_xa = OF;
SELECT @@session.tokudb_support_xa;
# for global
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.tokudb_support_xa = 2;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.tokudb_support_xa = "T";
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.tokudb_support_xa = "Y";
--echo '#--------------------case#3 xa.test port from tokudb_mariadb/xa.test ------------------------#'
--echo '#--------------------xa.test with tokudb_support_xa OFF ------------------------#'
SET @@global.tokudb_support_xa = OFF;
SELECT @@global.tokudb_support_xa;
create table t1 (a int) engine=tokudb;
xa start 'test1';
insert t1 values (10);
xa end 'test1';
xa prepare 'test1';
xa rollback 'test1';
select * from t1;
xa start 'test2';
--error ER_XAER_RMFAIL
xa start 'test-bad';
insert t1 values (20);
--error ER_XAER_RMFAIL
xa prepare 'test2';
xa end 'test2';
xa prepare 'test2';
xa commit 'test2';
select * from t1;
xa start 'testa','testb';
insert t1 values (30);
--error ER_XAER_RMFAIL
commit;
xa end 'testa','testb';
--error ER_XAER_RMFAIL
begin;
--error ER_XAER_RMFAIL
create table t2 (a int);
connect (con1,localhost,root,,);
connection con1;
--error ER_XAER_DUPID
xa start 'testa','testb';
--error ER_XAER_DUPID
xa start 'testa','testb', 123;
# gtrid [ , bqual [ , formatID ] ]
xa start 0x7465737462, 0x2030405060, 0xb;
insert t1 values (40);
xa end 'testb',' 0@P`',11;
xa prepare 'testb',0x2030405060,11;
--error ER_XAER_RMFAIL
start transaction;
xa recover;
connection default;
xa prepare 'testa','testb';
xa recover;
--error ER_XAER_NOTA
xa commit 'testb',0x2030405060,11;
xa rollback 'testa','testb';
--error ER_PARSE_ERROR
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
select * from t1;
disconnect con1;
connection default;
drop table t1;
--echo '#--------------------end------------------------#'
SET @@session.tokudb_support_xa = @session_start_value;
SELECT @@session.tokudb_support_xa;
SET @@global.tokudb_support_xa = @global_start_value;
SELECT @@global.tokudb_support_xa;
...@@ -830,6 +830,12 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) { ...@@ -830,6 +830,12 @@ static int tokudb_rollback(handlerton * hton, THD * thd, bool all) {
static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) { static int tokudb_xa_prepare(handlerton* hton, THD* thd, bool all) {
TOKUDB_DBUG_ENTER(""); TOKUDB_DBUG_ENTER("");
int r = 0; int r = 0;
/* if support_xa is disable, just return */
if (!THDVAR(thd, support_xa)) {
TOKUDB_DBUG_RETURN(r);
}
DBUG_PRINT("trans", ("preparing transaction %s", all ? "all" : "stmt")); DBUG_PRINT("trans", ("preparing transaction %s", all ? "all" : "stmt"));
tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton); tokudb_trx_data *trx = (tokudb_trx_data *) thd_get_ha_data(thd, hton);
DB_TXN* txn = all ? trx->all : trx->stmt; DB_TXN* txn = all ? trx->all : trx->stmt;
...@@ -1433,6 +1439,9 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1433,6 +1439,9 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(check_jemalloc), MYSQL_SYSVAR(check_jemalloc),
#endif #endif
MYSQL_SYSVAR(bulk_fetch), MYSQL_SYSVAR(bulk_fetch),
#if TOKU_INCLUDE_XA
MYSQL_SYSVAR(support_xa),
#endif
NULL NULL
}; };
......
...@@ -515,6 +515,16 @@ static uint tokudb_check_jemalloc; ...@@ -515,6 +515,16 @@ static uint tokudb_check_jemalloc;
static MYSQL_SYSVAR_UINT(check_jemalloc, tokudb_check_jemalloc, 0, "Check if jemalloc is linked", NULL, NULL, 1, 0, 1, 0); static MYSQL_SYSVAR_UINT(check_jemalloc, tokudb_check_jemalloc, 0, "Check if jemalloc is linked", NULL, NULL, 1, 0, 1, 0);
#endif #endif
#if TOKU_INCLUDE_XA
static MYSQL_THDVAR_BOOL(support_xa,
PLUGIN_VAR_OPCMDARG,
"Enable TokuDB support for the XA two-phase commit",
NULL, // check
NULL, // update
true // default
);
#endif
static MYSQL_THDVAR_BOOL(bulk_fetch, PLUGIN_VAR_THDLOCAL, "enable bulk fetch", NULL /*check*/, NULL /*update*/, true /*default*/); static MYSQL_THDVAR_BOOL(bulk_fetch, PLUGIN_VAR_THDLOCAL, "enable bulk fetch", NULL /*check*/, NULL /*update*/, true /*default*/);
extern HASH tokudb_open_tables; extern HASH tokudb_open_tables;
......
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