[MDEV-26536] Assertion `maybe_null() || !null_value' failed in Item_func_ceiling::time_op Created: 2021-09-04  Updated: 2023-01-10  Resolved: 2023-01-04

Status: Closed
Project: MariaDB Server
Component/s: Data types, Storage Engine - MyISAM
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Sergei Petrunia
Resolution: Duplicate Votes: 0
Labels: not-10.2, not-10.3

Issue Links:
Relates
relates to MDEV-20501 Assertion `maybe_null || !null_value'... Stalled

 Description   

Similar to MDEV-20501, but no TRUNCATE involved and somewhat different stack.

CREATE TABLE t (a INT,b TIME NOT NULL DEFAULT 1) ENGINE=MyISAM;
SELECT b FROM t GROUP BY b HAVING CEILING (b)>0;

Leads to:

10.7.0 05e29e177df243b700392b797e26cae43fd3181e (Debug)

mysqld: /test/10.7_dbg/sql/item_func.cc:2397: virtual bool Item_func_ceiling::time_op(THD*, MYSQL_TIME*): Assertion `maybe_null() || !null_value' failed.

10.7.0 05e29e177df243b700392b797e26cae43fd3181e (Debug)

Core was generated by `/test/MD280821-mariadb-10.7.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x15207d7b2700 (LWP 4118031))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000152094635859 in __GI_abort () at abort.c:79
#2  0x0000152094635729 in __assert_fail_base (fmt=0x1520947cb588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e86e570662 "maybe_null() || !null_value", file=0x55e86e570ae0 "/test/10.7_dbg/sql/item_func.cc", line=2397, function=<optimized out>) at assert.c:92
#3  0x0000152094646f36 in __GI___assert_fail (assertion=assertion@entry=0x55e86e570662 "maybe_null() || !null_value", file=file@entry=0x55e86e570ae0 "/test/10.7_dbg/sql/item_func.cc", line=line@entry=2397, function=function@entry=0x55e86e5717d0 "virtual bool Item_func_ceiling::time_op(THD*, MYSQL_TIME*)") at assert.c:101
#4  0x000055e86dad1d17 in Item_func_ceiling::time_op (this=0x152030014cc0, thd=0x152030000db8, to=0x15207d7b03e0) at /test/10.7_dbg/sql/item.h:1065
#5  0x000055e86d94bd31 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=0x15207d7b03e0, fuzzydate=<optimized out>) at /test/10.7_dbg/sql/sql_type.cc:5598
#6  0x000055e86d9669e3 in Type_handler::Item_func_hybrid_field_type_get_date_with_warn (this=0x55e86ed3b400 <type_handler_time2>, thd=thd@entry=0x152030000db8, item=item@entry=0x152030014cc0, ltime=ltime@entry=0x15207d7b03e0, mode=mode@entry={m_mode = (date_mode_t::FUZZY_DATES | date_mode_t::TIME_ONLY | date_mode_t::FRAC_TRUNCATE | date_mode_t::INVALID_DATES)}) at /test/10.7_dbg/sql/sql_type.cc:5131
#7  0x000055e86daa6eff in Item_func_hybrid_field_type::get_date (this=0x152030014cc0, thd=0x152030000db8, to=0x15207d7b03e0, mode={m_mode = (date_mode_t::FUZZY_DATES | date_mode_t::TIME_ONLY | date_mode_t::FRAC_TRUNCATE | date_mode_t::INVALID_DATES)}) at /test/10.7_dbg/sql/sql_type.h:7438
#8  0x000055e86d95eed5 in Time::make_from_item (this=this@entry=0x15207d7b03e0, thd=thd@entry=0x152030000db8, warn=warn@entry=0x15207d7b03dc, item=item@entry=0x152030014cc0, opt={<Temporal::Options> = {<date_mode_t> = {m_mode = (date_mode_t::FUZZY_DATES | date_mode_t::TIME_ONLY | date_mode_t::FRAC_TRUNCATE | date_mode_t::INVALID_DATES)}, <No data fields>}, m_datetime_to_time_mode = Time::DATETIME_TO_TIME_YYYYMMDD_000000DD_MIX_TO_HOURS}) at /test/10.7_dbg/sql/sql_type.cc:758
#9  0x000055e86d600907 in Time::Time (opt=<optimized out>, item=0x152030014cc0, thd=0x152030000db8, this=0x15207d7b03e0) at /test/10.7_dbg/sql/sql_type.h:1766
#10 Item::val_time_packed (this=0x152030014cc0, thd=0x152030000db8) at /test/10.7_dbg/sql/item.h:2033
#11 0x000055e86da8be6c in Arg_comparator::compare_time (this=0x152030014ea0) at /test/10.7_dbg/sql/item_cmpfunc.cc:704
#12 0x000055e86da8a73e in Arg_comparator::compare (this=0x152030014ea0) at /test/10.7_dbg/sql/item_cmpfunc.h:103
#13 Item_func_gt::val_int (this=0x152030014df0) at /test/10.7_dbg/sql/item_cmpfunc.cc:1802
#14 0x000055e86d949e0a in Type_handler_int_result::Item_val_bool (this=<optimized out>, item=<optimized out>) at /test/10.7_dbg/sql/sql_type.cc:5092
#15 0x000055e86d5ffa36 in Item::val_bool (this=0x152030014df0) at /test/10.7_dbg/sql/item.h:1687
#16 0x000055e86d784111 in Item::eval_const_cond (this=0x152030014df0) at /test/10.7_dbg/sql/item.h:1694
#17 Item_bool_func2::remove_eq_conds (this=0x152030014df0, thd=<optimized out>, cond_value=0x152030015cd0, top_level_arg=<optimized out>) at /test/10.7_dbg/sql/sql_select.cc:17925
#18 0x000055e86d7ccf2e in make_join_statistics (join=join@entry=0x152030015988, tables_list=@0x152030013f50: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x152030015f30, last = 0x152030015f30, elements = 1}, <No data fields>}, keyuse_array=keyuse_array@entry=0x152030015ca8) at /test/10.7_dbg/sql/sql_select.cc:5628
#19 0x000055e86d7d4edb in JOIN::optimize_inner (this=this@entry=0x152030015988) at /test/10.7_dbg/sql/sql_select.cc:2453
#20 0x000055e86d7d5186 in JOIN::optimize (this=this@entry=0x152030015988) at /test/10.7_dbg/sql/sql_select.cc:1809
#21 0x000055e86d7d57ff in mysql_select (thd=thd@entry=0x152030000db8, tables=0x152030014318, fields=@0x152030013fd8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1520300142d0, last = 0x1520300142d0, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0x152030014b30, having=0x152030014df0, proc_param=0x0, select_options=2147748608, result=0x152030015960, unit=0x152030005120, select_lex=0x152030013d38) at /test/10.7_dbg/sql/sql_select.cc:4977
#22 0x000055e86d7d5b03 in handle_select (thd=thd@entry=0x152030000db8, lex=lex@entry=0x152030005058, result=result@entry=0x152030015960, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.7_dbg/sql/sql_select.cc:545
#23 0x000055e86d7377ee in execute_sqlcom_select (thd=thd@entry=0x152030000db8, all_tables=0x152030014318) at /test/10.7_dbg/sql/sql_parse.cc:6256
#24 0x000055e86d744678 in mysql_execute_command (thd=thd@entry=0x152030000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.7_dbg/sql/sql_parse.cc:3946
#25 0x000055e86d730b83 in mysql_parse (thd=thd@entry=0x152030000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15207d7b1400) at /test/10.7_dbg/sql/sql_parse.cc:8030
#26 0x000055e86d73f788 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x152030000db8, packet=packet@entry=0x15203000b739 "SELECT b FROM t GROUP BY b HAVING CEILING (b)>0", packet_length=packet_length@entry=47, blocking=blocking@entry=true) at /test/10.7_dbg/sql/sql_class.h:1358
#27 0x000055e86d742b90 in do_command (thd=0x152030000db8, blocking=blocking@entry=true) at /test/10.7_dbg/sql/sql_parse.cc:1404
#28 0x000055e86d8b8f2e in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55e8706363f8, put_in_cache=put_in_cache@entry=true) at /test/10.7_dbg/sql/sql_connect.cc:1418
#29 0x000055e86d8b9533 in handle_one_connection (arg=arg@entry=0x55e8706363f8) at /test/10.7_dbg/sql/sql_connect.cc:1312
#30 0x000055e86dd22586 in pfs_spawn_thread (arg=0x55e8705199d8) at /test/10.7_dbg/storage/perfschema/pfs.cc:2201
#31 0x0000152094b44609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#32 0x0000152094732293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.22 (dbg), 10.5.13 (dbg), 10.6.5 (dbg), 10.7.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.41 (dbg), 10.2.41 (opt), 10.3.32 (dbg), 10.3.32 (opt), 10.4.22 (opt), 10.5.13 (opt), 10.6.5 (opt), 10.7.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.35 (dbg), 5.7.35 (opt), 8.0.26 (dbg), 8.0.26 (opt)



 Comments   
Comment by Alice Sherepa [ 2021-10-19 ]

A similar test case.
setting condition_pushdown_from_having=off could be a workaround.

set optimizer_switch="condition_pushdown_from_having=on";
create table t (b time not null ) engine=myisam;
select floor(b) as f from t group by b having f=1;
 
# cleanup
drop table t;

10.4 a736a3174a4e7c0d9

Version: '10.4.22-MariaDB-debug-log' 
10.4/src/sql/item_func.cc:2404: virtual bool Item_func_floor::time_op(THD*, MYSQL_TIME*): Assertion `maybe_null || !null_value' failed.
211019 16:29:18 [ERROR] mysqld got signal 6 ;
 
Server version: 10.4.22-MariaDB-debug-log
 
:0(__GI___assert_fail)[0x7f9058e3ff36]
sql/item_func.cc:2405(Item_func_floor::time_op(THD*, st_mysql_time*))[0x55726d0fc6a9]
sql/sql_type.cc:5109(Type_handler_time_common::Item_func_hybrid_field_type_get_date(THD*, Item_func_hybrid_field_type*, Temporal::Warn*, st_mysql_time*, date_mode_t) const)[0x55726cce37f0]
sql/sql_type.cc:4643(Type_handler::Item_func_hybrid_field_type_get_date_with_warn(THD*, Item_func_hybrid_field_type*, st_mysql_time*, date_mode_t) const)[0x55726cce05ce]
sql/item_func.h:814(Item_func_hybrid_field_type::get_date(THD*, st_mysql_time*, date_mode_t))[0x55726c747534]
sql/sql_type.cc:652(Time::make_from_item(THD*, int*, Item*, Time::Options))[0x55726ccc9f6e]
sql/sql_type.h:1621(Time::Time(THD*, Item*, Time::Options))[0x55726c4c9a1b]
sql/item.h:1796(Item::val_time_packed(THD*))[0x55726c4cc8a3]
sql/item_cmpfunc.cc:711(Arg_comparator::compare_time())[0x55726d0554d3]
sql/item_cmpfunc.h:104(Arg_comparator::compare())[0x55726d09a628]
sql/item_cmpfunc.cc:1773(Item_func_eq::val_int())[0x55726d062ab7]
sql/sql_type.cc:4603(Type_handler_int_result::Item_val_bool(Item*) const)[0x55726ccdfe94]
sql/item.h:1466(Item::val_bool())[0x55726c4cbb04]
sql/item.h:1474(Item::eval_const_cond())[0x55726c90f4d6]
sql/sql_select.cc:17588(Item_bool_func2::remove_eq_conds(THD*, Item::cond_result*, bool))[0x55726c8afdc2]
sql/sql_select.cc:5386(make_join_statistics(JOIN*, List<TABLE_LIST>&, st_dynamic_array*))[0x55726c85cd77]
sql/sql_select.cc:2316(JOIN::optimize_inner())[0x55726c83d329]
sql/sql_select.cc:1659(JOIN::optimize())[0x55726c836230]
sql/sql_select.cc:4741(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55726c856f6d]
sql/sql_select.cc:436(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55726c828292]
sql/sql_parse.cc:6449(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55726c796f28]
sql/sql_parse.cc:3963(mysql_execute_command(THD*))[0x55726c7847f5]
sql/sql_parse.cc:7995(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55726c7a0415]
sql/sql_parse.cc:1860(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55726c776b90]
sql/sql_parse.cc:1373(do_command(THD*))[0x55726c77360d]
sql/sql_connect.cc:1420(do_handle_one_connection(CONNECT*))[0x55726cb6d0d9]
sql/sql_connect.cc:1317(handle_one_connection)[0x55726cb6c832]
perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55726e244679]
nptl/pthread_create.c:478(start_thread)[0x7f9059356609]
x86_64/clone.S:97(__GI___clone)[0x7f9058f2b293]
 
Query (0x62b0000a1290): select floor(b) as f from t group by b having f=1

Comment by Sergei Petrunia [ 2023-01-04 ]

Both tescases are fixed by the fix for MDEV-20501.

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