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

Crash with EXPLAIN + WITH + constant query

Details

    Description

      This script

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1),(2),(3);
      SELECT * FROM (WITH a AS (SELECT * FROM t1) SELECT 1) AS t1;
      EXPLAIN SELECT * FROM (WITH a AS (SELECT * FROM t1) SELECT 1) AS t1;
      

      crashes the served with the following stack trace:

      #0  0x0000555555a419a3 in st_select_lex::update_used_tables (this=0x7ffecf4612e0)
          at /home/bar/maria-git/server.10.2/sql/sql_lex.cc:4218
      #1  0x0000555555a8bda7 in JOIN::optimize_inner (this=0x7ffecf4656f0)
          at /home/bar/maria-git/server.10.2/sql/sql_select.cc:1162
      #2  0x0000555555a8b9b4 in JOIN::optimize (this=0x7ffecf4656f0) at /home/bar/maria-git/server.10.2/sql/sql_select.cc:1070
      #3  0x0000555555a93cbf in mysql_select (thd=0x7ffecf416070, tables=0x7ffecf461ee0, wild_num=0, fields=..., conds=0x0, 
          og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184068, result=0x7ffecf4644d0, 
          unit=0x7ffecf461678, select_lex=0x7ffecf4612e0) at /home/bar/maria-git/server.10.2/sql/sql_select.cc:3524
      #4  0x0000555555ac7a2b in mysql_explain_union (thd=0x7ffecf416070, unit=0x7ffecf461678, result=0x7ffecf4644d0)
          at /home/bar/maria-git/server.10.2/sql/sql_select.cc:24511
      #5  0x0000555555ac77c7 in select_describe (join=0x7ffecf464b50, need_tmp_table=false, need_order=false, distinct=false, 
          message=0x0) at /home/bar/maria-git/server.10.2/sql/sql_select.cc:24466
      #6  0x0000555555a935b9 in JOIN::exec_inner (this=0x7ffecf464b50)
          at /home/bar/maria-git/server.10.2/sql/sql_select.cc:3314
      #7  0x0000555555a92c8a in JOIN::exec (this=0x7ffecf464b50) at /home/bar/maria-git/server.10.2/sql/sql_select.cc:3154
      #8  0x0000555555a93d4f in mysql_select (thd=0x7ffecf416070, tables=0x7ffecf463e00, wild_num=1, fields=..., conds=0x0, 
          og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748612, result=0x7ffecf4644d0, 
          unit=0x7ffecf419ac0, select_lex=0x7ffecf41a1e8) at /home/bar/maria-git/server.10.2/sql/sql_select.cc:3538
      #9  0x0000555555ac7a2b in mysql_explain_union (thd=0x7ffecf416070, unit=0x7ffecf419ac0, result=0x7ffecf4644d0)
          at /home/bar/maria-git/server.10.2/sql/sql_select.cc:24511
      

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov added a comment - - edited

            A similar crash happens with this script:

            DROP TABLE IF EXISTS t1,t2,t3;
            CREATE TABLE t1 (a INT);
            CREATE TABLE t2 (a INT);
            CREATE TABLE t3 (a INT);
            INSERT INTO t1 VALUES (1),(2),(3);
            INSERT INTO t2 VALUES (1),(2),(3);
            INSERT INTO t3 VALUES (1),(2),(3);
            EXPLAIN WITH a AS (SELECT * FROM t1) SELECT * FROM (t2 NATURAL JOIN t3);
            

            and with this script:

            DROP TABLE IF EXISTS t1,t2,t3;
            CREATE TABLE t1 (a INT);
            CREATE TABLE t2 (a INT);
            CREATE TABLE t3 (a INT);
            INSERT INTO t1 VALUES (1),(2),(3);
            INSERT INTO t2 VALUES (1),(2),(3);
            INSERT INTO t3 VALUES (1),(2),(3);
            EXPLAIN SELECT * FROM (WITH a AS (SELECT * FROM t1) SELECT * FROM t2 NATURAL JOIN t3) AS d1;
            

            bar Alexander Barkov added a comment - - edited A similar crash happens with this script: DROP TABLE IF EXISTS t1,t2,t3; CREATE TABLE t1 (a INT ); CREATE TABLE t2 (a INT ); CREATE TABLE t3 (a INT ); INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t2 VALUES (1),(2),(3); INSERT INTO t3 VALUES (1),(2),(3); EXPLAIN WITH a AS ( SELECT * FROM t1) SELECT * FROM (t2 NATURAL JOIN t3); and with this script: DROP TABLE IF EXISTS t1,t2,t3; CREATE TABLE t1 (a INT ); CREATE TABLE t2 (a INT ); CREATE TABLE t3 (a INT ); INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t2 VALUES (1),(2),(3); INSERT INTO t3 VALUES (1),(2),(3); EXPLAIN SELECT * FROM ( WITH a AS ( SELECT * FROM t1) SELECT * FROM t2 NATURAL JOIN t3) AS d1;

            Checked all the testcase. Neither crashes on the current 10.2 tree (after the recursive CTEs tree was merged).

            psergei Sergei Petrunia added a comment - Checked all the testcase. Neither crashes on the current 10.2 tree (after the recursive CTEs tree was merged).
            bar Alexander Barkov added a comment - Reopened. Please see here for details: https://lists.launchpad.net/maria-developers/msg09938.html

            People

              igor Igor Babaev (Inactive)
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.