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

Assertion failure on 2nd PS execution with optimizer error and Array Binding

    XMLWordPrintable

Details

    Description

      This is a followup to MDEV-35318.

      The patch for MDEV-35318 (and MDEV-36057) has added re-prepare logic in Prepared_statement::execute_loop. But it did not add it in Prepared_statement::execute_bulk_loop, which is another variant of the function to be used with Array Binding.

      A patch for mysql_client_test.c which causes the same kind of failure: mdev36080-testcase.diff

      (The testcase has to be different, as the failing statement must support Array Binding and be able to re-execute. MDEV-36057 used CREATE TABLE which didn't have either of these properties. Also note that there other kinds of issues: MDEV-36072)

        mysqld: /home/psergey/dev-git2/11.7-look/sql/sql_base.cc:8326: bool setup_tables(THD*, 
      Name_resolution_context*, List<TABLE_LIST>*, TABLE_LIST*, List<TABLE_LIST>&, bool, bool): 
      Assertion         `select_lex->leaf_tables_saved' failed.
      

      (gdb) wher
        #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
        #1  0x00007ffff5a847f1 in __GI_abort () at abort.c:79
        #2  0x00007ffff5a743fa in __assert_fail_base (fmt=0x7ffff5bfb6c0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555556e1cf33 "select_lex->leaf_tables_saved", file=file@ entry=0x555556e1afd0 "/home/psergey/dev-git2/11.7-look/sql/sql_base.cc", line=line@entry=8326, function=function@entry=0x555556e1f9c0 <setup_tables(THD*, Name_resolution_context*,                  List<TABLE_LIST>*, TABLE_LIST*, List<TABLE_LIST>&, bool, bool)::__PRETTY_FUNCTION__> "bool setup_tables(THD*, Name_resolution_context*, List<TABLE_LIST>*, TABLE_LIST*, List<TABLE_LIST>&, bool,     bool)") at assert.c:92
        #3  0x00007ffff5a74472 in __GI___assert_fail (assertion=0x555556e1cf33 "select_lex->leaf_tables_saved", file=0x555556e1afd0 "/home/psergey/dev-git2/11.7-look/sql/sql_base.cc", line=8326,         function=0x555556e1f9c0 <setup_tables(THD*, Name_resolution_context*, List<TABLE_LIST>*, TABLE_LIST*, List<TABLE_LIST>&, bool, bool)::__PRETTY_FUNCTION__> "bool setup_tables(THD*,                  Name_resolution_context*, List<TABLE_LIST>*, TABLE_LIST*, List<TABLE_LIST>&, bool, bool)") at assert.c:101
        #4  0x0000555555f4ae74 in setup_tables (thd=0x7fff34008958, context=0x7fff34072d28, from_clause=0x7fff34072e98, tables=0x7fff34075d78, leaves=@0x7fff34072ef8: {<base_list> = {<Sql_alloc> = {<No  data fields>}, first = 0x555557dde3a0 <end_of_list>, last = 0x7fff34072ef8, elements = 0}, <No data fields>}, select_insert=false, full_table_list=false) at /home/psergey/dev-git2/11.7-look/sql/   sql_base.cc:8326
        #5  0x0000555555f4b364 in setup_tables_and_check_access (thd=0x7fff34008958, context=0x7fff34072d28, from_clause=0x7fff34072e98, tables=0x7fff34075d78, leaves=@0x7fff34072ef8: {<base_list> =     {<Sql_alloc> = {<No data fields>}, first = 0x555557dde3a0 <end_of_list>, last = 0x7fff34072ef8, elements = 0}, <No data fields>}, select_insert=false, want_access_first=SELECT_ACL,                 want_access=SELECT_ACL, full_table_list=false) at /home/psergey/dev-git2/11.7-look/sql/sql_base.cc:8420
        #6  0x0000555556061580 in JOIN::prepare (this=0x7fff34021578, tables_init=0x7fff34075d78, conds_init=0x7fff340765c0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0,                having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fff34072ce0, unit_arg=0x7fff34076800) at /home/psergey/dev-git2/11.7-look/sql/sql_select.cc:1468
        #7  0x00005555565376b9 in subselect_single_select_engine::prepare (this=0x7fff340772a8, thd=0x7fff34008958) at /home/psergey/dev-git2/11.7-look/sql/item_subselect.cc:3981
        #8  0x00005555565291d3 in Item_subselect::fix_fields (this=0x7fff34077108, thd_param=0x7fff34008958, ref=0x7fff34077370) at /home/psergey/dev-git2/11.7-look/sql/item_subselect.cc:294
        #9  0x0000555555ec7480 in Item::fix_fields_if_needed (this=0x7fff34077108, thd=0x7fff34008958, ref=0x7fff34077370) at /home/psergey/dev-git2/11.7-look/sql/item.h:1168
        #10 0x00005555564a1a13 in Item_func::fix_fields (this=0x7fff340772e8, thd=0x7fff34008958, ref=0x7fff34021240) at /home/psergey/dev-git2/11.7-look/sql/item_func.cc:348
        #11 0x0000555555ec7480 in Item::fix_fields_if_needed (this=0x7fff340772e8, thd=0x7fff34008958, ref=0x7fff34021240) at /home/psergey/dev-git2/11.7-look/sql/item.h:1168
        #12 0x0000555555ec74ad in Item::fix_fields_if_needed_for_scalar (this=0x7fff340772e8, thd=0x7fff34008958, ref=0x7fff34021240) at /home/psergey/dev-git2/11.7-look/sql/item.h:1177
        #13 0x0000555555f51905 in Item::fix_fields_if_needed_for_bool (this=0x7fff340772e8, thd=0x7fff34008958, ref=0x7fff34021240) at /home/psergey/dev-git2/11.7-look/sql/item.h:1181
        #14 0x0000555555f4cb35 in setup_conds (thd=0x7fff34008958, tables=0x7fff340717a8, leaves=@0x7fff34070368: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff34020d90, last =         0x7fff34020da0, elements = 2}, <No data fields>}, conds=0x7fff34021240) at /home/psergey/dev-git2/11.7-look/sql/sql_base.cc:8885
        #15 0x000055555605eb3b in setup_without_group (thd=0x7fff34008958, ref_pointer_array={m_array = 0x7fff34083620, m_size = 12}, tables=0x7fff340717a8, leaves=@0x7fff34070368: {<base_list> =        {<Sql_alloc> = {<No data fields>}, first = 0x7fff34020d90, last = 0x7fff34020da0, elements = 2}, <No data fields>}, fields=@0x7fff34070408: {<base_list> = {<Sql_alloc> = {<No data fields>}, first  = 0x7fff34072b38, last = 0x7fff34072b38, elements = 1}, <No data fields>}, all_fields=@0x7fff34021158: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff34072b38, last =              0x7fff34072b38, elements = 1}, <No data fields>}, conds=0x7fff34021240, order=0x0, group=0x0, win_specs=@0x7fff340705d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x555557dde3a0    <end_of_list>, last = 0x7fff340705d0, elements = 0}, <No data fields>}, win_funcs=@0x7fff340705f0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x555557dde3a0 <end_of_list>, last =    0x7fff340705f0, elements = 0}, <No data fields>}, hidden_group_fields=0x7fff34021107) at /home/psergey/dev-git2/11.7-look/sql/sql_select.cc:955
        #16 0x0000555556061d4c in JOIN::prepare (this=0x7fff34020db0, tables_init=0x7fff340717a8, conds_init=0x7fff340772e8, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0,                having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fff34070150, unit_arg=0x7fff3406f900) at /home/psergey/dev-git2/11.7-look/sql/sql_select.cc:1577
        #17 0x0000555556172f45 in Sql_cmd_update::prepare_inner (this=0x7fff34072b58, thd=0x7fff34008958) at /home/psergey/dev-git2/11.7-look/sql/sql_update.cc:3101
        #18 0x00005555560bf584 in Sql_cmd_dml::prepare (this=0x7fff34072b58, thd=0x7fff34008958) at /home/psergey/dev-git2/11.7-look/sql/sql_select.cc:34243
        #19 0x00005555560bf709 in Sql_cmd_dml::execute (this=0x7fff34072b58, thd=0x7fff34008958) at /home/psergey/dev-git2/11.7-look/sql/sql_select.cc:34296
        #20 0x0000555555ffbf9e in mysql_execute_command (thd=0x7fff34008958, is_called_from_prepared_stmt=true) at /home/psergey/dev-git2/11.7-look/sql/sql_parse.cc:4428
        #21 0x0000555556042cf7 in Prepared_statement::execute (this=0x7fff3406f388, expanded_query=0x7fffd416b0a0, open_cursor=false) at /home/psergey/dev-git2/11.7-look/sql/sql_prepare.cc:5072
        #22 0x00005555560416ec in Prepared_statement::execute_bulk_loop (this=0x7fff3406f388, expanded_query=0x7fffd416b0a0, open_cursor=false, packet_arg=0x7fff3407b58f "",                              packet_end_arg=0x7fff3407b59a "", send_unit_results=false) at /home/psergey/dev-git2/11.7-look/sql/sql_prepare.cc:4650
        #23 0x000055555603de2b in mysql_stmt_execute_common (thd=0x7fff34008958, stmt_id=2, packet=0x7fff3407b58f "", packet_end=0x7fff3407b59a "", cursor_flags=0, bulk_op=true, read_types=false,        send_unit_results=false) at /home/psergey/dev-git2/11.7-look/sql/sql_prepare.cc:3345
        #24 0x000055555603d803 in mysqld_stmt_bulk_execute (thd=0x7fff34008958, packet_arg=0x7fff3407b589 "\002", packet_length=17) at /home/psergey/dev-git2/11.7-look/sql/sql_prepare.cc:3169
        #25 0x0000555555ff3ec0 in dispatch_command (command=COM_STMT_BULK_EXECUTE, thd=0x7fff34008958, packet=0x7fff3407b589 "\002", packet_length=17, blocking=true) at /home/psergey/dev-git2/11.7-look/ sql/sql_parse.cc:1816
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              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.