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

SIGSEGV in optimize_keyuse on INSERT

    XMLWordPrintable

    Details

      Description

      CREATE TABLE t(c INT KEY) ENGINE=InnoDB;
      INSERT INTO t VALUES ((c IN (SELECT * FROM (SELECT * FROM t GROUP BY c) AS d NATURAL JOIN (SELECT * FROM t) AS e)) - 1);
      

      Leads to:

      10.10.0 081a284712bb661349e2e3802077b12211cede3e (Debug)

      Core was generated by `/test/MD310522-mariadb-10.10.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  optimize_keyuse (join=join@entry=0x14d8b40276c0, 
          keyuse_array=keyuse_array@entry=0x14d8b40279e0)
          at /test/10.10_dbg/sql/sql_select.cc:7346
      [Current thread is 1 (Thread 0x14d8eac18700 (LWP 106312))]
      (gdb) bt
      #0  optimize_keyuse (join=join@entry=0x14d8b40276c0, keyuse_array=keyuse_array@entry=0x14d8b40279e0) at /test/10.10_dbg/sql/sql_select.cc:7346
      #1  0x0000562f6ba93dc6 in JOIN::add_keyuses_for_splitting (this=0x14d8b40276c0) at /test/10.10_dbg/sql/opt_split.cc:774
      #2  0x0000562f6ba93f61 in st_join_table::add_keyuses_for_splitting (this=this@entry=0x14d8b407b180) at /test/10.10_dbg/sql/opt_split.cc:801
      #3  0x0000562f6b8df813 in make_join_statistics (join=join@entry=0x14d8b4027020, tables_list=@0x14d8b4014c78: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d8b40282b0, last = 0x14d8b40282c0, elements = 2}, <No data fields>}, keyuse_array=keyuse_array@entry=0x14d8b4027340) at /test/10.10_dbg/sql/sql_select.cc:5769
      #4  0x0000562f6b8e7012 in JOIN::optimize_inner (this=this@entry=0x14d8b4027020) at /test/10.10_dbg/sql/sql_select.cc:2503
      #5  0x0000562f6b8e7452 in JOIN::optimize (this=this@entry=0x14d8b4027020) at /test/10.10_dbg/sql/sql_select.cc:1845
      #6  0x0000562f6b82ba24 in st_select_lex::optimize_unflattened_subqueries (this=0x14d8b40144b0, const_only=const_only@entry=false) at /test/10.10_dbg/sql/sql_lex.cc:4916
      #7  0x0000562f6b81cff6 in mysql_insert (thd=thd@entry=0x14d8b4000db8, table_list=0x14d8b4013dc0, fields=@0x14d8b4005e90: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x562f6cd36a00 <end_of_list>, last = 0x14d8b4005e90, elements = 0}, <No data fields>}, values_list=@0x14d8b4005ed8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d8b4026520, last = 0x14d8b4026520, elements = 1}, <No data fields>}, update_fields=@0x14d8b4005ec0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x562f6cd36a00 <end_of_list>, last = 0x14d8b4005ec0, elements = 0}, <No data fields>}, update_values=@0x14d8b4005ea8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x562f6cd36a00 <end_of_list>, last = 0x14d8b4005ea8, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.10_dbg/sql/sql_lex.h:981
      #8  0x0000562f6b861803 in mysql_execute_command (thd=thd@entry=0x14d8b4000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.10_dbg/sql/sql_parse.cc:4562
      #9  0x0000562f6b84de3a in mysql_parse (thd=thd@entry=0x14d8b4000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d8eac17470) at /test/10.10_dbg/sql/sql_parse.cc:8036
      #10 0x0000562f6b85b422 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d8b4000db8, packet=packet@entry=0x14d8b400b6d9 "INSERT INTO t VALUES ((v IN (SELECT * FROM (SELECT * FROM t GROUP BY v) AS d NATURAL JOIN (SELECT * FROM t) AS e)) - 1)", packet_length=packet_length@entry=119, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_class.h:1364
      #11 0x0000562f6b85db2c in do_command (thd=0x14d8b4000db8, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_parse.cc:1407
      #12 0x0000562f6b9bd3c0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x562f6f202a48, put_in_cache=put_in_cache@entry=true) at /test/10.10_dbg/sql/sql_connect.cc:1418
      #13 0x0000562f6b9bd8c9 in handle_one_connection (arg=0x562f6f202a48) at /test/10.10_dbg/sql/sql_connect.cc:1312
      #14 0x000014d90789a609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #15 0x000014d907486133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.26 (dbg), 10.5.17 (dbg), 10.6.9 (dbg), 10.7.5 (dbg), 10.8.4 (dbg), 10.9.2 (dbg), 10.10.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.3.36 (dbg), 10.3.36 (opt), 10.4.26 (opt), 10.5.17 (opt), 10.6.9 (opt), 10.7.5 (opt), 10.8.4 (opt), 10.9.2 (opt), 10.10.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)

      SIGSEGV|optimize_keyuse|JOIN::add_keyuses_for_splitting|st_join_table::add_keyuses_for_splitting|make_join_statistics
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.