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: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.3.13, 5.5, 10.0, 10.1
    • Fix Version/s: 5.5.54
    • Component/s: Optimizer
    • Labels:
    • Sprint:
      10.0.24, 5.5.50, 10.2.2-2, 10.2.2-3, 10.2.2-4, 5.5.54

      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;

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psergey Sergei Petrunia
                Reporter:
                elenst Elena Stepanova
              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: