the last example is oversimplified, it's a different bug. It fails because Item_cache_temporal::cache_value ignores null_value that was set in the failed datetime conversion, can be fixed with
--- a/sql/item.cc
|
+++ b/sql/item.cc
|
@@ -10637,7 +10637,7 @@ bool Item_cache_temporal::cache_value()
|
return false;
|
value_cached= true;
|
value= example->val_datetime_packed_result(current_thd);
|
- null_value_inside= null_value= example->null_value;
|
+ null_value_inside= null_value;
|
return true;
|
}
|
This test
create table t1 (c1 tinyint);
|
insert into t1 (c1) values (1);
|
select c1 in (date'0000-00-00') from t1;
|
drop table t1;
|
fails differently. It's because Item_field::val_datetime_packed() invokes Field::val_datetime_packed() which cannot return NULL for failed datetime conversion. Item_field::get_date() is correct, though.
I try other integer data types like follows, in which the `BIGINT` data type returns the expected data type.