diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 1950410c7c4..e00e6d8bacd 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -2335,3 +2335,14 @@ DROP TABLE t1; # # End of 11.3 tests # +# Start of 11.4 tests +# +# MDEV-35677 Assertion `thd->is_error()' failed in virtual bool Field::sp_prepare_and_store_item(THD*, Item**) +# +CREATE FUNCTION f() RETURNS INT DETERMINISTIC RETURN (SELECT a FROM t); +CREATE TABLE t (c TIMESTAMP); +SELECT * FROM t WHERE c=f(); +ERROR 42S22: Unknown column 'a' in 'SELECT' +DROP TABLE t; +DROP FUNCTION f; +# End of 11.4 tests diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 8b45bd1590c..2b0e772d54b 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -1370,3 +1370,21 @@ DROP TABLE t1; --echo # --echo # End of 11.3 tests --echo # + +--echo # Start of 11.4 tests + +--echo # +--echo # MDEV-35677 Assertion `thd->is_error()' failed in virtual bool Field::sp_prepare_and_store_item(THD*, Item**) +--echo # + +CREATE FUNCTION f() RETURNS INT DETERMINISTIC RETURN (SELECT a FROM t); +CREATE TABLE t (c TIMESTAMP); +# with view protocol it raises ER_VIEW_INVALID +--disable_view_protocol +--error ER_BAD_FIELD_ERROR +SELECT * FROM t WHERE c=f(); +--enable_view_protocol +DROP TABLE t; +DROP FUNCTION f; + +--echo # End of 11.4 tests diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 12c971b3bd7..2c74c42b1be 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -7959,8 +7959,13 @@ Type_handler_datetime_common::convert_item_for_comparison( const char *msg, Sql_condition **cond_hdl) override { - hit++; - return *level >= Sql_condition::WARN_LEVEL_WARN; + if (sql_errno == ER_TRUNCATED_WRONG_VALUE || + sql_errno == ER_DATETIME_FUNCTION_OVERFLOW) + { + hit++; + return *level >= Sql_condition::WARN_LEVEL_WARN; + } + return false; } } cnt_handler;