Skip to content

Commit

Permalink
MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comp…
Browse files Browse the repository at this point in the history
…arison
  • Loading branch information
Alexander Barkov committed Nov 2, 2017
1 parent 892cf2d commit d8a9b52
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mysql-test/r/type_date.result
Original file line number Diff line number Diff line change
Expand Up @@ -843,5 +843,16 @@ Warning 1292 Incorrect datetime value: '1'
Warning 1292 Incorrect datetime value: '1'
DROP TABLE t1;
#
# MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comparison
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24');
SELECT d, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP HAVING CASE d WHEN '2017-05-25' THEN 0 ELSE 1 END;
d COUNT(*)
1985-05-13 1
1989-12-24 1
NULL 2
DROP TABLE t1;
#
# End of 10.1 tests
#
9 changes: 9 additions & 0 deletions mysql-test/t/type_date.test
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,15 @@ SELECT DATE(a), DATE(b), DATE(c) FROM t1;
SELECT DATE(COALESCE(a)), DATE(COALESCE(b)), DATE(COALESCE(c)) FROM t1;
DROP TABLE t1;

--echo #
--echo # MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comparison
--echo #

CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24');
SELECT d, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP HAVING CASE d WHEN '2017-05-25' THEN 0 ELSE 1 END;
DROP TABLE t1;


--echo #
--echo # End of 10.1 tests
Expand Down
11 changes: 11 additions & 0 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -2581,6 +2581,17 @@ class Item_null_result :public Item_null
Field *result_field;
Item_null_result(THD *thd): Item_null(thd), result_field(0) {}
bool is_result_field() { return result_field != 0; }
#if MARIADB_VERSION_ID < 100300
enum_field_types field_type() const
{
return result_field->type();
}
#else
const Type_handler *type_handler() const
{
return result_field->type_handler();
}
#endif
void save_in_result_field(bool no_conversions)
{
save_in_field(result_field, no_conversions);
Expand Down

0 comments on commit d8a9b52

Please sign in to comment.