Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-29149

Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed

    XMLWordPrintable

Details

    Description

      It looks similar to MDEV-19301 which was fixed long time ago (and remains fixed). On the other hand, MDEV-21637 which once caused the same assertion was likely something different, specific to DEFAULT.

      SELECT IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE));
      

      Note incorrect time value in the 2nd argument of TIMEDIFF.

      10.4 8911823f

      mysqld: /data/src/10.4/sql/sql_type.cc:1076: Datetime_truncation_not_needed::Datetime_truncation_not_needed(THD*, Item*, date_conv_mode_t): Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed.
      220721 22:14:31 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f1453db3662 in __GI___assert_fail (assertion=0x55699be01098 "!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0", file=0x55699be00798 "/data/src/10.4/sql/sql_type.cc", line=1076, function=0x55699be01038 "Datetime_truncation_not_needed::Datetime_truncation_not_needed(THD*, Item*, date_conv_mode_t)") at assert.c:101
      No locals.
      #8  0x000055699b2c4927 in Datetime_truncation_not_needed::Datetime_truncation_not_needed (this=0x7f144dd83b50, thd=0x7f143c000d90, item=0x7f143c015110, mode={m_mode = date_conv_mode_t::CONV_NONE}) at /data/src/10.4/sql/sql_type.cc:1076
              __PRETTY_FUNCTION__ = {<optimized out> <repeats 94 times>}
      #9  0x000055699b349821 in Datetime_truncation_not_needed::Datetime_truncation_not_needed (this=0x7f144dd83b50, thd=0x7f143c000d90, item=0x7f143c015110, mode={m_mode = date_mode_t::FRAC_TRUNCATE}) at /data/src/10.4/sql/sql_type.h:2532
      No locals.
      #10 0x000055699b34d4a5 in Item_func_case_abbreviation2_switch::date_op (this=0x7f143c015348, thd=0x7f143c000d90, ltime=0x7f144dd83fc8, fuzzydate={m_mode = date_mode_t::FRAC_TRUNCATE}) at /data/src/10.4/sql/item_cmpfunc.h:1139
              dt = {<Datetime> = {<Temporal_with_date> = {<Temporal> = {<st_mysql_time> = {year = 2022, month = 6, day = 17, hour = 15, minute = 59, second = 59, second_part = 1, neg = 0 '\000', time_type = MYSQL_TIMESTAMP_DATETIME}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}
      #11 0x000055699b2ce55d in Type_handler_temporal_result::Item_func_hybrid_field_type_get_date (this=0x55699c654dd0 <type_handler_datetime>, thd=0x7f143c000d90, item=0x7f143c015348, warn=0x7f144dd83c10, ltime=0x7f144dd83fc8, fuzzydate={m_mode = date_mode_t::FRAC_TRUNCATE}) at /data/src/10.4/sql/sql_type.cc:5057
      No locals.
      #12 0x000055699b2cd3ca in Type_handler::Item_func_hybrid_field_type_get_date_with_warn (this=0x55699c654dd0 <type_handler_datetime>, thd=0x7f143c000d90, item=0x7f143c015348, ltime=0x7f144dd83fc8, mode={m_mode = date_mode_t::FRAC_TRUNCATE}) at /data/src/10.4/sql/sql_type.cc:4641
              s = 0x0
              warn = {<Temporal::Warn> = {<ErrBuff> = {err_buffer = "\000\000\000\000\001\000\000\000\060P\001<\024\177\000\000\220\r\000<\024\177\000\000\020Ne\234iU\000\000P<\330M\024\177\000\000\220\362\311\233iU\000\000`P\001<\024\177\000\000\274\363\311\233$\000\000\000\002\000\000\000\002", '\000' <repeats 23 times>, "F\003\000\000;\000\000\000;\000\000\000?B\017\000\000\000\000\000\000\247\nR\002\000\000\000\220\362\311\233iU\000\000\260<\330M\024\177\000\000\274\363\311\233iU\000\000\370\247\nR\024\177\000\000`\v\000<\024\177\000\000\320<\330M\024\177\000\000\220\362\311\233\000\000\000\000@\250g\234iU", '\000' <repeats 24 times>...}, <Temporal::Status> = {<st_mysql_time_status> = {warnings = 0, precision = 0, nanoseconds = 0}, <No data fields>}, <No data fields>}, m_thd = 0x7f143c000d90, m_db_name = 0x0, m_table_name = 0x0, m_name = 0x0, m_ltime = 0x7f144dd83fc8, m_mode = {m_mode = date_mode_t::FRAC_TRUNCATE}}
      #13 0x000055699b088bee in Item_func_hybrid_field_type::get_date (this=0x7f143c015348, thd=0x7f143c000d90, to=0x7f144dd83fc8, mode={m_mode = date_mode_t::FRAC_TRUNCATE}) at /data/src/10.4/sql/item_func.h:814
              __PRETTY_FUNCTION__ = "virtual bool Item_func_hybrid_field_type::get_date(THD*, MYSQL_TIME*, date_mode_t)"
      #14 0x000055699b2d3343 in Type_handler::Item_send_datetime (this=0x55699c654dd0 <type_handler_datetime>, item=0x7f143c015348, protocol=0x7f143c001388, buf=0x7f144dd83fc0) at /data/src/10.4/sql/sql_type.cc:7152
      No locals.
      #15 0x000055699b2e0c0a in Type_handler_datetime_common::Item_send (this=0x55699c654dd0 <type_handler_datetime>, item=0x7f143c015348, protocol=0x7f143c001388, buf=0x7f144dd83fc0) at /data/src/10.4/sql/sql_type.h:5802
      No locals.
      #16 0x000055699af7e678 in Item::send (this=0x7f143c015348, protocol=0x7f143c001388, buffer=0x7f144dd83fc0) at /data/src/10.4/sql/item.h:1042
      No locals.
      #17 0x000055699af78745 in Protocol::send_result_set_row (this=0x7f143c001388, row_items=0x7f143c014b38) at /data/src/10.4/sql/protocol.cc:1038
              value_buffer = {<Value> = {<st_value> = {m_type = 2614520182, value = {m_longlong = 0, m_double = 0, m_time = {year = 0, month = 0, day = 1306017776, hour = 32532, minute = 2613703612, second = 65536, second_part = 139725182091280, neg = 7 '\a', time_type = 21865}}, m_string = {<Charset> = {m_charset = 0x55699c67a840 <my_charset_bin>}, <Binary_string> = {<Static_binary_string> = {<Sql_alloc> = {<No data fields>}, Ptr = 0x7f144dd84058 "\260\f", str_length = 766}, Alloced_length = 766, extra_alloc = 0, alloced = false, thread_specific = false}, <No data fields>}, m_decimal = {<st_decimal_t> = {intg = -1680447272, frac = 21865, len = 9, sign = 0 '\000', buf = 0x7f144dd8402c}, foo1 = 123, buffer = {-1515870811, -1515870811, -1515870811, -1515870811, -1515870811, -1515870811, -1515870811, -1515870811, -1515870811}, foo2 = 123}}, <No data fields>}, buffer = "\260\f\000<\001\000\000\000\240B\330M\024\177\000\000y\\\314\233iU\000\000\240\061\202\234iU\000\000\020C\330M\024\177\000\000\b\000\000\000iU\000\000\320\f\000<\024\177\000\000\006", '\000' <repeats 15 times>, "I\000\000\000\000\000\000\000J\000\000\000\000\000\000\000\331\354\000<\024\177\000\000\332\354\000<\024\177\000\000`\317q\234iU\000\000\360I\001<\024\177\000\000\020A\330M\024\177\000\000s\213\367\232iU\000\000\240\061\202\234iU\000\000`\317q\234iU\000\000\240\061\202\234iU\000\000\220\362\311\233iU\000\000 A\330M\024\177\000\000\274\363\311\233iU\000\000PA\330M\024\177\000\000`\v\000<\024\177\000\000"...}
              item = 0x7f143c015348
              it = {<base_list_iterator> = {list = 0x7f143c014b38, el = 0x7f143c015430, prev = 0x0, current = 0x0}, <No data fields>}
              _db_stack_frame_ = {func = 0x55699bd85dff "select_send::send_data", file = 0x55699bd850a8 "/data/src/10.4/sql/sql_class.cc", level = 2147483657, line = -1, prev = 0x7f144dd843a0}
      #18 0x000055699b02f6ec in select_send::send_data (this=0x7f143c015dc0, items=@0x7f143c014b38: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7f143c015430, last = 0x7f143c015430, elements = 1}, <No data fields>}) at /data/src/10.4/sql/sql_class.cc:3113
              protocol = 0x7f143c001388
              _db_stack_frame_ = {func = 0x55699bda5019 "JOIN::exec_inner", file = 0x55699bda3fb0 "/data/src/10.4/sql/sql_select.cc", level = 2147483656, line = -1, prev = 0x7f144dd84400}
      #19 0x000055699b0f7f8c in JOIN::exec_inner (this=0x7f143c015de8) at /data/src/10.4/sql/sql_select.cc:4413
              columns_list = 0x7f143c014b38
              _db_stack_frame_ = {func = 0x55699bda50f7 "mysql_select", file = 0x55699bda3fb0 "/data/src/10.4/sql/sql_select.cc", level = 2147483655, line = -1, prev = 0x7f144dd84540}
              __PRETTY_FUNCTION__ = "void JOIN::exec_inner()"
              trace_wrapper = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x55699c510510 <vtable for Json_writer_object+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
              trace_exec = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x55699c510510 <vtable for Json_writer_object+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
              trace_steps = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x55699c5104f0 <vtable for Json_writer_array+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
      #20 0x000055699b0f7822 in JOIN::exec (this=0x7f143c015de8) at /data/src/10.4/sql/sql_select.cc:4327
      No locals.
      #21 0x000055699b0f8f9c in mysql_select (thd=0x7f143c000d90, tables=0x0, wild_num=0, fields=@0x7f143c014b38: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7f143c015430, last = 0x7f143c015430, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f143c015dc0, unit=0x7f143c004cc0, select_lex=0x7f143c0149f0) at /data/src/10.4/sql/sql_select.cc:4766
              err = 0
              free_join = true
              _db_stack_frame_ = {func = 0x55699bda4098 "handle_select", file = 0x55699bda3fb0 "/data/src/10.4/sql/sql_select.cc", level = 2147483654, line = -1, prev = 0x7f144dd84600}
              join = 0x7f143c015de8
      #22 0x000055699b0e888a in handle_select (thd=0x7f143c000d90, lex=0x7f143c004c00, result=0x7f143c015dc0, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:436
              unit = 0x7f143c004cc0
              res = false
              select_lex = 0x7f143c0149f0
              _db_stack_frame_ = {func = 0x55699bd97930 "mysql_execute_command", file = 0x55699bd96cc8 "/data/src/10.4/sql/sql_parse.cc", level = 2147483653, line = -1, prev = 0x7f144dd84c80}
      #23 0x000055699b0adf76 in execute_sqlcom_select (thd=0x7f143c000d90, all_tables=0x0) at /data/src/10.4/sql/sql_parse.cc:6449
              save_protocol = 0x0
              lex = 0x7f143c004c00
              result = 0x7f143c015dc0
              res = false
              __PRETTY_FUNCTION__ = "bool execute_sqlcom_select(THD*, TABLE_LIST*)"
      #24 0x000055699b0a4796 in mysql_execute_command (thd=0x7f143c000d90) at /data/src/10.4/sql/sql_parse.cc:3963
              privileges_requested = 1
              res = 0
              up_result = 0
              lex = 0x7f143c004c00
              select_lex = 0x7f143c0149f0
              first_table = 0x0
              all_tables = 0x0
              unit = 0x7f143c004cc0
              have_table_map_for_update = false
              rpl_filter = 0x55699b50107d <inline_mysql_mutex_unlock(mysql_mutex_t*, char const*, uint)+107>
              _db_stack_frame_ = {func = 0x55699bd98bb8 "mysql_parse", file = 0x55699bd96cc8 "/data/src/10.4/sql/sql_parse.cc", level = 2147483652, line = -1, prev = 0x7f144dd85250}
              __PRETTY_FUNCTION__ = "int mysql_execute_command(THD*)"
              ots = {ctx = 0x7f143c0048e0, traceable = false}
              trace_command = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x55699c510510 <vtable for Json_writer_object+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
              trace_command_steps = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x55699c5104f0 <vtable for Json_writer_array+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
              orig_binlog_format = BINLOG_FORMAT_MIXED
              orig_current_stmt_binlog_format = BINLOG_FORMAT_STMT
      #25 0x000055699b0b1efa in mysql_parse (thd=0x7f143c000d90, rawbuf=0x7f143c014900 "SELECT IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE))", length=72, parser_state=0x7f144dd85410, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
              found_semicolon = 0x0
              error = 32532
              lex = 0x7f143c004c00
              err = false
              _db_stack_frame_ = {func = 0x55699bd9713a "dispatch_command", file = 0x55699bd96cc8 "/data/src/10.4/sql/sql_parse.cc", level = 2147483651, line = -1, prev = 0x7f144dd853f0}
              __PRETTY_FUNCTION__ = "void mysql_parse(THD*, char*, uint, Parser_state*, bool, bool)"
      #26 0x000055699b09e39a in dispatch_command (command=COM_QUERY, thd=0x7f143c000d90, packet=0x7f143c00ac01 "", packet_length=72, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
              packet_end = 0x7f143c014948 ""
              parser_state = {m_lip = {lookahead_token = -1, lookahead_yylval = 0x0, m_thd = 0x7f143c000d90, m_ptr = 0x7f143c014949 "\004", m_tok_start = 0x7f143c014949 "\004", m_tok_end = 0x7f143c014949 "\004", m_end_of_query = 0x7f143c014948 "", m_tok_start_prev = 0x7f143c014948 "", m_buf = 0x7f143c014900 "SELECT IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE))", m_buf_length = 72, m_echo = true, m_echo_saved = 12, m_cpp_buf = 0x7f143c0149a0 "SELECT IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE))", m_cpp_ptr = 0x7f143c0149e8 "", m_cpp_tok_start = 0x7f143c0149e8 "", m_cpp_tok_start_prev = 0x7f143c0149e8 "", m_cpp_tok_end = 0x7f143c0149e8 "", m_body_utf8 = 0x0, m_body_utf8_ptr = 0x55699bcc6a07 <DoTrace+150> "\203\370\005\177\063\205\300\017\210\255", m_cpp_utf8_processed_ptr = 0x0, next_state = MY_LEX_END, found_semicolon = 0x0, ignore_space = false, stmt_prepare_mode = false, multi_statements = true, yylineno = 1, m_digest = 0x0, in_comment = NO_COMMENT, in_comment_saved = (PRESERVE_COMMENT | unknown: 0x5568), m_cpp_text_start = 0x7f143c0149d3 "2022-12-12' AS DATE))", m_cpp_text_end = 0x7f143c0149dd "' AS DATE))", m_underscore_cs = 0x0}, m_yacc = {yacc_yyss = 0x0, yacc_yyvs = 0x0, m_set_signal_info = {m_item = {0x0 <repeats 12 times>}}, m_lock_type = TL_READ_DEFAULT, m_mdl_type = MDL_SHARED_READ}, m_digest_psi = 0x7f143c0046e0}
              net = 0x7f143c0010b8
              error = false
              do_end_of_statement = true
              _db_stack_frame_ = {func = 0x55699bd96ec5 "do_command", file = 0x55699bd96cc8 "/data/src/10.4/sql/sql_parse.cc", level = 2147483650, line = -1, prev = 0x7f144dd85cb0}
              drop_more_results = false
              __PRETTY_FUNCTION__ = "bool dispatch_command(enum_server_command, THD*, char*, uint, bool, bool)"
              __FUNCTION__ = "dispatch_command"
              res = <optimized out>
      #27 0x000055699b09cc4d in do_command (thd=0x7f143c000d90) at /data/src/10.4/sql/sql_parse.cc:1378
              return_value = 128
              packet = 0x7f143c00ac00 "\001"
              packet_length = 73
              net = 0x7f143c0010b8
              command = COM_QUERY
              _db_stack_frame_ = {func = 0x55699c152368 "?func", file = 0x55699c15236e "?file", level = 2147483649, line = -1, prev = 0x0}
              __PRETTY_FUNCTION__ = "bool do_command(THD*)"
              __FUNCTION__ = "do_command"
      #28 0x000055699b22bfbd in do_handle_one_connection (connect=0x55699e7a4460) at /data/src/10.4/sql/sql_connect.cc:1420
              create_user = true
              thr_create_utime = 4852983265324
              thd = 0x7f143c000d90
              __PRETTY_FUNCTION__ = "void do_handle_one_connection(CONNECT*)"
      #29 0x000055699b22bc65 in handle_one_connection (arg=0x55699e7a4460) at /data/src/10.4/sql/sql_connect.cc:1316
              connect = 0x55699e7a4460
      #30 0x000055699b748f9d in pfs_spawn_thread (arg=0x55699e81be60) at /data/src/10.4/storage/perfschema/pfs.cc:1869
              typed_arg = 0x55699e81be60
              user_arg = 0x55699e7a4460
              user_start_routine = 0x55699b22bc35 <handle_one_connection(void*)>
              pfs = 0x7f14520aa6c0
              klass = 0x55699e4c5c00
      #31 0x00007f145427fea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
              ret = <optimized out>
              pd = <optimized out>
              unwind_buf = {cancel_jmp_buf = {{jmp_buf = {139725182101248, 2562032573968484414, 140721266970062, 140721266970063, 139725182099072, 311296, -2475096615206057922, -2475146622501844930}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
              not_first_call = 0
      #32 0x00007f1453e7cdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Reproducible on 10.4-10.10, not reproducible on 10.3.

      The same crash happens with:

      SELECT IF(1,TIMEDIFF(385959,8390000),CAST('2022-12-12' AS DATE));
      

      Non-debug build returns a result which is probably correct, even though it is not immediately obvious:

      MariaDB [test]> SELECT IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE));
      +-------------------------------------------------------------------+
      | IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE)) |
      +-------------------------------------------------------------------+
      | 2022-06-17 15:59:59                                               |
      +-------------------------------------------------------------------+
      1 row in set, 1 warning (0.000 sec)
      

      (executed on 2022-07-21).

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.