Skip to content
Permalink
Browse files
XA PREPARE and SHOW STATUS
XA transaction only allows to access data in specific states,
in ACTIVE, but not in IDLE or PREPARE.

But even then one should be able to run SHOW STATUS.
  • Loading branch information
vuvova committed May 8, 2021
1 parent 18fbe56 commit 66acec9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
@@ -317,3 +317,29 @@ XA ROLLBACK 'xid';
DROP TABLE t1;
disconnect con1;
connection default;
#
# XA states and SHOW commands
#
create table t1 (pk int primary key) engine=innodb;
xa start 'foo';
insert t1 set pk=1;
xa end 'foo';
xa prepare 'foo';
show status like 'foo';
Variable_name Value
select table_name,table_comment from information_schema.tables where table_schema='test';
table_name t1
table_comment
select table_name,table_rows,table_comment from information_schema.tables where table_schema='test';
table_name t1
table_rows NULL
table_comment XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
Warnings:
Level Warning
Code 1399
Message XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
xa commit 'foo';
drop table t1;
#
# End of 10.2 tests
#
@@ -470,3 +470,21 @@ DROP TABLE t1;
connection default;

--source include/wait_until_count_sessions.inc

--echo #
--echo # XA states and SHOW commands
--echo #
create table t1 (pk int primary key) engine=innodb;
xa start 'foo';
insert t1 set pk=1;
xa end 'foo';
xa prepare 'foo';
show status like 'foo';
--query_vertical select table_name,table_comment from information_schema.tables where table_schema='test'
--query_vertical select table_name,table_rows,table_comment from information_schema.tables where table_schema='test'
xa commit 'foo';
drop table t1;

--echo #
--echo # End of 10.2 tests
--echo #
@@ -3985,13 +3985,19 @@ bool open_tables(THD *thd, const DDL_options_st &options,
bool has_prelocking_list;
DBUG_ENTER("open_tables");

/* Accessing data in XA_IDLE or XA_PREPARED is not allowed. */
enum xa_states xa_state= thd->transaction.xid_state.xa_state;
if (*start && (xa_state == XA_IDLE || xa_state == XA_PREPARED))
{
my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[xa_state]);
DBUG_RETURN(true);
}
/* Data access in XA transaction is only allowed when it is active. */
for (TABLE_LIST *table= *start; table; table= table->next_global)
if (!table->schema_table)
{
enum xa_states xa_state= thd->transaction.xid_state.xa_state;
if (xa_state == XA_IDLE || xa_state == XA_PREPARED)
{
my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[xa_state]);
DBUG_RETURN(true);
}
else
break;
}

thd->current_tablenr= 0;
restart:

0 comments on commit 66acec9

Please sign in to comment.