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

Crash on query using CTE with the same name as a base table

Details

    Description

      The following sql reproduces the issue. The create table is not really needed since it doesn't get that far. It crashes before it knows whether the table exists. It seems that it works ok if the last cte is used as the main query instead. So it has something to do with one cte having two references to the previous cte and the previous cte selecting from a table with the same name as itself.

      create or replace table t (id int primary key)
      as select seq as id from seq_1_to_10;
       
       
      with t as (
          select * from t
      ), crash as (
          select t1.id t1id, t2.id t2id
          from t t1
          cross join t t2
      )
      select * from crash;
      

      When it crashes there are no messages in the error log, the server just dies.

      Attachments

        Activity

          alice Alice Sherepa added a comment -

          Thanks for the report!
          I repeated as described on 10.4-11.0:

          MariaDB [test]> with t as (select * from t ), crash as ( select 1 from t t1   join t t2 ) select * from crash;
          ERROR 2013 (HY000): Lost connection to server during query
          

          alice Alice Sherepa added a comment - Thanks for the report! I repeated as described on 10.4-11.0: MariaDB [test]> with t as (select * from t ), crash as ( select 1 from t t1 join t t2 ) select * from crash; ERROR 2013 (HY000): Lost connection to server during query

          @sanja, please review. See also bb-10.4-mdev-31657.

          igor Igor Babaev (Inactive) added a comment - @sanja, please review. See also bb-10.4-mdev-31657.

          OK to push

          sanja Oleksandr Byelkin added a comment - OK to push

          A fix for this bug was pushed into 10.4. It has to be merged upstream as it is.

          igor Igor Babaev (Inactive) added a comment - A fix for this bug was pushed into 10.4. It has to be merged upstream as it is.

          People

            igor Igor Babaev (Inactive)
            jacob.williams Jacob Williams
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.