[MDEV-20816] Assertions `maybe_null || !null_value' and `args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_TIME' fail in Item_func_round::time_op Created: 2019-10-12  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-20501 Assertion `maybe_null || !null_value'... Stalled
relates to MDEV-20815 ONLY_FULL_GROUP_BY is ignored with de... Open
relates to MDEV-21797 Assertion `maybe_null || !null_value... Confirmed
relates to MDEV-23928 Assertion `maybe_null || !null_value'... Confirmed

 Description   

Note: Possibly it's just an ugly side-effect of MDEV-20815, as I couldn't reproduce it with a "good" aggregate query, or without views.

CREATE TABLE t1 (a TIME NOT NULL);
CREATE VIEW v1 AS SELECT * FROM t1;
 
SET SQL_MODE= 'ONLY_FULL_GROUP_BY';
SELECT ROUND(a), COUNT(*) FROM v1;
 
# Cleanup
DROP VIEW v1;
DROP TABLE t1;

10.4 36824d2b

mysqld: /data/src/10.4/sql/item_func.cc:2551: virtual bool Item_func_round::time_op(THD*, MYSQL_TIME*): Assertion `maybe_null || !null_value' failed.
191012 18:33:35 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f72ae4baf12 in __GI___assert_fail (assertion=0x55fa7f51a5e0 "maybe_null || !null_value", file=0x55fa7f51a248 "/data/src/10.4/sql/item_func.cc", line=2551, function=0x55fa7f51c040 <Item_func_round::time_op(THD*, st_mysql_time*)::__PRETTY_FUNCTION__> "virtual bool Item_func_round::time_op(THD*, MYSQL_TIME*)") at assert.c:101
#8  0x000055fa7ea7498c in Item_func_round::time_op (this=0x7f7298013810, thd=0x7f7298000b00, to=0x7f72a868a9e8) at /data/src/10.4/sql/item_func.cc:2551
#9  0x000055fa7e8a5ab5 in Type_handler_time_common::Item_func_hybrid_field_type_get_date (this=0x55fa7fe1dc10 <type_handler_time2>, thd=0x7f7298000b00, item=0x7f7298013810, warn=0x7f72a868a610, ltime=0x7f72a868a9e8, fuzzydate=...) at /data/src/10.4/sql/sql_type.cc:4875
#10 0x000055fa7e8a4814 in Type_handler::Item_func_hybrid_field_type_get_date_with_warn (this=0x55fa7fe1dc10 <type_handler_time2>, thd=0x7f7298000b00, item=0x7f7298013810, ltime=0x7f72a868a9e8, mode=...) at /data/src/10.4/sql/sql_type.cc:4408
#11 0x000055fa7e66ba34 in Item_func_hybrid_field_type::get_date (this=0x7f7298013810, thd=0x7f7298000b00, to=0x7f72a868a9e8, mode=...) at /data/src/10.4/sql/item_func.h:777
#12 0x000055fa7e8ba5b0 in Item::get_time (this=0x7f7298013810, thd=0x7f7298000b00, ltime=0x7f72a868a9e8) at /data/src/10.4/sql/item.h:1752
#13 0x000055fa7e8aa49f in Type_handler::Item_send_time (this=0x55fa7fe1dc10 <type_handler_time2>, item=0x7f7298013810, protocol=0x7f72980010c8, buf=0x7f72a868a9e0) at /data/src/10.4/sql/sql_type.cc:6822
#14 0x000055fa7e8b73da in Type_handler_time_common::Item_send (this=0x55fa7fe1dc10 <type_handler_time2>, item=0x7f7298013810, protocol=0x7f72980010c8, buf=0x7f72a868a9e0) at /data/src/10.4/sql/sql_type.h:5250
#15 0x000055fa7e56523a in Item::send (this=0x7f7298013810, protocol=0x7f72980010c8, buffer=0x7f72a868a9e0) at /data/src/10.4/sql/item.h:1034
#16 0x000055fa7e55f385 in Protocol::send_result_set_row (this=0x7f72980010c8, row_items=0x7f7298013318) at /data/src/10.4/sql/protocol.cc:1035
#17 0x000055fa7e613fa4 in select_send::send_data (this=0x7f7298018220, items=...) at /data/src/10.4/sql/sql_class.cc:3002
#18 0x000055fa7e6f69cf in return_zero_rows (join=0x7f7298018248, result=0x7f7298018220, tables=..., fields=..., send_row=true, select_options=2147748608, info=0x55fa7f388b28 "no matching row in const table", having=0x0, all_fields=...) at /data/src/10.4/sql/sql_select.cc:14196
#19 0x000055fa7e6dabed in JOIN::exec_inner (this=0x7f7298018248) at /data/src/10.4/sql/sql_select.cc:4314
#20 0x000055fa7e6da13e in JOIN::exec (this=0x7f7298018248) at /data/src/10.4/sql/sql_select.cc:4168
#21 0x000055fa7e6db853 in mysql_select (thd=0x7f7298000b00, tables=0x7f7298013b40, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f7298018220, unit=0x7f7298004a30, select_lex=0x7f72980131d0) at /data/src/10.4/sql/sql_select.cc:4600
#22 0x000055fa7e6cb7c4 in handle_select (thd=0x7f7298000b00, lex=0x7f7298004968, result=0x7f7298018220, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:420
#23 0x000055fa7e692193 in execute_sqlcom_select (thd=0x7f7298000b00, all_tables=0x7f7298013b40) at /data/src/10.4/sql/sql_parse.cc:6352
#24 0x000055fa7e68787a in mysql_execute_command (thd=0x7f7298000b00) at /data/src/10.4/sql/sql_parse.cc:3894
#25 0x000055fa7e6962b1 in mysql_parse (thd=0x7f7298000b00, rawbuf=0x7f7298013128 "SELECT ROUND(a), COUNT(*) FROM v1", length=33, parser_state=0x7f72a868c170, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7912
#26 0x000055fa7e681544 in dispatch_command (command=COM_QUERY, thd=0x7f7298000b00, packet=0x7f7298008331 "", packet_length=33, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1841
#27 0x000055fa7e67fbd1 in do_command (thd=0x7f7298000b00) at /data/src/10.4/sql/sql_parse.cc:1359
#28 0x000055fa7e807603 in do_handle_one_connection (connect=0x55fa81bbfaf0) at /data/src/10.4/sql/sql_connect.cc:1412
#29 0x000055fa7e807352 in handle_one_connection (arg=0x55fa81bbfaf0) at /data/src/10.4/sql/sql_connect.cc:1316
#30 0x000055fa7f2088bb in pfs_spawn_thread (arg=0x55fa81bdb680) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#31 0x00007f72b00304a4 in start_thread (arg=0x7f72a868d700) at pthread_create.c:456
#32 0x00007f72ae577d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Also reproducible on 10.5.
Couldn't reproduce with 10.3, but maybe it's because of different defaults.
No obvious effect on a non-debug build.



 Comments   
Comment by Sergei Petrunia [ 2023-01-04 ]

The fix for MDEV-20501 doesn't fix this.

Comment by Roel Van de Paar [ 2023-04-07 ]

Version update

Bug confirmed present in:
MariaDB: 10.4.29 (dbg), 10.5.20 (dbg), 10.6.13 (dbg), 10.7.8 (dbg), 10.8.8 (dbg), 10.9.6 (dbg), 10.10.4 (dbg), 10.11.3 (dbg), 11.0.2 (dbg), 11.1.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.4.29 (opt), 10.5.20 (opt), 10.6.13 (opt), 10.7.8 (opt), 10.8.8 (opt), 10.9.6 (opt), 10.10.4 (opt), 10.11.3 (opt), 11.0.2 (opt), 11.1.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 5.7.40 (opt), 8.0.31 (dbg), 8.0.31 (opt)

Comment by Roel Van de Paar [ 2023-04-07 ]

Additional testcase which leads to an additional assert with very similar stack (and testcase uses GROUP BY). MEMORY, MyISAM and Aria are affected, InnoDB is not.

CREATE TABLE t (a TIME(6)) ENGINE=MEMORY;
INSERT INTO t VALUES (1);
SELECT ROUND (a) AS f FROM t GROUP BY a WITH ROLLUP;

Leads to:

11.1.0 2b61ff8f2221745f0a96855a0feb0825c426f993 (Debug)

mariadbd: /test/11.1_dbg/sql/item_func.cc:2764: virtual bool Item_func_round::time_op(THD*, MYSQL_TIME*): Assertion `args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_TIME' failed.

11.1.0 2b61ff8f2221745f0a96855a0feb0825c426f993 (Debug)

Core was generated by `/test/MD070423-mariadb-11.1.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=23261997311552)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x15281b162640 (LWP 4078354))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=23261997311552) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=23261997311552) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=23261997311552, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000015285c909476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x000015285c8ef7f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000015285c8ef71b in __assert_fail_base (fmt=0x15285caa4150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55d13371cb40 "args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_TIME", file=0x55d13371bec8 "/test/11.1_dbg/sql/item_func.cc", line=2764, function=<optimized out>) at ./assert/assert.c:92
#6  0x000015285c900e96 in __GI___assert_fail (assertion=0x55d13371cb40 "args[0]->type_handler()->mysql_timestamp_type() == MYSQL_TIMESTAMP_TIME", file=0x55d13371bec8 "/test/11.1_dbg/sql/item_func.cc", line=2764, function=0x55d13371cb88 "virtual bool Item_func_round::time_op(THD*, MYSQL_TIME*)") at ./assert/assert.c:101
#7  0x000055d132dc83cd in Item_func_round::time_op (this=0x1527ec0138d8, thd=0x1527ec000d58, to=0x15281b15fec8) at /test/11.1_dbg/sql/item_func.cc:2764
#8  0x000055d132c5d6b5 in Type_handler_time_common::Item_func_hybrid_field_type_get_date (this=<optimized out>, thd=<optimized out>, item=<optimized out>, warn=<optimized out>, ltime=0x15281b15fec8, fuzzydate=<optimized out>) at /test/11.1_dbg/sql/sql_type.cc:5589
#9  0x000055d132c762cb in Type_handler::Item_func_hybrid_field_type_get_date_with_warn (this=0x55d133f73cf0 <type_handler_time2>, thd=thd@entry=0x1527ec000d58, item=item@entry=0x1527ec0138d8, ltime=ltime@entry=0x15281b15fec8, mode=mode@entry={m_mode = (date_mode_t::TIME_ONLY | date_mode_t::FRAC_TRUNCATE | date_mode_t::INVALID_DATES)}) at /test/11.1_dbg/sql/sql_type.cc:5122
#10 0x000055d132d99455 in Item_func_hybrid_field_type::get_date (this=this@entry=0x1527ec0138d8, thd=thd@entry=0x1527ec000d58, to=to@entry=0x15281b15fec8, mode={m_mode = (date_mode_t::TIME_ONLY | date_mode_t::FRAC_TRUNCATE | date_mode_t::INVALID_DATES)}) at /test/11.1_dbg/sql/sql_type.h:7441
#11 0x000055d132c779af in Item::get_time (ltime=0x15281b15fec8, thd=0x1527ec000d58, this=0x1527ec0138d8) at /test/11.1_dbg/sql/sql_type.h:1583
#12 Type_handler::Item_send_time (this=<optimized out>, item=0x1527ec0138d8, protocol=0x1527ec001368, buf=0x15281b15fec0) at /test/11.1_dbg/sql/sql_type.cc:7552
#13 0x000055d132bb74d1 in Type_handler_time_common::Item_send (this=<optimized out>, item=<optimized out>, protocol=<optimized out>, buf=<optimized out>) at /test/11.1_dbg/sql/sql_type.h:6148
#14 0x000055d1329545e8 in Item::send (this=0x1527ec0138d8, protocol=0x1527ec001368, buffer=0x15281b15fec0) at /test/11.1_dbg/sql/item.h:1235
#15 0x000055d13298a1dd in Protocol::send_result_set_row (this=this@entry=0x1527ec001368, row_items=row_items@entry=0x1527ec015570) at /test/11.1_dbg/sql/protocol.cc:1332
#16 0x000055d132a0ca7d in select_send::send_data (this=0x1527ec014bc0, items=@0x1527ec015570: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1527ec015608, last = 0x1527ec015608, elements = 1}, <No data fields>}) at /test/11.1_dbg/sql/sql_class.cc:3102
#17 0x000055d132ae8e9f in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=<optimized out>, this=<optimized out>) at /test/11.1_dbg/sql/sql_class.h:5748
#18 JOIN::rollup_send_data (this=this@entry=0x1527ec014be8, idx=idx@entry=0) at /test/11.1_dbg/sql/sql_select.cc:28797
#19 0x000055d132ae98be in end_send_group (join=0x1527ec014be8, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/11.1_dbg/sql/sql_select.cc:24476
#20 0x000055d132afd211 in do_select (procedure=0x0, join=0x1527ec014be8) at /test/11.1_dbg/sql/sql_select.cc:22499
#21 JOIN::exec_inner (this=this@entry=0x1527ec014be8) at /test/11.1_dbg/sql/sql_select.cc:4897
#22 0x000055d132afd9c0 in JOIN::exec (this=this@entry=0x1527ec014be8) at /test/11.1_dbg/sql/sql_select.cc:4674
#23 0x000055d132afb898 in mysql_select (thd=thd@entry=0x1527ec000d58, tables=<optimized out>, fields=@0x1527ec013508: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1527ec0139a0, last = 0x1527ec0139a0, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0x1527ec014250, having=0x0, proc_param=0x0, select_options=2164525824, result=0x1527ec014bc0, unit=0x1527ec004fa0, select_lex=0x1527ec013248) at /test/11.1_dbg/sql/sql_select.cc:5155
#24 0x000055d132afc01e in handle_select (thd=thd@entry=0x1527ec000d58, lex=lex@entry=0x1527ec004ec8, result=result@entry=0x1527ec014bc0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/11.1_dbg/sql/sql_select.cc:611
#25 0x000055d132a62314 in execute_sqlcom_select (thd=thd@entry=0x1527ec000d58, all_tables=0x1527ec0139f0) at /test/11.1_dbg/sql/sql_parse.cc:6024
#26 0x000055d132a6d974 in mysql_execute_command (thd=thd@entry=0x1527ec000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.1_dbg/sql/sql_parse.cc:3944
#27 0x000055d132a73f05 in mysql_parse (thd=thd@entry=0x1527ec000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15281b161230) at /test/11.1_dbg/sql/sql_parse.cc:7760
#28 0x000055d132a76099 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1527ec000d58, packet=packet@entry=0x1527ec00ae49 "", packet_length=packet_length@entry=51, blocking=blocking@entry=true) at /test/11.1_dbg/sql/sql_class.h:242
#29 0x000055d132a77ef5 in do_command (thd=0x1527ec000d58, blocking=blocking@entry=true) at /test/11.1_dbg/sql/sql_parse.cc:1405
#30 0x000055d132bc9cfc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55d13568e6d8, put_in_cache=put_in_cache@entry=true) at /test/11.1_dbg/sql/sql_connect.cc:1416
#31 0x000055d132bc9f5b in handle_one_connection (arg=0x55d13568e6d8) at /test/11.1_dbg/sql/sql_connect.cc:1318
#32 0x000015285c95bb43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#33 0x000015285c9eda00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.4.29 (dbg), 10.5.20 (dbg), 10.6.13 (dbg), 10.7.8 (dbg), 10.8.8 (dbg), 10.9.6 (dbg), 10.10.4 (dbg), 10.11.3 (dbg), 11.0.2 (dbg), 11.1.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.4.29 (opt), 10.5.20 (opt), 10.6.13 (opt), 10.7.8 (opt), 10.8.8 (opt), 10.9.6 (opt), 10.10.4 (opt), 10.11.3 (opt), 11.0.2 (opt), 11.1.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 5.7.40 (opt), 8.0.31 (dbg), 8.0.31 (opt)

Generated at Thu Feb 08 09:02:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.