[MDEV-14221] Assertion `0' failed in Item::field_type_for_temporal_comparison Created: 2017-10-30  Updated: 2020-05-22  Resolved: 2017-11-02

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.1, 10.2
Fix Version/s: 10.1.29, 10.2.11, 10.3.3

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-16190 Server crashes in Item_null_result::f... Closed
Sprint: 10.1.29

 Description   

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

10.1 38e12db478fdea10531

mysqld: /data/src/10.1/sql/item.h:1261: enum_field_types Item::field_type_for_temporal_comparison(const Item*) const: Assertion `0' failed.
171030 16:46:53 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f6ecd8d2ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x0000561e4af22d28 in Item::field_type_for_temporal_comparison (this=0x7f6ec4de0c40, other=0x7f6ec4de0c40) at /data/src/10.1/sql/item.h:1261
#9  0x0000561e4af34b29 in cmp_item_datetime::store_value (this=0x7f6ec4de19d0, item=0x7f6ec4de0c40) at /data/src/10.1/sql/item_cmpfunc.cc:4036
#10 0x0000561e4af3171f in Item_func_case::find_item (this=0x7f6ec4de0f30, str=0x7f6ecf954d30) at /data/src/10.1/sql/item_cmpfunc.cc:2989
#11 0x0000561e4af319ba in Item_func_case::int_op (this=0x7f6ec4de0f30) at /data/src/10.1/sql/item_cmpfunc.cc:3026
#12 0x0000561e4af5b552 in Item_func_hybrid_field_type::val_int (this=0x7f6ec4de0f30) at /data/src/10.1/sql/item_func.cc:936
#13 0x0000561e4ad2fed6 in JOIN::rollup_send_data (this=0x7f6ec4de11a8, idx=0) at /data/src/10.1/sql/sql_select.cc:23938
#14 0x0000561e4ad25ae5 in end_send_group (join=0x7f6ec4de11a8, join_tab=0x7f6ec4de27e0, end_of_records=true) at /data/src/10.1/sql/sql_select.cc:19703
#15 0x0000561e4ad2275d in sub_select (join=0x7f6ec4de11a8, join_tab=0x7f6ec4de2498, end_of_records=true) at /data/src/10.1/sql/sql_select.cc:18365
#16 0x0000561e4ad22235 in do_select (join=0x7f6ec4de11a8, fields=0x7f6ec4de15a8, table=0x0, procedure=0x0) at /data/src/10.1/sql/sql_select.cc:18071
#17 0x0000561e4acfcba0 in JOIN::exec_inner (this=0x7f6ec4de11a8) at /data/src/10.1/sql/sql_select.cc:3225
#18 0x0000561e4acf9e31 in JOIN::exec (this=0x7f6ec4de11a8) at /data/src/10.1/sql/sql_select.cc:2512
#19 0x0000561e4acfd3c7 in mysql_select (thd=0x7f6ec68d5070, rref_pointer_array=0x7f6ec68d9518, tables=0x7f6ec4de04e8, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f6ec4de0be8, having=0x7f6ec4de0f30, proc_param=0x0, select_options=2147748608, result=0x7f6ec4de1188, unit=0x7f6ec68d8b70, select_lex=0x7f6ec68d9270) at /data/src/10.1/sql/sql_select.cc:3449
#20 0x0000561e4acf2dd0 in handle_select (thd=0x7f6ec68d5070, lex=0x7f6ec68d8aa8, result=0x7f6ec4de1188, setup_tables_done_option=0) at /data/src/10.1/sql/sql_select.cc:384
#21 0x0000561e4acc2ccf in execute_sqlcom_select (thd=0x7f6ec68d5070, all_tables=0x7f6ec4de04e8) at /data/src/10.1/sql/sql_parse.cc:5905
#22 0x0000561e4acb8ef6 in mysql_execute_command (thd=0x7f6ec68d5070) at /data/src/10.1/sql/sql_parse.cc:2975
#23 0x0000561e4acc63dd in mysql_parse (thd=0x7f6ec68d5070, rawbuf=0x7f6ec4de0088 "SELECT d, COUNT(*) FROM t GROUP BY d WITH ROLLUP HAVING CASE d WHEN '2017-05-25' THEN 0 ELSE 1 END", length=98, parser_state=0x7f6ecf9565e0) at /data/src/10.1/sql/sql_parse.cc:7326
#24 0x0000561e4acb4ff2 in dispatch_command (command=COM_QUERY, thd=0x7f6ec68d5070, packet=0x7f6ec93f9071 "", packet_length=98) at /data/src/10.1/sql/sql_parse.cc:1477
#25 0x0000561e4acb3d77 in do_command (thd=0x7f6ec68d5070) at /data/src/10.1/sql/sql_parse.cc:1106
#26 0x0000561e4adec9ed in do_handle_one_connection (thd_arg=0x7f6ec68d5070) at /data/src/10.1/sql/sql_connect.cc:1349
#27 0x0000561e4adec751 in handle_one_connection (arg=0x7f6ec68d5070) at /data/src/10.1/sql/sql_connect.cc:1261
#28 0x0000561e4b1a5aea in pfs_spawn_thread (arg=0x7f6ecd039ef0) at /data/src/10.1/storage/perfschema/pfs.cc:1861
#29 0x00007f6ecf5d6494 in start_thread (arg=0x7f6ecf957b00) at pthread_create.c:333
#30 0x00007f6ecd98f93f in clone () from /lib/x86_64-linux-gnu/libc.so.6



 Comments   
Comment by Alexander Barkov [ 2017-10-30 ]

Not repeatable in 10.3.

Comment by Alexander Barkov [ 2018-06-08 ]

If I insert one more value (two values total), it does not crash and returns a correct result set:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (t TIME) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('12:12:12'),('12:12:13');
SELECT t, COUNT(*) FROM t1 GROUP BY t WITH ROLLUP HAVING t > '00:00:00';

+----------+----------+
| t        | COUNT(*) |
+----------+----------+
| 12:12:12 |        1 |
| 12:12:13 |        1 |
+----------+----------+

Generated at Thu Feb 08 08:11:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.