revision-id: 5e044f78c0a9a8cd40dedff0e4bc857c0bd76b95 (mariadb-10.2.18-336-g5e044f7) parent(s): 1f020299f816263e347c852eb2a494b5ef1cbf0d author: Igor Babaev committer: Igor Babaev timestamp: 2019-03-16 15:08:17 -0700 message: MDEV-18945 Assertion `fixed == 1' failed in Item_cond_and::val_int In the function make_cond_for_table_from_pred a call of ix_fields() missed checking of the return code. As a result an extracted constant condition could be not well formed and this caused an assertion failure. --- mysql-test/r/update.result | 13 +++++++++++++ mysql-test/t/update.test | 19 +++++++++++++++++++ sql/sql_select.cc | 3 ++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 73ebb73..9e19abc 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -719,3 +719,16 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 drop table t1, t2; # End of MariaDB 10.0 tests +# +# MDEV-18945: multi-table update with constant table and +# comparison of date field with integer field +# +CREATE TABLE t1 (i1 int, d1 date , i2 int , d2 date) engine=myisam; +INSERT INTO t1 VALUES (19,'0000-00-00',73,'2008-05-21'); +CREATE TABLE t2 (d1 date , i1 int, i2 int , d2 date) engine=myisam; +INSERT INTO t2 VALUES +('2006-01-12',-102,45,'2023-11-25'),('2034-12-19',-102,45,'2001-11-20'); +UPDATE t1,t2 SET t1.i1 = -39 WHERE t2.d1 <> t1.i1 AND t2.d1 = t1.d2; +ERROR 22007: Incorrect datetime value: '19' for column `test`.`t1`.`i1` at row 1 +DROP TABLE t1,t2; +# End of MariaDB 10.2 tests diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index e5ef0b1..8470910 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -654,3 +654,22 @@ show status like 'Handler_read%'; drop table t1, t2; --echo # End of MariaDB 10.0 tests + +--echo # +--echo # MDEV-18945: multi-table update with constant table and +--echo # comparison of date field with integer field +--echo # + +CREATE TABLE t1 (i1 int, d1 date , i2 int , d2 date) engine=myisam; +INSERT INTO t1 VALUES (19,'0000-00-00',73,'2008-05-21'); + +CREATE TABLE t2 (d1 date , i1 int, i2 int , d2 date) engine=myisam; +INSERT INTO t2 VALUES + ('2006-01-12',-102,45,'2023-11-25'),('2034-12-19',-102,45,'2001-11-20'); + +--error ER_TRUNCATED_WRONG_VALUE +UPDATE t1,t2 SET t1.i1 = -39 WHERE t2.d1 <> t1.i1 AND t2.d1 = t1.d2; + +DROP TABLE t1,t2; + +--echo # End of MariaDB 10.2 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1dfd652..6253c39 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -20614,7 +20614,8 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, the new parent Item. This should not be expensive because all children of Item_cond_and should be fixed by now. */ - new_cond->fix_fields(thd, 0); + if (new_cond->fix_fields(thd, 0)) + return (COND*) 0; new_cond->used_tables_cache= ((Item_cond_and*) cond)->used_tables_cache & tables;