summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-05-03 18:10:13 +0200
committerSergei Golubchik <serg@mariadb.org>2021-05-08 18:02:34 +0200
commit66acec99d5877241b694493e96a0265be9260c69 (patch)
treef26c6933c7a32ad0b0c47893c3baf8c774690732
parent18fbe566bdf7420fbd9b4a1a8bede76e351d3b95 (diff)
downloadmariadb-git-66acec99d5877241b694493e96a0265be9260c69.tar.gz
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.
-rw-r--r--mysql-test/r/xa.result26
-rw-r--r--mysql-test/t/xa.test18
-rw-r--r--sql/sql_base.cc20
3 files changed, 57 insertions, 7 deletions
diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result
index 8ff84862270..4e4d7bc6048 100644
--- a/mysql-test/r/xa.result
+++ b/mysql-test/r/xa.result
@@ -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
+#
diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test
index ecce563b8c8..b13d12d2019 100644
--- a/mysql-test/t/xa.test
+++ b/mysql-test/t/xa.test
@@ -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 #
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 16689f86c4e..e3c30c7433b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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: