From b5d0e3092343bfb23fe5fb65c019159f0133026f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 15 Apr 2025 00:18:23 +0200 Subject: [PATCH] MDEV-36596 Assertion failure in TABLE_SHARE::init_from_sql_statement_string upon returning wrong type from function WHERE clause evaluation can fail --- mysql-test/main/information_schema2.result | 8 ++++++++ mysql-test/main/information_schema2.test | 10 ++++++++++ sql/sql_show.cc | 2 ++ 3 files changed, 20 insertions(+) diff --git a/mysql-test/main/information_schema2.result b/mysql-test/main/information_schema2.result index fa4d71bf227..eb0a1e4c0ff 100644 --- a/mysql-test/main/information_schema2.result +++ b/mysql-test/main/information_schema2.result @@ -36,3 +36,11 @@ index_name comment a disabled drop table t1; # End of 10.5 tests +# +# MDEV-36596 Assertion failure in TABLE_SHARE::init_from_sql_statement_string upon returning wrong type from function +# +create function f() returns int return (1>2,1,2); +select * from information_schema.columns where f() is null; +ERROR HY000: Cannot cast 'row' as 'int' in assignment of `(null)` +drop function f; +# End of 11.8 tests diff --git a/mysql-test/main/information_schema2.test b/mysql-test/main/information_schema2.test index 50ceec2c5d3..517746e7901 100644 --- a/mysql-test/main/information_schema2.test +++ b/mysql-test/main/information_schema2.test @@ -28,3 +28,13 @@ select index_name, comment from information_schema.statistics where table_schema drop table t1; --echo # End of 10.5 tests + +--echo # +--echo # MDEV-36596 Assertion failure in TABLE_SHARE::init_from_sql_statement_string upon returning wrong type from function +--echo # +create function f() returns int return (1>2,1,2); +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +select * from information_schema.columns where f() is null; +drop function f; + +--echo # End of 11.8 tests diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8d8ad22ebcb..17c1455d302 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5622,6 +5622,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) if (!partial_cond || partial_cond->val_bool()) { + if (thd->is_error()) + goto err; /* If table is I_S.tables and open_table_method is 0 (eg SKIP_OPEN) we can skip table opening and we don't have lookup value for