diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2021-01-18 20:21:33 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2021-01-19 15:36:35 +0530 |
commit | 5d4853085b588b823242143fe31bc8e02882ee89 (patch) | |
tree | 2ac67662636541ba9d5830ebcdece396f4fb7dc6 | |
parent | beaea31ab12ab56ea8a6eb5e99cf82648675ea78 (diff) | |
download | mariadb-git-5d4853085b588b823242143fe31bc8e02882ee89.tar.gz |
MDEV-22768: Assertion `! is_set() || m_can_overwrite_status' failed inbb-10.2-MDEV-22768
Diagnostics_area::set_error_status
Analysis: Error occurs while restoring set statement variable after the
statement succeeds. Since the statement has already succeeded, OK is already
sent. So, diagnostics area status is already DA_OK.
Fix: Reset the diagnostics area if OK is already sent because error can happen
while restoring set statement variable.
-rw-r--r-- | mysql-test/suite/sys_vars/r/gtid_domain_id_basic.result | 24 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/gtid_domain_id_basic.test | 27 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 |
3 files changed, 53 insertions, 0 deletions
diff --git a/mysql-test/suite/sys_vars/r/gtid_domain_id_basic.result b/mysql-test/suite/sys_vars/r/gtid_domain_id_basic.result index ac195ecb13b..f613ebc065a 100644 --- a/mysql-test/suite/sys_vars/r/gtid_domain_id_basic.result +++ b/mysql-test/suite/sys_vars/r/gtid_domain_id_basic.result @@ -27,3 +27,27 @@ SELECT @@session.gtid_domain_id; @@session.gtid_domain_id 0 SET GLOBAL gtid_domain_id= @old_gtid_domain_id; +# +# 10.2 Test +# +# MDEV-22768: Assertion `! is_set() || m_can_overwrite_status' +# failed in Diagnostics_area::set_error_status +# +SET @old_mode= @@sql_mode; +SET @old_autocommit=@@autocommit; +SET @old_init_connect= @@GLOBAL.init_connect; +USE test; +SET SQL_MODE=''; +SET AUTOCOMMIT=0; +CREATE TABLE t(c CHAR (0)); +SET STATEMENT gtid_domain_id=0 FOR INSERT INTO t VALUES(0),(0); +Warnings: +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'c' at row 2 +Error 1953 Cannot modify @@session.gtid_domain_id or @@session.gtid_seq_no inside a transaction +SET GLOBAL init_connect="SET @a=0"; +DROP TABLE t; +SET @@sql_mode= @old_mode; +SET @@autocommit=@old_autocommit; +SET @@GLOBAL.init_connect= @old_init_connect; +# End of 10.2 Test diff --git a/mysql-test/suite/sys_vars/t/gtid_domain_id_basic.test b/mysql-test/suite/sys_vars/t/gtid_domain_id_basic.test index f9c78fe2749..340ed3749ee 100644 --- a/mysql-test/suite/sys_vars/t/gtid_domain_id_basic.test +++ b/mysql-test/suite/sys_vars/t/gtid_domain_id_basic.test @@ -1,3 +1,5 @@ +--source include/have_log_bin.inc + SET @old_gtid_domain_id= @@global.gtid_domain_id; SELECT @@global.gtid_domain_id; @@ -15,3 +17,28 @@ SET SESSION gtid_domain_id= -1; SELECT @@session.gtid_domain_id; SET GLOBAL gtid_domain_id= @old_gtid_domain_id; + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-22768: Assertion `! is_set() || m_can_overwrite_status' +--echo # failed in Diagnostics_area::set_error_status +--echo # + +SET @old_mode= @@sql_mode; +SET @old_autocommit=@@autocommit; +SET @old_init_connect= @@GLOBAL.init_connect; + +USE test; +SET SQL_MODE=''; +SET AUTOCOMMIT=0; +CREATE TABLE t(c CHAR (0)); +SET STATEMENT gtid_domain_id=0 FOR INSERT INTO t VALUES(0),(0); +SET GLOBAL init_connect="SET @a=0"; + +DROP TABLE t; +SET @@sql_mode= @old_mode; +SET @@autocommit=@old_autocommit; +SET @@GLOBAL.init_connect= @old_init_connect; + +--echo # End of 10.2 Test diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 131ba4a86c5..26881321e97 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2442,6 +2442,8 @@ com_multi_end: /* Check that some variables are reset properly */ DBUG_ASSERT(thd->abort_on_warning == 0); + if (thd->get_stmt_da()->is_ok()) + thd->get_stmt_da()->reset_diagnostics_area(); thd->lex->restore_set_statement_var(); DBUG_RETURN(error); } |