Commit 127ed74f authored by Andrei Elkin's avatar Andrei Elkin

MDEV-22420 DDL on temporary object is prohibited when XA is in prepare state

The parser must reject DDL operations on temporary objects when
they may modify or alter such object, including temporary tables and sequences.
The rejection is regardless (has been already in place for bin-loggable DML:s)
of the binlogging capability of the server or connection.

The patch implements the requirement. A binlog test is added.
parent 545a6194
CREATE TEMPORARY SEQUENCE seq_1;
XA START '3';
CREATE TEMPORARY TABLE tmp_1(c INT);
XA END '3';
XA PREPARE '3';
DROP TEMPORARY TABLE tmp_1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
ALTER TABLE tmp_1 DROP COLUMN c;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
DROP TEMPORARY SEQUENCE seq_1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
ALTER SEQUENCE seq_1 INCREMENT BY 1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
CREATE TEMPORARY TABLE tmp_2(c INT);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
CREATE TEMPORARY SEQUENCE seq_2;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
XA ROLLBACK '3';
# Proof of correct logging incl empty XA-PREPARE
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY SEQUENCE seq_1
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp_1(c INT)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # XA START X'33',X'',1 GTID #-#-#
master-bin.000001 # Query # # XA END X'33',X'',1
master-bin.000001 # XA_prepare # # XA PREPARE X'33',X'',1
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # XA ROLLBACK X'33',X'',1
# The test verifies execution and binary logging of user XA that produce empty
# XA-PREPARE group of events.
--source include/have_binlog_format_mixed.inc
--source include/have_innodb.inc
# MDEV-22420 DDL on temporary object is prohibited when XA is in prepare state
# Temporary sequnce may not be created within a transaction
CREATE TEMPORARY SEQUENCE seq_1;
XA START '3';
CREATE TEMPORARY TABLE tmp_1(c INT);
XA END '3';
XA PREPARE '3';
--error ER_XAER_RMFAIL
DROP TEMPORARY TABLE tmp_1;
--error ER_XAER_RMFAIL
ALTER TABLE tmp_1 DROP COLUMN c;
--error ER_XAER_RMFAIL
DROP TEMPORARY SEQUENCE seq_1;
--error ER_XAER_RMFAIL
ALTER SEQUENCE seq_1 INCREMENT BY 1;
--error ER_XAER_RMFAIL
CREATE TEMPORARY TABLE tmp_2(c INT);
--error ER_XAER_RMFAIL
CREATE TEMPORARY SEQUENCE seq_2;
# Cleanup
XA ROLLBACK '3';
--echo # Proof of correct logging incl empty XA-PREPARE
--source include/show_binlog_events.inc
...@@ -4890,6 +4890,8 @@ mysql_execute_command(THD *thd) ...@@ -4890,6 +4890,8 @@ mysql_execute_command(THD *thd)
} }
else else
{ {
if (thd->transaction->xid_state.check_has_uncommitted_xa())
goto error;
status_var_decrement(thd->status_var.com_stat[lex->sql_command]); status_var_decrement(thd->status_var.com_stat[lex->sql_command]);
status_var_increment(thd->status_var.com_drop_tmp_table); status_var_increment(thd->status_var.com_drop_tmp_table);
......
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