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.
This commit is contained in:
parent
545a6194e8
commit
127ed74fd2
31
mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result
Normal file
31
mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result
Normal file
@ -0,0 +1,31 @@
|
||||
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
|
35
mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test
Normal file
35
mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test
Normal file
@ -0,0 +1,35 @@
|
||||
# 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)
|
||||
}
|
||||
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_increment(thd->status_var.com_drop_tmp_table);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user