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

Item_null_result did not override type_handler() because of a wrong merge
of d8a9b52 (MDEV-14221) from 10.1.

Overriding type_handler().

Removing the old style field_type() method. It's not relevant any more.
  • Loading branch information
abarkov committed May 22, 2020
1 parent dc22acf commit ea7830e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 11 additions & 0 deletions mysql-test/main/type_datetime_hires.result
Original file line number Diff line number Diff line change
Expand Up @@ -889,5 +889,16 @@ Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
DROP TABLE t1;
#
# MDEV-20984 Possibly wrong result or Assertion `args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_DATETIME' failed in Item_func_round::date_op
#
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('1979-01-03 10:33:32'),('2012-12-12 12:12:12');
SELECT ROUND(a) AS f FROM t1 GROUP BY a WITH ROLLUP;
f
1979-01-03 10:33:32
2012-12-12 12:12:12
NULL
DROP TABLE t1;
#
# End of 10.4 tests
#
10 changes: 10 additions & 0 deletions mysql-test/main/type_datetime_hires.test
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ SELECT a, ROUND(a,-6) FROM t1;

DROP TABLE t1;

--echo #
--echo # MDEV-20984 Possibly wrong result or Assertion `args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_DATETIME' failed in Item_func_round::date_op
--echo #

CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('1979-01-03 10:33:32'),('2012-12-12 12:12:12');
SELECT ROUND(a) AS f FROM t1 GROUP BY a WITH ROLLUP;
DROP TABLE t1;


--echo #
--echo # End of 10.4 tests
--echo #
6 changes: 4 additions & 2 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -3654,9 +3654,11 @@ 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; }
enum_field_types field_type() const
const Type_handler *type_handler() const
{
return result_field->type();
if (result_field)
return result_field->type_handler();
return &type_handler_null;
}
Field *create_tmp_field_ex(TABLE *table, Tmp_field_src *src,
const Tmp_field_param *param)
Expand Down

0 comments on commit ea7830e

Please sign in to comment.