[MDEV-29924] Assertion `(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0' failed in my_time_packed_to_binary on SELECT when using TIME field Created: 2022-11-01  Updated: 2022-11-02  Resolved: 2022-11-02

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4.27, 10.5.18, 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2

Type: Bug Priority: Blocker
Reporter: Roel Van de Paar Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Problem/Incident
is caused by MDEV-27101 Subquery using the ALL keyword on TIM... Closed

 Description   

Recent regression. I am running git bisect to find exact commit. Happens on at least InnoDB and MyISAM.

CREATE TABLE t (c INT,d TIME(6));
INSERT INTO t VALUES (NULL,0.1),(NULL,0.1);
SELECT c FROM t WHERE c>ALL (SELECT d FROM t);

Leads to:

10.11.1 50c5743adc87e1cdec1431a02558f6540fe5a6d5 (Debug)

mysqld: /test/10.11_dbg/sql/compat56.cc:126: void my_time_packed_to_binary(longlong, uchar*, uint): Assertion `(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0' failed.

10.11.1 50c5743adc87e1cdec1431a02558f6540fe5a6d5 (Debug)

Core was generated by `/test/MD221022-mariadb-10.11.1-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 0x1476001f9700 (LWP 1787359))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014762577b859 in __GI_abort () at abort.c:79
#2  0x000014762577b729 in __assert_fail_base (fmt=0x147625911588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55f53eb3bf18 "(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0", file=0x55f53eb3bdf8 "/test/10.11_dbg/sql/compat56.cc", line=126, function=<optimized out>) at assert.c:92
#3  0x000014762578cfd6 in __GI___assert_fail (assertion=assertion@entry=0x55f53eb3bf18 "(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0", file=file@entry=0x55f53eb3bdf8 "/test/10.11_dbg/sql/compat56.cc", line=line@entry=126, function=function@entry=0x55f53eb3be80 "void my_time_packed_to_binary(longlong, uchar*, uint)") at assert.c:101
#4  0x000055f53e0b7270 in my_time_packed_to_binary (nr=100000, ptr=0x1476001f6846 "", dec=dec@entry=0) at /test/10.11_dbg/sql/compat56.cc:126
#5  0x000055f53e018e5c in Time::to_native (this=this@entry=0x1476001f67d0, to=to@entry=0x1476001f6830, decimals=0) at /test/10.11_dbg/sql/sql_string.h:282
#6  0x000055f53e12f922 in Item_cache_time::val_native (this=0x14757806edf8, thd=0x147578000d48, to=0x1476001f6830) at /test/10.11_dbg/sql/sql_type.h:1767
#7  0x000055f53dda26d5 in select_max_min_finder_subselect::cmp_native (this=0x14757806c290) at /test/10.11_dbg/sql/sql_class.cc:3821
#8  0x000055f53ddab521 in select_max_min_finder_subselect::send_data (this=0x14757806c290, items=<optimized out>) at /test/10.11_dbg/sql/sql_class.cc:3714
#9  0x000055f53de847ec in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x1475780143b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1475780146a8, last = 0x1475780146a8, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.11_dbg/sql/sql_class.h:5703
#10 end_send (join=0x1475780169b0, join_tab=0x14757806d528, end_of_records=<optimized out>) at /test/10.11_dbg/sql/sql_select.cc:23000
#11 0x000055f53de569b4 in evaluate_join_record (join=join@entry=0x1475780169b0, join_tab=join_tab@entry=0x14757806d170, error=error@entry=0) at /test/10.11_dbg/sql/sql_select.cc:21994
#12 0x000055f53de6a454 in sub_select (join=0x1475780169b0, join_tab=0x14757806d170, end_of_records=false) at /test/10.11_dbg/sql/sql_select.cc:21803
#13 0x000055f53de9f1b5 in do_select (procedure=<optimized out>, join=0x1475780169b0) at /test/10.11_dbg/sql/sql_select.cc:21309
#14 JOIN::exec_inner (this=this@entry=0x1475780169b0) at /test/10.11_dbg/sql/sql_select.cc:4813
#15 0x000055f53de9f69e in JOIN::exec (this=0x1475780169b0) at /test/10.11_dbg/sql/sql_select.cc:4591
#16 0x000055f53e20095a in subselect_single_select_engine::exec (this=0x147578015888) at /test/10.11_dbg/sql/item_subselect.cc:4101
#17 0x000055f53e1fffa8 in Item_subselect::exec (this=0x14757806c130) at /test/10.11_dbg/sql/item_subselect.cc:811
#18 0x000055f53e1fec42 in Item_singlerow_subselect::get_date (this=0x14757806c130, thd=0x147578000d48, ltime=0x1476001f7110, fuzzydate={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.11_dbg/sql/item_subselect.cc:1570
#19 0x000055f53e018e9b in Time::make_from_item (this=this@entry=0x1476001f7110, thd=thd@entry=0x147578000d48, warn=warn@entry=0x1476001f710c, item=item@entry=0x14757806c130, 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.11_dbg/sql/sql_type.cc:758
#20 0x000055f53dcf33ab in Time::Time (opt=<optimized out>, item=0x14757806c130, thd=0x147578000d48, this=0x1476001f7110) at /test/10.11_dbg/sql/sql_type.h:1767
#21 Item::val_time_packed (this=0x14757806c130, thd=0x147578000d48) at /test/10.11_dbg/sql/item.h:2048
#22 0x000055f53e13c0de in Arg_comparator::compare_time (this=0x14757806c390) at /test/10.11_dbg/sql/item_cmpfunc.cc:715
#23 0x000055f53e13add4 in Arg_comparator::compare (this=0x14757806c390) at /test/10.11_dbg/sql/item_cmpfunc.h:103
#24 Item_func_ge::val_int (this=0x14757806c2e0) at /test/10.11_dbg/sql/item_cmpfunc.cc:1807
#25 0x000055f53e14862b in Item_in_optimizer::val_int (this=0x147578017030) at /test/10.11_dbg/sql/item_cmpfunc.cc:1568
#26 0x000055f53e003e80 in Type_handler_int_result::Item_val_bool (this=<optimized out>, item=<optimized out>) at /test/10.11_dbg/sql/sql_type.cc:5091
#27 0x000055f53dcf24ce in Item::val_bool (this=0x147578017030) at /test/10.11_dbg/sql/item.h:1692
#28 0x000055f53e146410 in Item_func_not_all::val_int (this=0x1475780158c8) at /test/10.11_dbg/sql/item_cmpfunc.cc:221
#29 0x000055f53de56751 in evaluate_join_record (join=join@entry=0x1475780162b8, join_tab=join_tab@entry=0x14757806b248, error=error@entry=0) at /test/10.11_dbg/sql/sql_select.cc:21862
#30 0x000055f53de6a347 in sub_select (join=0x1475780162b8, join_tab=0x14757806b248, end_of_records=false) at /test/10.11_dbg/sql/sql_select.cc:21764
#31 0x000055f53de9f1b5 in do_select (procedure=<optimized out>, join=0x1475780162b8) at /test/10.11_dbg/sql/sql_select.cc:21309
#32 JOIN::exec_inner (this=this@entry=0x1475780162b8) at /test/10.11_dbg/sql/sql_select.cc:4813
#33 0x000055f53de9f69e in JOIN::exec (this=this@entry=0x1475780162b8) at /test/10.11_dbg/sql/sql_select.cc:4591
#34 0x000055f53de9d652 in mysql_select (thd=thd@entry=0x147578000d48, tables=0x1475780138c8, fields=@0x147578013588: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x147578013880, last = 0x147578013880, elements = 1}, <No data fields>}, conds=0x1475780158c8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x147578016290, unit=0x147578004f88, select_lex=0x1475780132e8) at /test/10.11_dbg/sql/sql_select.cc:5071
#35 0x000055f53de9ddc5 in handle_select (thd=thd@entry=0x147578000d48, lex=lex@entry=0x147578004eb0, result=result@entry=0x147578016290, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.11_dbg/sql/sql_select.cc:582
#36 0x000055f53de0bad5 in execute_sqlcom_select (thd=thd@entry=0x147578000d48, all_tables=0x1475780138c8) at /test/10.11_dbg/sql/sql_parse.cc:6261
#37 0x000055f53de17bd2 in mysql_execute_command (thd=thd@entry=0x147578000d48, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:3945
#38 0x000055f53de05f90 in mysql_parse (thd=thd@entry=0x147578000d48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1476001f8300) at /test/10.11_dbg/sql/sql_parse.cc:8023
#39 0x000055f53de134ac in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x147578000d48, packet=packet@entry=0x14757800af09 "", packet_length=packet_length@entry=45, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:1346
#40 0x000055f53de158f4 in do_command (thd=0x147578000d48, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
#41 0x000055f53df72067 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55f541f04f38, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1416
#42 0x000055f53df72536 in handle_one_connection (arg=0x55f541f04f38) at /test/10.11_dbg/sql/sql_connect.cc:1318
#43 0x0000147625c8c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#44 0x0000147625878133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.27 (dbg), 10.5.18 (dbg), 10.6.10 (dbg), 10.7.6 (dbg), 10.8.5 (dbg), 10.9.3 (dbg), 10.10.2 (dbg), 10.11.1 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.37 (dbg), 10.3.37 (opt), 10.4.27 (opt), 10.5.18 (opt), 10.6.10 (opt), 10.7.6 (opt), 10.8.5 (opt), 10.9.3 (opt), 10.10.2 (opt), 10.11.1 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)


Generated at Thu Feb 08 10:12:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.