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

Assertion `thd->is_error()' failed in virtual bool Field::sp_prepare_and_store_item(THD*, Item**)

Details

    Description

      CREATE FUNCTION f() RETURNS INT DETERMINISTIC RETURN (SELECT a FROM t);
      CREATE TABLE t (c TIMESTAMP);
      SELECT * FROM t WHERE c=f();
      

      Leads to:

      CS 11.7.1 d60efa269e798537efa77b2b915288425f6e73f1 (Debug)

      mariadbd: /test/11.7_dbg/sql/field.cc:1520: virtual bool Field::sp_prepare_and_store_item(THD*, Item**): Assertion `thd->is_error()' failed.
      

      CS 11.7.1 d60efa269e798537efa77b2b915288425f6e73f1 (Debug)

      Core was generated by `/test/MD161224-mariadb-11.7.1-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'.
      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 0x14dae930e700 (LWP 504931))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x000014db02386859 in __GI_abort () at abort.c:79
      #2  0x000014db02386729 in __assert_fail_base (fmt=0x14db0251c588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c6fda7c6fc "thd->is_error()", file=0x55c6fdc1c7db "/test/11.7_dbg/sql/field.cc", line=1520, function=<optimized out>) at assert.c:92
      #3  0x000014db02397fd6 in __GI___assert_fail (assertion=assertion@entry=0x55c6fda7c6fc "thd->is_error()", file=file@entry=0x55c6fdc1c7db "/test/11.7_dbg/sql/field.cc", line=line@entry=1520, function=function@entry=0x55c6fdc1d358 "virtual bool Field::sp_prepare_and_store_item(THD*, Item**)") at assert.c:101
      #4  0x000055c6fd0b714a in Field::sp_prepare_and_store_item (this=0x14dabc01e5f8, thd=0x14dabc000d48, value=<optimized out>) at /test/11.7_dbg/sql/sql_error.h:1063
      #5  0x000055c6fccddc5b in THD::sp_eval_expr (this=this@entry=0x14dabc000d48, result_field=0x14dabc01e5f8, expr_item_ptr=expr_item_ptr@entry=0x14dabc04f860) at /test/11.7_dbg/sql/sp_head.cc:444
      #6  0x000055c6fcceee18 in sp_rcontext::set_return_value (this=0x14dabc099020, thd=thd@entry=0x14dabc000d48, return_value_item=return_value_item@entry=0x14dabc04f860) at /test/11.7_dbg/sql/sp_rcontext.cc:399
      #7  0x000055c6fcfed7c4 in sp_instr_freturn::exec_core (this=0x14dabc04f7e0, thd=0x14dabc000d48, nextp=0x14dae930b8b4) at /test/11.7_dbg/sql/sp_instr.cc:1513
      #8  0x000055c6fcff177c in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x14dabc04f818, thd=thd@entry=0x14dabc000d48, nextp=nextp@entry=0x14dae930b8b4, open_tables=open_tables@entry=true, instr=instr@entry=0x14dabc04f7e0, rerun_the_same_instr=rerun_the_same_instr@entry=false) at /test/11.7_dbg/sql/sp_instr.cc:314
      #9  0x000055c6fcff21ea in sp_lex_keeper::validate_lex_and_exec_core (this=0x14dabc04f818, thd=0x14dabc000d48, nextp=0x14dae930b8b4, open_tables=open_tables@entry=true, instr=0x14dabc04f7e0) at /test/11.7_dbg/sql/sp_instr.cc:493
      #10 0x000055c6fcff308f in sp_instr_freturn::execute (this=<optimized out>, thd=<optimized out>, nextp=<optimized out>) at /test/11.7_dbg/sql/sp_instr.cc:1470
      #11 0x000055c6fcce471c in sp_head::execute (this=this@entry=0x14dabc04b9b0, thd=thd@entry=0x14dabc000d48, merge_da_on_success=merge_da_on_success@entry=true) at /test/11.7_dbg/sql/sp_head.cc:1289
      #12 0x000055c6fcce71e5 in sp_head::execute_function (this=0x14dabc04b9b0, thd=thd@entry=0x14dabc000d48, argp=argp@entry=0x0, argcount=argcount@entry=0, return_value_fld=<optimized out>, func_ctx=func_ctx@entry=0x14dabc01bae8, call_arena=0x14dabc01c600) at /test/11.7_dbg/sql/sp_head.cc:2050
      #13 0x000055c6fd11ea86 in Item_sp::execute_impl (this=this@entry=0x14dabc01ba88, thd=thd@entry=0x14dabc000d48, args=args@entry=0x0, arg_count=arg_count@entry=0) at /test/11.7_dbg/sql/item.cc:3014
      #14 0x000055c6fd11ec7f in Item_sp::execute (this=this@entry=0x14dabc01ba88, thd=0x14dabc000d48, null_value=null_value@entry=0x14dabc01ba44, args=args@entry=0x0, arg_count=arg_count@entry=0) at /test/11.7_dbg/sql/item.cc:2928
      #15 0x000055c6fd1a0c07 in Item_func_sp::execute (this=this@entry=0x14dabc01b9d8) at /test/11.7_dbg/sql/item_func.cc:6681
      #16 0x000055c6fd1b67cf in Item_func_sp::get_date (this=0x14dabc01b9d8, thd=<optimized out>, ltime=0x14dae930c210, fuzzydate={m_mode = (date_mode_t::FRAC_TRUNCATE | date_mode_t::NO_ZERO_IN_DATE)}) at /test/11.7_dbg/sql/item_func.h:4060
      #17 0x000055c6fd014fc1 in Temporal_with_date::make_from_item (this=this@entry=0x14dae930c210, thd=0x14dabc000d48, item=0x14dabc01b9d8, fuzzydate=<optimized out>) at /test/11.7_dbg/sql/sql_type.cc:1069
      #18 0x000055c6fd022aff in Temporal_with_date::Temporal_with_date (fuzzydate=<optimized out>, item=<optimized out>, thd=<optimized out>, this=0x14dae930c210) at /test/11.7_dbg/sql/sql_type.h:2156
      #19 Datetime::Datetime (this=0x14dae930c210, thd=<optimized out>, item=<optimized out>, fuzzydate=<optimized out>) at /test/11.7_dbg/sql/sql_type.h:2439
      #20 0x000055c6fd015152 in Type_handler_datetime_common::convert_item_for_comparison (this=<optimized out>, thd=0x14dabc000d48, subject=0x14dabc01b9d8, counterpart=<optimized out>) at /test/11.7_dbg/sql/sql_basic_types.h:283
      #21 0x000055c6fd14e455 in Item_func::aggregate_args2_for_comparison_with_conversion (this=this@entry=0x14dabc01c620, thd=thd@entry=0x14dabc000d48, th=th@entry=0x14dae930c2e8) at /test/11.7_dbg/sql/sql_type.h:7773
      #22 0x000055c6fd14e71f in Item_bool_rowready_func2::fix_length_and_dec (this=0x14dabc01c620, thd=0x14dabc000d48) at /test/11.7_dbg/sql/item_cmpfunc.cc:526
      #23 0x000055c6fd1879e3 in Item_func::fix_fields (this=0x14dabc01c620, thd=0x14dabc000d48, ref=<optimized out>) at /test/11.7_dbg/sql/item_func.cc:366
      #24 0x000055c6fcd34761 in Item::fix_fields_if_needed (ref=0x14dabc01e068, thd=0x14dabc000d48, this=0x14dabc01c620) at /test/11.7_dbg/sql/item.h:1181
      #25 Item::fix_fields_if_needed_for_scalar (ref=0x14dabc01e068, thd=0x14dabc000d48, this=0x14dabc01c620) at /test/11.7_dbg/sql/item.h:1177
      #26 Item::fix_fields_if_needed_for_bool (ref=0x14dabc01e068, thd=0x14dabc000d48, this=0x14dabc01c620) at /test/11.7_dbg/sql/item.h:1181
      #27 setup_conds (thd=thd@entry=0x14dabc000d48, tables=tables@entry=0x14dabc01af60, leaves=@0x14dabc01ab40: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14dabc01e3b0, last = 0x14dabc01e3b0, elements = 1}, <No data fields>}, conds=conds@entry=0x14dabc01e068) at /test/11.7_dbg/sql/sql_base.cc:8928
      #28 0x000055c6fce3858e in setup_without_group (hidden_group_fields=0x14dabc01df2f, win_funcs=@0x14dabc01adc8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55c6fe4cb300 <end_of_list>, last = 0x14dabc01adc8, elements = 0}, <No data fields>}, win_specs=@0x14dabc01ada8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55c6fe4cb300 <end_of_list>, last = 0x14dabc01ada8, elements = 0}, <No data fields>}, group=0x0, order=0x0, conds=0x14dabc01e068, all_fields=@0x14dabc01df80: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14dabc01af10, last = 0x14dabc01af10, elements = 1}, <No data fields>}, fields=@0x14dabc01abe0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14dabc01af10, last = 0x14dabc01af10, elements = 1}, <No data fields>}, leaves=@0x14dabc01ab40: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14dabc01e3b0, last = 0x14dabc01e3b0, elements = 1}, <No data fields>}, tables=0x14dabc01af60, ref_pointer_array=<optimized out>, thd=0x14dabc000d48) at /test/11.7_dbg/sql/sql_select.cc:955
      #29 JOIN::prepare (this=this@entry=0x14dabc01dbd8, tables_init=tables_init@entry=0x14dabc01af60, conds_init=conds_init@entry=0x14dabc01c620, og_num=og_num@entry=0, order_init=order_init@entry=0x0, skip_order_by=skip_order_by@entry=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14dabc01a928, unit_arg=0x14dabc005070) at /test/11.7_dbg/sql/sql_select.cc:1577
      #30 0x000055c6fce50fc4 in mysql_select (thd=thd@entry=0x14dabc000d48, tables=0x14dabc01af60, fields=@0x14dabc01abe0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14dabc01af10, last = 0x14dabc01af10, elements = 1}, <No data fields>}, conds=0x14dabc01c620, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x14dabc01dbb0, unit=0x14dabc005070, select_lex=0x14dabc01a928) at /test/11.7_dbg/sql/sql_select.cc:5327
      #31 0x000055c6fce511bf in handle_select (thd=thd@entry=0x14dabc000d48, lex=lex@entry=0x14dabc004f90, result=result@entry=0x14dabc01dbb0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/11.7_dbg/sql/sql_select.cc:633
      #32 0x000055c6fcdafa25 in execute_sqlcom_select (thd=thd@entry=0x14dabc000d48, all_tables=0x14dabc01af60) at /test/11.7_dbg/sql/sql_parse.cc:6177
      #33 0x000055c6fcdb7fdc in mysql_execute_command (thd=thd@entry=0x14dabc000d48, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.7_dbg/sql/sql_parse.cc:3966
      #34 0x000055c6fcda8895 in mysql_parse (thd=thd@entry=0x14dabc000d48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14dae930d2c0) at /test/11.7_dbg/sql/sql_parse.cc:7901
      #35 0x000055c6fcdbfdd3 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14dabc000d48, packet=packet@entry=0x14dabc00b099 "SELECT * FROM t WHERE c=f()", packet_length=packet_length@entry=27, blocking=blocking@entry=true) at /test/11.7_dbg/sql/sql_class.h:1656
      #36 0x000055c6fcdc2626 in do_command (thd=thd@entry=0x14dabc000d48, blocking=blocking@entry=true) at /test/11.7_dbg/sql/sql_parse.cc:1416
      #37 0x000055c6fcf455bf in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55c7000da478, put_in_cache=put_in_cache@entry=true) at /test/11.7_dbg/sql/sql_connect.cc:1415
      #38 0x000055c6fcf45a99 in handle_one_connection (arg=0x55c7000da478) at /test/11.7_dbg/sql/sql_connect.cc:1327
      #39 0x000014db028b2609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #40 0x000014db02483133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 11.4.5 (dbg), 11.7.1 (dbg), 11.8.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.5.28 (dbg), 10.5.28 (opt), 10.6.21 (dbg), 10.6.21 (opt), 10.11.11 (dbg), 10.11.11 (opt), 11.4.5 (opt), 11.7.1 (opt), 11.8.0 (opt)

      Attachments

        Activity

          Transition Time In Source Status Execution Times
          Alexander Barkov made transition -
          Open In Progress
          40d 6h 28m 1
          Alexander Barkov made transition -
          In Progress Closed
          1h 31m 1

          People

            bar Alexander Barkov
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.