diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-05-06 22:46:56 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-05-08 10:48:13 +0200 |
commit | 34045af03f25fc2edd7c0c8db054e505f271513c (patch) | |
tree | 25f14d17460cf65238657b1e87afe4fec5fd4d90 | |
parent | 087ea8f820f46e200a2f8f84328c078555dda45f (diff) | |
download | mariadb-git-34045af03f25fc2edd7c0c8db054e505f271513c.tar.gz |
MDEV-15216 Assertion `! is_set() || m_can_overwrite_status' failed in Diagnostics_area::set_error_status upon operation inside XA
don't implicitly commit or rollback in mysql_admin_table()
unless the statement has CF_IMPLICIT_COMMIT_END flag.
-rw-r--r-- | mysql-test/r/assign_key_cache.result | 13 | ||||
-rw-r--r-- | mysql-test/r/implicit_commit.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result | 4 | ||||
-rw-r--r-- | mysql-test/t/assign_key_cache.test | 13 | ||||
-rw-r--r-- | sql/sql_admin.cc | 7 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.h | 1 |
9 files changed, 36 insertions, 18 deletions
diff --git a/mysql-test/r/assign_key_cache.result b/mysql-test/r/assign_key_cache.result new file mode 100644 index 00000000000..4ed6170136b --- /dev/null +++ b/mysql-test/r/assign_key_cache.result @@ -0,0 +1,13 @@ +set global my_cache.key_buffer_size = 1024*1024; +create table t1 (i int) engine=myisam partition by hash (i) partitions 2; +xa start 'xid'; +cache index t1 partition (non_existing_partition) in my_cache; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache error Error in list of partitions to test.t1 +cache index t1 partition (p1) in my_cache; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +xa end 'xid'; +xa rollback 'xid'; +drop table t1; +set global my_cache.key_buffer_size = 0; diff --git a/mysql-test/r/implicit_commit.result b/mysql-test/r/implicit_commit.result index d568d05e7b7..0dcee1b8f06 100644 --- a/mysql-test/r/implicit_commit.result +++ b/mysql-test/r/implicit_commit.result @@ -561,7 +561,7 @@ INSERT INTO db1.trans (a) VALUES (1); cache index t3 in keycache; CALL db1.test_if_commit(); IMPLICIT COMMIT -YES +NO set global keycache.key_buffer_size=0; # # SQLCOM_PRELOAD_KEYS @@ -570,7 +570,7 @@ INSERT INTO db1.trans (a) VALUES (1); load index into cache t3; CALL db1.test_if_commit(); IMPLICIT COMMIT -YES +NO # # SQLCOM_FLUSH # diff --git a/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result index e272961abe9..7efb1f7162b 100644 --- a/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result @@ -140,11 +140,7 @@ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# diff --git a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result index 5d6590bd821..e24a84e02a1 100644 --- a/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result @@ -145,12 +145,8 @@ master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test.tt_1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ diff --git a/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result b/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result index e272961abe9..7efb1f7162b 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result @@ -140,11 +140,7 @@ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP FUNCTION myfunc_int master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (41) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (40) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO tt_1(ddl_case) VALUES (39) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# diff --git a/mysql-test/t/assign_key_cache.test b/mysql-test/t/assign_key_cache.test new file mode 100644 index 00000000000..401e7bf9138 --- /dev/null +++ b/mysql-test/t/assign_key_cache.test @@ -0,0 +1,13 @@ +# +# MDEV-15216 Assertion `! is_set() || m_can_overwrite_status' failed in Diagnostics_area::set_error_status upon operation inside XA +# +--source include/have_partition.inc +set global my_cache.key_buffer_size = 1024*1024; +create table t1 (i int) engine=myisam partition by hash (i) partitions 2; +xa start 'xid'; +cache index t1 partition (non_existing_partition) in my_cache; +cache index t1 partition (p1) in my_cache; +xa end 'xid'; +xa rollback 'xid'; +drop table t1; +set global my_cache.key_buffer_size = 0; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 06a453e1bb7..4fe51a2189e 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1064,7 +1064,9 @@ send_result_message: } else { - if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) + if (trans_commit_stmt(thd) || + (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END) && + trans_commit_implicit(thd))) goto err; } close_thread_tables(thd); @@ -1098,7 +1100,8 @@ send_result_message: err: /* Make sure this table instance is not reused after the failure. */ trans_rollback_stmt(thd); - trans_rollback(thd); + if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END)) + trans_rollback(thd); if (table && table->table) { table->table->m_needs_reopen= true; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4c0be4ebc8b..87edf93bb4a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -192,7 +192,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables) /* - Implicitly commit a active transaction if statement requires so. + Check whether the statement implicitly commits an active transaction. @param thd Thread handle. @param mask Bitmask used for the SQL command match. @@ -200,7 +200,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables) @return 0 No implicit commit @return 1 Do a commit */ -static bool stmt_causes_implicit_commit(THD *thd, uint mask) +bool stmt_causes_implicit_commit(THD *thd, uint mask) { LEX *lex= thd->lex; bool skip= FALSE; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index fa414911093..39d92e656c8 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -84,6 +84,7 @@ bool check_identifier_name(LEX_STRING *str, uint max_char_length, uint err_code, const char *param_for_err_msg); bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); bool sqlcom_can_generate_row_events(const THD *thd); +bool stmt_causes_implicit_commit(THD *thd, uint mask); bool is_update_query(enum enum_sql_command command); bool is_log_table_write_query(enum enum_sql_command command); bool alloc_query(THD *thd, const char *packet, uint packet_length); |