Skip to content

Commit ea7830e

Browse files
committed
MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comparison
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.
1 parent dc22acf commit ea7830e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

mysql-test/main/type_datetime_hires.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,5 +889,16 @@ Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
889889
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
890890
DROP TABLE t1;
891891
#
892+
# MDEV-20984 Possibly wrong result or Assertion `args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_DATETIME' failed in Item_func_round::date_op
893+
#
894+
CREATE TABLE t1 (a DATETIME);
895+
INSERT INTO t1 VALUES ('1979-01-03 10:33:32'),('2012-12-12 12:12:12');
896+
SELECT ROUND(a) AS f FROM t1 GROUP BY a WITH ROLLUP;
897+
f
898+
1979-01-03 10:33:32
899+
2012-12-12 12:12:12
900+
NULL
901+
DROP TABLE t1;
902+
#
892903
# End of 10.4 tests
893904
#

mysql-test/main/type_datetime_hires.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ SELECT a, ROUND(a,-6) FROM t1;
146146

147147
DROP TABLE t1;
148148

149+
--echo #
150+
--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
151+
--echo #
152+
153+
CREATE TABLE t1 (a DATETIME);
154+
INSERT INTO t1 VALUES ('1979-01-03 10:33:32'),('2012-12-12 12:12:12');
155+
SELECT ROUND(a) AS f FROM t1 GROUP BY a WITH ROLLUP;
156+
DROP TABLE t1;
157+
158+
149159
--echo #
150160
--echo # End of 10.4 tests
151161
--echo #

sql/item.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,9 +3654,11 @@ class Item_null_result :public Item_null
36543654
Field *result_field;
36553655
Item_null_result(THD *thd): Item_null(thd), result_field(0) {}
36563656
bool is_result_field() { return result_field != 0; }
3657-
enum_field_types field_type() const
3657+
const Type_handler *type_handler() const
36583658
{
3659-
return result_field->type();
3659+
if (result_field)
3660+
return result_field->type_handler();
3661+
return &type_handler_null;
36603662
}
36613663
Field *create_tmp_field_ex(TABLE *table, Tmp_field_src *src,
36623664
const Tmp_field_param *param)

0 commit comments

Comments
 (0)