mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-35677 Assertion `thd->is_error()' failed in virtual bool Field::sp_prepare_and_store_item(THD*, Item**)
The Count_handler (derived from Internal_error_handler) used in Type_handler_datetime_common::convert_item_for_comparison() suppressed all error codes. This caused a DBUG_ASSERT(thd->is_error()) in Field::sp_prepare_and_store_item() when the error happened while evaluating a subselect in a scenario like this: CREATE FUNCTION f() RETURNS INT DETERMINISTIC RETURN (SELECT a FROM t); CREATE TABLE t (c TIMESTAMP); SELECT * FROM t WHERE c=f(); Notice there is no such column 'a' in in the table 't'. Fix: Handle only DATETIME->TIMESTAMP conversion related errors in Count_handler: - ER_TRUNCATED_WRONG_VALUE - ER_DATETIME_FUNCTION_OVERFLOW thus let other error kinds be processed in their usual way. The reported scenario now returns this (expected) error: ERROR 1054 (42S22): Unknown column 'a' in 'SELECT'
This commit is contained in:
@ -2335,3 +2335,14 @@ DROP TABLE t1;
|
|||||||
#
|
#
|
||||||
# End of 11.3 tests
|
# 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
|
||||||
|
@ -1370,3 +1370,21 @@ DROP TABLE t1;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # End of 11.3 tests
|
--echo # End of 11.3 tests
|
||||||
--echo #
|
--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
|
||||||
|
@ -7959,8 +7959,13 @@ Type_handler_datetime_common::convert_item_for_comparison(
|
|||||||
const char *msg,
|
const char *msg,
|
||||||
Sql_condition **cond_hdl) override
|
Sql_condition **cond_hdl) override
|
||||||
{
|
{
|
||||||
hit++;
|
if (sql_errno == ER_TRUNCATED_WRONG_VALUE ||
|
||||||
return *level >= Sql_condition::WARN_LEVEL_WARN;
|
sql_errno == ER_DATETIME_FUNCTION_OVERFLOW)
|
||||||
|
{
|
||||||
|
hit++;
|
||||||
|
return *level >= Sql_condition::WARN_LEVEL_WARN;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} cnt_handler;
|
} cnt_handler;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user