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

Assertion `!jt1->emb_sj_nest' failed in join_tab_cmp_straight

    Details

      Description

      CREATE TABLE t1 (f1 VARCHAR(3));
      INSERT INTO t1 VALUES ('foo'),('foo');
       
      CREATE TABLE t2 (f2 VARCHAR(3));
      INSERT INTO t2 VALUES ('bar'),('qux');
       
      SELECT STRAIGHT_JOIN * FROM ( SELECT * FROM t1 WHERE f1 IN ( SELECT f2 FROM t2 ) ) AS sq;
       
      # Cleanup
      DROP TABLE t1, t2;
      

      mysqld: /data/src/5.5/sql/sql_select.cc:6356: int join_tab_cmp_straight(const void*, const void*, const void*): Assertion `!jt1->emb_sj_nest' failed.
      170516 13:56:07 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f88ea52cee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x000000000063fb7e in join_tab_cmp_straight (dummy=0x0, ptr1=0x7f88e5174a48, ptr2=0x7f88e5174a50) at /data/src/5.5/sql/sql_select.cc:6356
      #9  0x0000000000c9093d in my_qsort2 (base_ptr=0x7f88e5174a48, count=2, size=8, cmp=0x63fb20 <join_tab_cmp_straight(void const*, void const*, void const*)>, cmp_argument=0x0) at /data/src/5.5/mysys/mf_qsort.c:131
      #10 0x000000000063f760 in choose_plan (join=0x7f88e5198078, join_tables=3) at /data/src/5.5/sql/sql_select.cc:6184
      #11 0x000000000063916d in make_join_statistics (join=0x7f88e5198078, tables_list=..., conds=0x7f88e5174078, keyuse_array=0x7f88e5198398) at /data/src/5.5/sql/sql_select.cc:3805
      #12 0x00000000006300ce in JOIN::optimize (this=0x7f88e5198078) at /data/src/5.5/sql/sql_select.cc:1234
      #13 0x0000000000636a65 in mysql_select (thd=0x7f88e6264060, rref_pointer_array=0x7f88e6267cf0, tables=0x7f88e51815e0, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748610, result=0x7f88e5181c68, unit=0x7f88e6267388, select_lex=0x7f88e6267a68) at /data/src/5.5/sql/sql_select.cc:3085
      #14 0x000000000062d352 in handle_select (thd=0x7f88e6264060, lex=0x7f88e62672d8, result=0x7f88e5181c68, setup_tables_done_option=0) at /data/src/5.5/sql/sql_select.cc:319
      #15 0x00000000006067b3 in execute_sqlcom_select (thd=0x7f88e6264060, all_tables=0x7f88e51815e0) at /data/src/5.5/sql/sql_parse.cc:4686
      #16 0x00000000005ffb26 in mysql_execute_command (thd=0x7f88e6264060) at /data/src/5.5/sql/sql_parse.cc:2234
      #17 0x000000000060937e in mysql_parse (thd=0x7f88e6264060, rawbuf=0x7f88e5148078 "SELECT STRAIGHT_JOIN * FROM ( SELECT * FROM t1 WHERE f1 IN ( SELECT f2 FROM t2 ) ) AS sq", length=88, parser_state=0x7f88ebfa0650) at /data/src/5.5/sql/sql_parse.cc:5931
      #18 0x00000000005fd0b5 in dispatch_command (command=COM_QUERY, thd=0x7f88e6264060, packet=0x7f88e9f5b061 "SELECT STRAIGHT_JOIN * FROM ( SELECT * FROM t1 WHERE f1 IN ( SELECT f2 FROM t2 ) ) AS sq", packet_length=88) at /data/src/5.5/sql/sql_parse.cc:1079
      #19 0x00000000005fc26f in do_command (thd=0x7f88e6264060) at /data/src/5.5/sql/sql_parse.cc:793
      #20 0x00000000006fe951 in do_handle_one_connection (thd_arg=0x7f88e6264060) at /data/src/5.5/sql/sql_connect.cc:1268
      #21 0x00000000006fe6de in handle_one_connection (arg=0x7f88e6264060) at /data/src/5.5/sql/sql_connect.cc:1184
      #22 0x0000000000a0bae7 in pfs_spawn_thread (arg=0x7f88e6f76fc0) at /data/src/5.5/storage/perfschema/pfs.cc:1015
      #23 0x00007f88ebbd3494 in start_thread (arg=0x7f88ebfa1700) at pthread_create.c:333
      #24 0x00007f88ea5e993f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Reproducible both with MyISAM and InnoDB.
      The failure started happening on 5.5 tree with this revision:

      commit 6b97fe067db1b1d8e8dee56508e6d78a36e92481
      Author: Igor Babaev 
      Date:   Tue May 9 00:41:45 2017 -0700
       
          Fixed the bugs mdev-12670 and mdev-12675.
          
          The code that blocked conversion of a IN subselect pedicate to a semi-join
          if it occurred in the ON expression of an outer join did not do it correctly.
          As a result, the conversion was blocked for IN subselect predicates
          encountered in ON expressions of INNER joins or in WHERE conditions
          of mergeable views / derived tables. This patch fixes this problem.
      

        Attachments

          Activity

            People

            • Assignee:
              igor Igor Babaev
              Reporter:
              elenst Elena Stepanova
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: