Skip to content

Commit c742cc9

Browse files
committed
MDEV-35611 ALTER IF EXISTS assertions in sql_errno with statement timeout
Check stmt_da::is_error before calling stmt_da::sql_errno(which is what the assertion ensures) The bug did not have any negative effects in optimized builds.
1 parent 6e9e486 commit c742cc9

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

mysql-test/main/alter_table_lock.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,22 @@ drop table t1;
6060
#
6161
# End of 10.11 tests
6262
#
63+
#
64+
# MDEV-35611 Assertion failure in Diagnostics_area::sql_errno upon interrupted ALTER
65+
#
66+
CREATE TABLE t (a INT) ENGINE=MyISAM;
67+
INSERT INTO t VALUES (1);
68+
LOCK TABLE t READ;
69+
connection con1;
70+
SET max_statement_time=0.001;
71+
ALTER TABLE t FORCE;
72+
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
73+
ALTER TABLE IF EXISTS t FORCE;
74+
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
75+
disconnect con1;
76+
connection default;
77+
UNLOCK TABLES;
78+
DROP TABLE t;
79+
#
80+
# End of 11.4 tests
81+
#

mysql-test/main/alter_table_lock.test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,25 @@ drop table t1;
7878
--echo #
7979
--echo # End of 10.11 tests
8080
--echo #
81+
82+
--echo #
83+
--echo # MDEV-35611 Assertion failure in Diagnostics_area::sql_errno upon interrupted ALTER
84+
--echo #
85+
CREATE TABLE t (a INT) ENGINE=MyISAM;
86+
INSERT INTO t VALUES (1);
87+
LOCK TABLE t READ;
88+
--connection con1
89+
SET max_statement_time=0.001;
90+
--error ER_STATEMENT_TIMEOUT
91+
ALTER TABLE t FORCE;
92+
--error ER_STATEMENT_TIMEOUT
93+
ALTER TABLE IF EXISTS t FORCE;
94+
# Cleanup
95+
--disconnect con1
96+
--connection default
97+
UNLOCK TABLES;
98+
DROP TABLE t;
99+
100+
--echo #
101+
--echo # End of 11.4 tests
102+
--echo #

sql/sql_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10655,7 +10655,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
1065510655

1065610656
if (unlikely(error))
1065710657
{
10658-
if (if_exists)
10658+
if (if_exists && thd->get_stmt_da()->is_error())
1065910659
{
1066010660
int tmp_errno= thd->get_stmt_da()->sql_errno();
1066110661
if (tmp_errno == ER_NO_SUCH_TABLE)

0 commit comments

Comments
 (0)