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

Assertion `outer_context || !*from_field || *from_field == not_found_field' failed on 2nd execution of PS with nested subqueries

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.3.13, 10.1, 10.0, 5.5
    • Fix Version/s: 10.1, 10.0, 5.5
    • Component/s: Optimizer
    • Labels:

      Description

      See also MDEV-7688, MDEV-7689, MDEV-7690, MDEV-7696, MDEV-7751 - they all are somewhat similar, probably there are duplicates among them; but effects are different everywhere.

      Stack trace from 5.5 commit 34f37aa0c0aa87cfb6908500e937516ff37ea6f0
      5.5/sql/item.cc:4806: int Item_field::fix_outer_field(THD*, Field**, Item**): Assertion `outer_context || !*from_field || *from_field == not_found_field' failed.
      150310 17:48:11 [ERROR] mysqld got signal 6 ;
      
      #6  0x00007fdca20ce311 in *__GI___assert_fail (assertion=0xe05880 "outer_context || !*from_field || *from_field == not_found_field", file=<optimized out>, line=4806, function=0xe07dc0 "int Item_field::fix_outer_field(THD*, Field**, Item**)") at assert.c:81#7  0x00000000007fd8f6 in Item_field::fix_outer_field (this=0x7fdc9cca88a8, thd=0x7fdca0b49060, from_field=0x7fdc9d7b39f8, reference=0x7fdc9cca3608) at sql/item.cc:4805
      #8  0x00000000007feac4 in Item_field::fix_fields (this=0x7fdc9cca88a8, thd=0x7fdca0b49060, reference=0x7fdc9cca3608) at sql/item.cc:5191
      #9  0x00000000005de894 in setup_fields (thd=0x7fdca0b49060, ref_pointer_array=0x7fdc9cca89c0, fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x7fdc9cc45748, allow_sum_func=true) at sql/sql_base.cc:8169
      #10 0x00000000006602ac in JOIN::prepare (this=0x7fdc9cc45418, rref_pointer_array=0x7fdc9cca2a80, tables_init=0x7fdc9cca3648, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x7fdc9cca8dc0, proc_param_init=0x0, select_lex_arg=0x7fdc9cca2810, unit_arg=0x7fdc9cca2130) at sql/sql_select.cc:723
      #11 0x00000000006689fb in mysql_select (thd=0x7fdca0b49060, rref_pointer_array=0x7fdc9cca2a80, tables=0x7fdc9cca3648, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x7fdc9cca8dc0, proc_param=0x0, select_options=2416184064, result=0x7fdc9cca8888, unit=0x7fdc9cca2130, select_lex=0x7fdc9cca2810) at sql/sql_select.cc:3074
      #12 0x000000000065f57d in handle_select (thd=0x7fdca0b49060, lex=0x7fdc9cca2080, result=0x7fdc9cca8888, setup_tables_done_option=0) at sql/sql_select.cc:319
      #13 0x0000000000638728 in execute_sqlcom_select (thd=0x7fdca0b49060, all_tables=0x7fdc9cca3648) at sql/sql_parse.cc:4689
      #14 0x000000000063190a in mysql_execute_command (thd=0x7fdca0b49060) at sql/sql_parse.cc:2234
      #15 0x0000000000652b81 in Prepared_statement::execute (this=0x7fdc9cc92460, expanded_query=0x7fdc9d7b4c90, open_cursor=false) at sql/sql_prepare.cc:3928
      #16 0x0000000000651c98 in Prepared_statement::execute_loop (this=0x7fdc9cc92460, expanded_query=0x7fdc9d7b4c90, open_cursor=false, packet=0x0, packet_end=0x0) at sql/sql_prepare.cc:3587
      #17 0x000000000064fdbc in mysql_sql_stmt_execute (thd=0x7fdca0b49060) at sql/sql_prepare.cc:2737
      #18 0x0000000000631938 in mysql_execute_command (thd=0x7fdca0b49060) at sql/sql_parse.cc:2244
      #19 0x000000000063b20e in mysql_parse (thd=0x7fdca0b49060, rawbuf=0x7fdc9cc45078 "EXECUTE stmt", length=12, parser_state=0x7fdc9d7b5620) at sql/sql_parse.cc:5909
      #20 0x000000000062ee51 in dispatch_command (command=COM_QUERY, thd=0x7fdca0b49060, packet=0x7fdc9dde8061 "EXECUTE stmt", packet_length=12) at sql/sql_parse.cc:1079
      #21 0x000000000062dfdd in do_command (thd=0x7fdca0b49060) at sql/sql_parse.cc:793
      #22 0x0000000000730712 in do_handle_one_connection (thd_arg=0x7fdca0b49060) at sql/sql_connect.cc:1266
      #23 0x00000000007301d1 in handle_one_connection (arg=0x7fdca0b49060) at sql/sql_connect.cc:1181
      #24 0x0000000000b66bad in pfs_spawn_thread (arg=0x7fdc9dd50ee0) at storage/perfschema/pfs.cc:1015
      #25 0x00007fdca3871b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
      #26 0x00007fdca217f70d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
      
      Test case
      CREATE TABLE t1 (a INT) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (4),(6);
      
      CREATE TABLE t2 (b INT) ENGINE=MyISAM;
      INSERT INTO t2 VALUES (1),(8);
      
      PREPARE stmt FROM "
      SELECT * FROM t2
      HAVING 0 IN ( 
        SELECT a FROM t1 
        WHERE a IN ( 
          SELECT a FROM t1
          WHERE b = a
        )
      )
      "; 
      
      EXECUTE stmt;
      EXECUTE stmt;
      
      Alternative test case, without HAVING
      CREATE TABLE t (i INT) ENGINE=MyISAM;
      INSERT INTO t VALUES (4),(6);
      
      PREPARE stmt FROM "
      SELECT * FROM t AS t1
      WHERE EXISTS ( 
        SELECT * FROM t AS t2 WHERE t1.i IN ( 
          SELECT i FROM t 
        ) 
      )";
      
      EXECUTE stmt;
      EXECUTE stmt;
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            On 5.3 the same test case causes a different assertion failure:

            mysqld: sql_lex.cc:1911: bool st_select_lex::mark_as_dependent(THD*, st_select_lex*, Item*): Assertion `this != last' failed.
            150311 12:03:29 [ERROR] mysqld got signal 6 ;
            
            #6  0x00007f158a0cd311 in *__GI___assert_fail (assertion=0xc7df22 "this != last", file=<optimized out>, line=1911, function=0xc7f080 "bool st_select_lex::mark_as_dependent(THD*, st_select_lex*, Item*)") at assert.c:81
            #7  0x00000000005871e0 in st_select_lex::mark_as_dependent (this=0x26352a8, thd=0x25b4fb0, last=0x26352a8, dependency=0x26392f8) at sql_lex.cc:1911
            #8  0x00000000005aa9b9 in mark_as_dependent (thd=0x25b4fb0, last=0x26352a8, current=0x26352a8, resolved_item=0x26392f8, mark_item=0x26392f8) at item.cc:4026
            #9  0x00000000005abfb5 in Item_field::fix_outer_field (this=0x26392f8, thd=0x25b4fb0, from_field=0x7f15815e8828, reference=0x2602698) at item.cc:4625
            #10 0x00000000005ac64e in Item_field::fix_fields (this=0x26392f8, thd=0x25b4fb0, reference=0x2602698) at item.cc:4794
            #11 0x00000000007141dd in setup_fields (thd=0x25b4fb0, ref_pointer_array=0x26394a8, fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x2639040, allow_sum_func=true) at sql_base.cc:7868
            #12 0x000000000072c7d6 in JOIN::prepare (this=0x2638d08, rref_pointer_array=0x26348f8, tables_init=0x264a7e8, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x263a838, proc_param_init=0x0, select_lex_arg=0x2634640, unit_arg=0x2634118) at sql_select.cc:666
            #13 0x00000000007351fb in mysql_select (thd=0x25b4fb0, rref_pointer_array=0x26348f8, tables=0x264a7e8, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x263a838, proc_param=0x0, select_options=2416200192, result=0x26376d8, unit=0x2634118, select_lex=0x2634640) at sql_select.cc:2987
            #14 0x000000000072bc1b in handle_select (thd=0x25b4fb0, lex=0x2634078, result=0x26376d8, setup_tables_done_option=0) at sql_select.cc:288
            #15 0x00000000006b9973 in execute_sqlcom_select (thd=0x25b4fb0, all_tables=0x264a7e8) at sql_parse.cc:5174
            #16 0x00000000006b0b06 in mysql_execute_command (thd=0x25b4fb0) at sql_parse.cc:2307
            #17 0x000000000078dcb8 in Prepared_statement::execute (this=0x2625e30, expanded_query=0x7f15815e9c70, open_cursor=false) at sql_prepare.cc:3764
            #18 0x000000000078cf05 in Prepared_statement::execute_loop (this=0x2625e30, expanded_query=0x7f15815e9c70, open_cursor=false, packet=0x0, packet_end=0x0) at sql_prepare.cc:3445
            #19 0x000000000078b35c in mysql_sql_stmt_execute (thd=0x25b4fb0) at sql_prepare.cc:2670
            #20 0x00000000006b0b34 in mysql_execute_command (thd=0x25b4fb0) at sql_parse.cc:2316
            #21 0x00000000006bc2ca in mysql_parse (thd=0x25b4fb0, rawbuf=0x26429e8 "EXECUTE stmt", length=12, found_semicolon=0x7f15815eacc8) at sql_parse.cc:6175
            #22 0x00000000006ae367 in dispatch_command (command=COM_QUERY, thd=0x25b4fb0, packet=0x25fe5a1 "EXECUTE stmt", packet_length=12) at sql_parse.cc:1245
            #23 0x00000000006ad640 in do_command (thd=0x25b4fb0) at sql_parse.cc:923
            #24 0x00000000006aa092 in handle_one_connection (arg=0x25b4fb0) at sql_connect.cc:1231
            #25 0x00007f158addbb50 in start_thread (arg=<optimized out>) at pthread_create.c:304
            #26 0x00007f158a17e70d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
            
            Show
            elenst Elena Stepanova added a comment - On 5.3 the same test case causes a different assertion failure: mysqld: sql_lex.cc:1911: bool st_select_lex::mark_as_dependent(THD*, st_select_lex*, Item*): Assertion `this != last' failed. 150311 12:03:29 [ERROR] mysqld got signal 6 ; #6 0x00007f158a0cd311 in *__GI___assert_fail (assertion=0xc7df22 "this != last", file=<optimized out>, line=1911, function=0xc7f080 "bool st_select_lex::mark_as_dependent(THD*, st_select_lex*, Item*)") at assert.c:81 #7 0x00000000005871e0 in st_select_lex::mark_as_dependent (this=0x26352a8, thd=0x25b4fb0, last=0x26352a8, dependency=0x26392f8) at sql_lex.cc:1911 #8 0x00000000005aa9b9 in mark_as_dependent (thd=0x25b4fb0, last=0x26352a8, current=0x26352a8, resolved_item=0x26392f8, mark_item=0x26392f8) at item.cc:4026 #9 0x00000000005abfb5 in Item_field::fix_outer_field (this=0x26392f8, thd=0x25b4fb0, from_field=0x7f15815e8828, reference=0x2602698) at item.cc:4625 #10 0x00000000005ac64e in Item_field::fix_fields (this=0x26392f8, thd=0x25b4fb0, reference=0x2602698) at item.cc:4794 #11 0x00000000007141dd in setup_fields (thd=0x25b4fb0, ref_pointer_array=0x26394a8, fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x2639040, allow_sum_func=true) at sql_base.cc:7868 #12 0x000000000072c7d6 in JOIN::prepare (this=0x2638d08, rref_pointer_array=0x26348f8, tables_init=0x264a7e8, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x263a838, proc_param_init=0x0, select_lex_arg=0x2634640, unit_arg=0x2634118) at sql_select.cc:666 #13 0x00000000007351fb in mysql_select (thd=0x25b4fb0, rref_pointer_array=0x26348f8, tables=0x264a7e8, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x263a838, proc_param=0x0, select_options=2416200192, result=0x26376d8, unit=0x2634118, select_lex=0x2634640) at sql_select.cc:2987 #14 0x000000000072bc1b in handle_select (thd=0x25b4fb0, lex=0x2634078, result=0x26376d8, setup_tables_done_option=0) at sql_select.cc:288 #15 0x00000000006b9973 in execute_sqlcom_select (thd=0x25b4fb0, all_tables=0x264a7e8) at sql_parse.cc:5174 #16 0x00000000006b0b06 in mysql_execute_command (thd=0x25b4fb0) at sql_parse.cc:2307 #17 0x000000000078dcb8 in Prepared_statement::execute (this=0x2625e30, expanded_query=0x7f15815e9c70, open_cursor=false) at sql_prepare.cc:3764 #18 0x000000000078cf05 in Prepared_statement::execute_loop (this=0x2625e30, expanded_query=0x7f15815e9c70, open_cursor=false, packet=0x0, packet_end=0x0) at sql_prepare.cc:3445 #19 0x000000000078b35c in mysql_sql_stmt_execute (thd=0x25b4fb0) at sql_prepare.cc:2670 #20 0x00000000006b0b34 in mysql_execute_command (thd=0x25b4fb0) at sql_parse.cc:2316 #21 0x00000000006bc2ca in mysql_parse (thd=0x25b4fb0, rawbuf=0x26429e8 "EXECUTE stmt", length=12, found_semicolon=0x7f15815eacc8) at sql_parse.cc:6175 #22 0x00000000006ae367 in dispatch_command (command=COM_QUERY, thd=0x25b4fb0, packet=0x25fe5a1 "EXECUTE stmt", packet_length=12) at sql_parse.cc:1245 #23 0x00000000006ad640 in do_command (thd=0x25b4fb0) at sql_parse.cc:923 #24 0x00000000006aa092 in handle_one_connection (arg=0x25b4fb0) at sql_connect.cc:1231 #25 0x00007f158addbb50 in start_thread (arg=<optimized out>) at pthread_create.c:304 #26 0x00007f158a17e70d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

              People

              • Assignee:
                sanja Oleksandr Byelkin
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: