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

Assertion `0' failed in Type_handler_row::field_type upon TO_CHAR with wrong argument

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.6, 10.7, 10.8, 10.9, 10.10
    • Fix Version/s: 10.6, 10.7, 10.8, 10.9
    • Component/s: Server
    • Labels:
      None

      Description

      TO_CHAR function was added in 10.6.1, hence the affected versions. Other functions which I tried don't fail this way.

      SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')));
      

      Note: VALUES(1,2) also fails, but I'm using dates in the test case to make it somewhat more sensible, because that's what TO_CHAR normally expects.

      10.6 654236c0

      mariadbd: /data/src/10.6/sql/sql_type.h:4372: virtual enum_field_types Type_handler_row::field_type() const: Assertion `0' failed.
      220722 16:14:57 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f44fc2f4662 in __GI___assert_fail (assertion=0x5607795ae847 "0", file=0x5607795adcb0 "/data/src/10.6/sql/sql_type.h", line=4372, function=0x5607795aeac8 "virtual enum_field_types Type_handler_row::field_type() const") at assert.c:101
      No locals.
      #8  0x0000560778a4b9fa in Type_handler_row::field_type (this=0x56077a118500 <type_handler_row>) at /data/src/10.6/sql/sql_type.h:4372
              __PRETTY_FUNCTION__ = "virtual enum_field_types Type_handler_row::field_type() const"
      #9  0x000056077872ed72 in Item::field_type (this=0x7f44dc016ab8) at /data/src/10.6/sql/item.h:1232
      No locals.
      #10 0x0000560778c77ba4 in Item_func_tochar::fix_length_and_dec (this=0x7f44dc016dc8) at /data/src/10.6/sql/item_timefunc.cc:2635
              cs = 0x560779fce600 <my_charset_latin1>
              arg1 = 0x7f44dc016d18
              repertoire = MY_REPERTOIRE_ASCII
              buffer = {<String> = {<Charset> = {m_charset = 0x560779f2b560 <my_charset_bin>}, <Binary_string> = {<Sql_alloc> = {<No data fields>}, Ptr = 0x7f44f2c9111e "", str_length = 0, Alloced_length = 80, extra_alloc = 0, alloced = false, thread_specific = false}, <No data fields>}, buff = "\000\000p\021\311\362D\177\000\000c4\276x\aV\000\000\002\000\000\000\001\000\000\000\310m\001\334D\177\000\000\004\021\311\362\004\177\000\000`\021\311\362\002\000\000\000\312\263sy\aV\000\000\a\000\000\000\000\000\000\000\220\021\311\362D\177\000\000\b\000\000\000\000"}
              str = 0x7f44dc016d18
              arg0_mysql_type = 32580
      #11 0x0000560778be3c31 in Item_func::fix_fields (this=0x7f44dc016dc8, thd=0x7f44dc000db8, ref=0x7f44dc016fd0) at /data/src/10.6/sql/item_func.cc:359
              __PRETTY_FUNCTION__ = "virtual bool Item_func::fix_fields(THD*, Item**)"
              arg = 0x7f44dc016e50
              arg_end = 0x7f44dc016e50
              buff = " \024\311\362D\177\000\000\260\024\311\362D\177\000\000\b\000\000\000\aV\000\000\340\f\000\334D\177\000\000\b\000\000\000D\177\000\000\340\f\000\334D\177\000\000@\022\311\362D\177\000\000)\000Dy\aV\000\000@\022\311\362D\177\000\000\340\f\000\334D\177\000\000\340\f\000\334D\177\000\000\270\f\000\334\000\000\000\000\034Y\227y\aV\000\000\000\000\000\000\000\000\000\000p\022\311\362D\177\000\000|\001Ay\aV\000\000\200\022\311\362D\177\000\000|\001Ay\aV\000\000\220\022\311\362D\177\000\000\250\002Ay\aV\000\000\240\022\311\362D\177\000\000`\v\000\334D\177\000\000\260\022\311\362D\177\000\000\067\314Cy\aV\000\000\340\f\000\334D\177\000\000"...
      #12 0x0000560778c236a3 in Item_str_func::fix_fields (this=0x7f44dc016dc8, thd=0x7f44dc000db8, ref=0x7f44dc016fd0) at /data/src/10.6/sql/item_strfunc.cc:122
              res = false
      #13 0x00005607786a62dc in Item::fix_fields_if_needed (this=0x7f44dc016dc8, thd=0x7f44dc000db8, ref=0x7f44dc016fd0) at /data/src/10.6/sql/item.h:1144
      No locals.
      #14 0x00005607786a6311 in Item::fix_fields_if_needed_for_scalar (this=0x7f44dc016dc8, thd=0x7f44dc000db8, ref=0x7f44dc016fd0) at /data/src/10.6/sql/item.h:1148
      No locals.
      #15 0x0000560778728c80 in setup_fields (thd=0x7f44dc000db8, ref_pointer_array={m_array = 0x7f44dc017ec0, m_size = 4}, fields=@0x7f44dc015a88: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7f44dc016fc8, last = 0x7f44dc016fc8, elements = 1}, <No data fields>}, column_usage=MARK_COLUMNS_READ, sum_func_list=0x7f44dc017c70, pre_fix=0x7f44dc015aa0, allow_sum_func=true) at /data/src/10.6/sql/sql_base.cc:7709
              item = 0x7f44dc016dc8
              saved_column_usage = MARK_COLUMNS_READ
              save_allow_sum_func = {buffer = {0}}
              it = {<base_list_iterator> = {list = 0x7f44dc015a88, el = 0x7f44dc016fc8, prev = 0x7f44dc015a88, current = 0x7f44dc016fc8}, <No data fields>}
              save_is_item_list_lookup = true
              make_pre_fix = true
              _db_stack_frame_ = {func = 0x56077953aee7 "JOIN::prepare", file = 0x56077953aa10 "/data/src/10.6/sql/sql_select.cc", level = 2147483656, line = -1, prev = 0x7f44f2c915a0}
              __PRETTY_FUNCTION__ = "bool setup_fields(THD*, Ref_ptr_array, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool)"
              li = {<base_list_iterator> = {list = 0x7f44dc006080, el = 0x56077a0ed100 <end_of_list>, prev = 0x7f44dc006080, current = 0x56077a0ed100 <end_of_list>}, <No data fields>}
              var = 0x0
              ref = {m_array = 0x7f44dc017ec0, m_size = 4}
      #16 0x000056077881511a in JOIN::prepare (this=0x7f44dc017918, tables_init=0x0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f44dc0157e8, unit_arg=0x7f44dc005120) at /data/src/10.6/sql/sql_select.cc:1408
              _db_stack_frame_ = {func = 0x56077953bb67 "mysql_select", file = 0x56077953aa10 "/data/src/10.6/sql/sql_select.cc", level = 2147483655, line = -1, prev = 0x7f44f2c91720}
              trace_wrapper = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x560779d8e328 <vtable for Json_writer_object+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
              trace_prepare = {<Json_writer_struct> = {_vptr.Json_writer_struct = 0x560779d8e328 <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 = 0x560779d8e308 <vtable for Json_writer_array+16>, my_writer = 0x0, context = {writer = 0x0}, closed = false}, <No data fields>}
              tbl = 0x0
              li = {<base_list_iterator> = {list = 0x7f44dc015a00, el = 0x56077a0ed100 <end_of_list>, prev = 0x0, current = 0x0}, <No data fields>}
              real_og_num = 0
              __PRETTY_FUNCTION__ = "int JOIN::prepare(TABLE_LIST*, COND*, uint, ORDER*, bool, ORDER*, Item*, ORDER*, SELECT_LEX*, SELECT_LEX_UNIT*)"
              save_place = NO_MATTER
              with_clause = 0x7f44dc017918
              with_elem = 0x7f44f2c915c0
              res = -221702288
      #17 0x0000560778822512 in mysql_select (thd=0x7f44dc000db8, tables=0x0, fields=@0x7f44dc015a88: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7f44dc016fc8, last = 0x7f44dc016fc8, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f44dc0178f0, unit=0x7f44dc005120, select_lex=0x7f44dc0157e8) at /data/src/10.6/sql/sql_select.cc:4997
              err = 0
              free_join = true
              _db_stack_frame_ = {func = 0x56077953aaf8 "handle_select", file = 0x56077953aa10 "/data/src/10.6/sql/sql_select.cc", level = 2147483654, line = -1, prev = 0x7f44f2c917e0}
              join = 0x7f44dc017918
      #18 0x0000560778811923 in handle_select (thd=0x7f44dc000db8, lex=0x7f44dc005058, result=0x7f44dc0178f0, setup_tables_done_option=0) at /data/src/10.6/sql/sql_select.cc:554
              unit = 0x7f44dc005120
              res = false
              select_lex = 0x7f44dc0157e8
              _db_stack_frame_ = {func = 0x56077952bcd0 "mysql_execute_command", file = 0x56077952afa8 "/data/src/10.6/sql/sql_parse.cc", level = 2147483653, line = -1, prev = 0x7f44f2c91e30}
      #19 0x00005607787d2e46 in execute_sqlcom_select (thd=0x7f44dc000db8, all_tables=0x0) at /data/src/10.6/sql/sql_parse.cc:6255
              save_protocol = 0x0
              lex = 0x7f44dc005058
              result = 0x7f44dc0178f0
              res = false
              __PRETTY_FUNCTION__ = "bool execute_sqlcom_select(THD*, TABLE_LIST*)"
      #20 0x00005607787ca146 in mysql_execute_command (thd=0x7f44dc000db8, is_called_from_prepared_stmt=false) at /data/src/10.6/sql/sql_parse.cc:3945
              privileges_requested = SELECT_ACL
              res = 0
              up_result = 0
              lex = 0x7f44dc005058
              select_lex = 0x7f44dc0157e8
              first_table = 0x0
              all_tables = 0x0
              unit = 0x7f44dc005120
              have_table_map_for_update = false
              rpl_filter = 0x7f44f2c91dd0
              _db_stack_frame_ = {func = 0x56077952d037 "mysql_parse", file = 0x56077952afa8 "/data/src/10.6/sql/sql_parse.cc", level = 2147483652, line = -1, prev = 0x7f44f2c92240}
              __PRETTY_FUNCTION__ = "int mysql_execute_command(THD*, bool)"
              ots = {ctx = 0x7f44dc004d20, traceable = false}
              orig_binlog_format = BINLOG_FORMAT_MIXED
              orig_current_stmt_binlog_format = BINLOG_FORMAT_STMT
      #21 0x00005607787d7bb8 in mysql_parse (thd=0x7f44dc000db8, rawbuf=0x7f44dc015720 "SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')))", length=51, parser_state=0x7f44f2c923c0) at /data/src/10.6/sql/sql_parse.cc:8029
              found_semicolon = 0x0
              error = 32580
              lex = 0x7f44dc005058
              err = false
              _db_stack_frame_ = {func = 0x56077952b521 "dispatch_command", file = 0x56077952afa8 "/data/src/10.6/sql/sql_parse.cc", level = 2147483651, line = -1, prev = 0x7f44f2c923a0}
              __PRETTY_FUNCTION__ = "void mysql_parse(THD*, char*, uint, Parser_state*)"
      #22 0x00005607787c421b in dispatch_command (command=COM_QUERY, thd=0x7f44dc000db8, packet=0x7f44dc00b879 "SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')))", packet_length=51, blocking=true) at /data/src/10.6/sql/sql_parse.cc:1896
              packet_end = 0x7f44dc015753 ""
              parser_state = {m_lip = {lookahead_token = -1, lookahead_yylval = 0x0, m_thd = 0x7f44dc000db8, m_ptr = 0x7f44dc015754 "\004", m_tok_start = 0x7f44dc015754 "\004", m_tok_end = 0x7f44dc015754 "\004", m_end_of_query = 0x7f44dc015753 "", m_tok_start_prev = 0x7f44dc015753 "", m_buf = 0x7f44dc015720 "SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')))", m_buf_length = 51, m_echo = true, m_echo_saved = false, m_cpp_buf = 0x7f44dc0157b0 "SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')))", m_cpp_ptr = 0x7f44dc0157e3 "", m_cpp_tok_start = 0x7f44dc0157e3 "", m_cpp_tok_start_prev = 0x7f44dc0157e3 "", m_cpp_tok_end = 0x7f44dc0157e3 "", m_body_utf8 = 0x0, m_body_utf8_ptr = 0x1dc000cb8 <error: Cannot access memory at address 0x1dc000cb8>, 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 = (unknown: 0x10000), m_cpp_text_start = 0x7f44dc0157d5 "2020-10-10')))", m_cpp_text_end = 0x7f44dc0157df "')))", 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 = 0x7f44dc004ab0}
              net = 0x7f44dc0010f0
              error = false
              do_end_of_statement = true
              _db_stack_frame_ = {func = 0x56077952b1a5 "do_command", file = 0x56077952afa8 "/data/src/10.6/sql/sql_parse.cc", level = 2147483650, line = -1, prev = 0x7f44f2c92c80}
              drop_more_results = false
              __PRETTY_FUNCTION__ = "dispatch_command_return dispatch_command(enum_server_command, THD*, char*, uint, bool)"
              __FUNCTION__ = "dispatch_command"
              res = <optimized out>
      #23 0x00005607787c2c16 in do_command (thd=0x7f44dc000db8, blocking=true) at /data/src/10.6/sql/sql_parse.cc:1409
              return_value = (DISPATCH_COMMAND_CLOSE_CONNECTION | unknown: 0x80000000)
              packet = 0x7f44dc00b878 "\003SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')))"
              packet_length = 52
              net = 0x7f44dc0010f0
              command = COM_QUERY
              _db_stack_frame_ = {func = 0x56077997de60 "?func", file = 0x56077997de66 "?file", level = 2147483649, line = -1, prev = 0x0}
              __PRETTY_FUNCTION__ = "dispatch_command_return do_command(THD*, bool)"
              __FUNCTION__ = "do_command"
      #24 0x000056077897cd20 in do_handle_one_connection (connect=0x56077c6f4ea8, put_in_cache=true) at /data/src/10.6/sql/sql_connect.cc:1418
              create_user = true
              thr_create_utime = 4917809604030
              thd = 0x7f44dc000db8
              __PRETTY_FUNCTION__ = "void do_handle_one_connection(CONNECT*, bool)"
      #25 0x000056077897c9bf in handle_one_connection (arg=0x56077c6f4af8) at /data/src/10.6/sql/sql_connect.cc:1312
              connect = 0x56077c6f4af8
      #26 0x0000560778e986fe in pfs_spawn_thread (arg=0x56077c6cdc28) at /data/src/10.6/storage/perfschema/pfs.cc:2201
              typed_arg = 0x56077c6cdc28
              user_arg = 0x56077c6f4af8
              user_start_routine = 0x56077897c964 <handle_one_connection(void*)>
              pfs = 0x7f44fbbe85c0
              klass = 0x56077c105900
      #27 0x00007f44fc7c0ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
              ret = <optimized out>
              pd = <optimized out>
              unwind_buf = {cancel_jmp_buf = {{jmp_buf = {139934107776768, 1659557081960745161, 140733638725310, 140733638725311, 139934107774528, 311296, -1617342237698357047, -1617330307275749175}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
              not_first_call = 0
      #28 0x00007f44fc3bddef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      It's a debug assertion so non-debug builds don't crash, but the error they produce is also questionable:

      query 'SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10')))' failed: ER_STD_INVALID_ARGUMENT (3047): Invalid argument error: data type of first argument must be type date/datetime/time or string in function to_char.
      

      Normally we would probably expect 1241 ER_OPERAND_COLUMNS (Operand should contain 1 column(s)).

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:

                Git Integration

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