Commit a9a06454 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-34589 spider: unconditionally restore da status in rollback

The documentation of ha_rollback_trans() suggests that
handlerton::rollback() should never return error:

      if ((err= ht->rollback(ht, thd, all)))
      {
        // cannot happen

Further, any error returned from ha_rollback_trans() is discarded in
trans_rollback_stmt(), and the code path in mysql_admin_table() after
calling trans_rollback_stmt() calls my_eof() which asserts clear
dastatus. So we clear the dastatus in spider_rollback() on error.
parent e6eb0629
for master_1
for child2
for child3
set spider_same_server_link= 1;
CREATE USER spider@localhost IDENTIFIED BY 'pwd';
GRANT ALL ON test.* TO spider@localhost;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'spider',PASSWORD 'pwd');
SET spider_internal_sql_log_off=0;
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", SRV "srv", TABLE "t1"' PARTITION BY HASH (c) PARTITIONS 2;
CHECK TABLE t2;
Table Op Msg_type Msg_text
test.t2 check error Partition p0 returned error
test.t2 check Error Access denied; you need (at least one of) the SUPER privilege(s) for this operation
test.t2 check Error Access denied; you need (at least one of) the SUPER privilege(s) for this operation
test.t2 check error Unknown - internal error 1227 during operation
Warnings:
Error 1227 Access denied; you need (at least one of) the SUPER privilege(s) for this operation
Error 1227 Access denied; you need (at least one of) the SUPER privilege(s) for this operation
drop table t1, t2;
drop server srv;
drop user spider@localhost;
for master_1
for child2
for child3
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link= 1;
CREATE USER spider@localhost IDENTIFIED BY 'pwd';
GRANT ALL ON test.* TO spider@localhost;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'spider',PASSWORD 'pwd');
SET spider_internal_sql_log_off=0;
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", SRV "srv", TABLE "t1"' PARTITION BY HASH (c) PARTITIONS 2;
CHECK TABLE t2;
drop table t1, t2;
drop server srv;
drop user spider@localhost;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
......@@ -451,6 +451,8 @@ enum spider_malloc_id {
if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; error_num = 0;}
#define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM \
if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; tmp_error_num = 0;}
#define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM_1 \
if (thd) {SPIDER_RESTORE_DASTATUS; tmp_error_num = 0;}
class ha_spider;
typedef struct st_spider_share SPIDER_SHARE;
......
......@@ -3225,13 +3225,13 @@ int spider_rollback(
(conn->autocommit != 1 || conn->trx_start) &&
(tmp_error_num = spider_db_rollback(conn))
) {
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM;
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM_1;
if (tmp_error_num)
error_num = tmp_error_num;
}
if ((tmp_error_num = spider_end_trx(trx, conn)))
{
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM;
SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM_1;
if (tmp_error_num)
error_num = tmp_error_num;
}
......
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