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.
This commit is contained in:
Vladislav Vaintroub 2025-06-23 15:38:49 +02:00
parent 6e9e48648a
commit c742cc94ba
3 changed files with 42 additions and 1 deletions

View File

@ -60,3 +60,22 @@ drop table t1;
#
# End of 10.11 tests
#
#
# MDEV-35611 Assertion failure in Diagnostics_area::sql_errno upon interrupted ALTER
#
CREATE TABLE t (a INT) ENGINE=MyISAM;
INSERT INTO t VALUES (1);
LOCK TABLE t READ;
connection con1;
SET max_statement_time=0.001;
ALTER TABLE t FORCE;
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
ALTER TABLE IF EXISTS t FORCE;
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
disconnect con1;
connection default;
UNLOCK TABLES;
DROP TABLE t;
#
# End of 11.4 tests
#

View File

@ -78,3 +78,25 @@ drop table t1;
--echo #
--echo # End of 10.11 tests
--echo #
--echo #
--echo # MDEV-35611 Assertion failure in Diagnostics_area::sql_errno upon interrupted ALTER
--echo #
CREATE TABLE t (a INT) ENGINE=MyISAM;
INSERT INTO t VALUES (1);
LOCK TABLE t READ;
--connection con1
SET max_statement_time=0.001;
--error ER_STATEMENT_TIMEOUT
ALTER TABLE t FORCE;
--error ER_STATEMENT_TIMEOUT
ALTER TABLE IF EXISTS t FORCE;
# Cleanup
--disconnect con1
--connection default
UNLOCK TABLES;
DROP TABLE t;
--echo #
--echo # End of 11.4 tests
--echo #

View File

@ -10655,7 +10655,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
if (unlikely(error))
{
if (if_exists)
if (if_exists && thd->get_stmt_da()->is_error())
{
int tmp_errno= thd->get_stmt_da()->sql_errno();
if (tmp_errno == ER_NO_SUCH_TABLE)