Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-25973 Fix tests that were temporary disabled in PS mode
  3. MDEV-26135

Assertion failure when executing PS with a hanging recursive CTE

    XMLWordPrintable

    Details

      Description

      Running of the following test case

      CREATE TABLE t1 (id INT);
      CREATE TABLE t2 (c1 INT, c2 INT);
       
      PREPARE stmt FROM 'with recursive rcte(a) as (select 1 union select cast(a+1 as unsigned) from rcte where a < 10), cte1 as (select count(*) as c1 from t1), cte2 as (select count(*) as c2 from t2) select * from cte1,cte2';
      

      leads to firing of assert in the function reinit_stmt_before_use()

        Assertion failed: (sl->join == 0), function <unknown>, file bb-10.6-MDEV-25973/sql/sql_prepare.cc, line 3174.
      

      and server crash.

      The data member SELECT_LEX::join points to a JOIN object created by the following calling sequence:

      check_prepared_statement
        mysql_test_select
          open_normal_and_derived_tables
            mysql_handle_derived
              mysql_derived_prepare
                st_select_lex_unit::prepare
                  st_select_lex_unit::prepare_join
      

      By some unknown reason the SELECT_LEX object that is owner of this JOIN object is not added to a list which head addressed by lex->unit.first_select()

      In result, when later the method Prepared_statement::prepare() calls lex->unit.cleanup() to clean up objects created on preparing the statement, the method JOIN::destroy() is not called for the JOIN object created on handling the statement

      PREPARE stmt FROM 'with recursive rcte(a) as (select 1 union select cast(a+1 as unsigned) from rcte where a < 10), cte1 as (select count(*) as c1 from t1), cte2 as (select count(*) as c2 from t2) select * from cte1,cte2';
      

      As a consequence, the data member SELECT_LEX::join is not reset and the assert (sl->join == 0) fired later on attempt to run the statement

      EXECUTE stmt;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igor Igor Babaev
              Reporter:
              shulga Dmitry Shulga
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration