MDEV-34085 Server crash ASAN used-after-poison upon 2nd execution of PS with erroneous timestamp conversion
The optimization code replacing DATETIME comparison to TIMESTAMP comparison in conditions like: - WHERE timestamp_col=const_expr - WHERE const_expr IN (SELECT timestamp_column FROM t1) worked as follows: - Install an internal condition handler (suppressing and counting warnings). - Convert const_expr from its data type to TIMESTAMP - Check the warning count collected by the internal condition handler: * If any warnings happened during the constant conversion, then continue with DATETIME comparison. * Otherwise, go to the next stage of switching to TIMESTAMP comparison. This scenario did not take into account that in some cases warnings are escalated to errors. Errors were not caught by the internal handler, so Type_handler_datetime_common::convert_item_for_comparison() returned with an SQL error in the diagnostics area. The calling code did not expect this. Fixing the code to suppress and count both errors and warnings, to make sure Type_handler_datetime_common::convert_item_for_comparison() returns without adding any errors to DA if the conversion to TIMESTAMP fails and it decides to go with DATETIME comparison.
This commit is contained in:
parent
3fa2caf553
commit
0e8e157510
@ -2207,5 +2207,17 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2024-01-01 00:00:00.000000'
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-34085 Server crash ASAN used-after-poison upon 2nd execution of PS with erroneous timestamp conversion
|
||||
#
|
||||
CREATE TABLE t1 (a int, b timestamp);
|
||||
INSERT INTO t1 VALUES (1,'2000-01-01'),(2,'2001-12-31');
|
||||
PREPARE stmt FROM 'UPDATE t1 SET a = 0 WHERE 1 IN (SELECT b FROM t1)';
|
||||
EXECUTE stmt;
|
||||
ERROR 22007: Truncated incorrect datetime value: '1'
|
||||
EXECUTE stmt;
|
||||
ERROR 22007: Truncated incorrect datetime value: '1'
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 11.3 tests
|
||||
#
|
||||
|
@ -1255,6 +1255,21 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE YEAR(a) >= 2024;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-34085 Server crash ASAN used-after-poison upon 2nd execution of PS with erroneous timestamp conversion
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int, b timestamp);
|
||||
INSERT INTO t1 VALUES (1,'2000-01-01'),(2,'2001-12-31');
|
||||
PREPARE stmt FROM 'UPDATE t1 SET a = 0 WHERE 1 IN (SELECT b FROM t1)';
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
EXECUTE stmt;
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 11.3 tests
|
||||
--echo #
|
||||
|
@ -7776,7 +7776,7 @@ Type_handler_datetime_common::convert_item_for_comparison(
|
||||
Sql_condition **cond_hdl)
|
||||
{
|
||||
hit++;
|
||||
return *level == Sql_condition::WARN_LEVEL_WARN;
|
||||
return *level >= Sql_condition::WARN_LEVEL_WARN;
|
||||
}
|
||||
} cnt_handler;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user