Commit caebe151 authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-22445 Crash on HANDLER READ NEXT after XA PREPARE

The assertion is absolutely correct since no data access is possible after
XA PREPARE.

The check is added in mysql_ha_read.
parent 1811fd51
......@@ -341,5 +341,20 @@ Message XAER_RMFAIL: The command cannot be executed when global transaction is i
xa commit 'foo';
drop table t1;
#
# MDEV-22445 Crash on HANDLER READ NEXT after XA PREPARE
#
CREATE TABLE t (a INT KEY) ENGINE=InnoDB;
HANDLER t OPEN AS t;
XA START '0';
SELECT * FROM t;
a
XA END '0';
XA PREPARE '0';
HANDLER t READ NEXT;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
# Cleanup
XA COMMIT '0';
DROP TABLE t;
#
# End of 10.2 tests
#
......@@ -485,6 +485,23 @@ show status like 'foo';
xa commit 'foo';
drop table t1;
--echo #
--echo # MDEV-22445 Crash on HANDLER READ NEXT after XA PREPARE
--echo #
CREATE TABLE t (a INT KEY) ENGINE=InnoDB;
HANDLER t OPEN AS t;
XA START '0';
SELECT * FROM t;
XA END '0';
XA PREPARE '0';
--error ER_XAER_RMFAIL
HANDLER t READ NEXT;
--echo # Cleanup
XA COMMIT '0';
DROP TABLE t;
--echo #
--echo # End of 10.2 tests
--echo #
......@@ -697,6 +697,9 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
if (!(handler= mysql_ha_find_handler(thd, tables->alias)))
goto err0;
if (thd->transaction.xid_state.check_has_uncommitted_xa())
goto err0;
table= handler->table;
tables->table= table; // This is used by fix_fields
table->pos_in_table_list= 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