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

GTT Context corruption on repeated SQL when autocommit is disabled

    XMLWordPrintable

Details

    Description

      SET autocommit=0; 
      # Original
      CREATE GLOBAL TEMPORARY TABLE t (c INT) ON COMMIT DELETE ROWS;
      INSERT INTO t VALUES (1);
      SELECT COUNT(*) FROM t;  -- 1, correct
      # Drop
      DROP TABLE t;
      # Repeat
      CREATE GLOBAL TEMPORARY TABLE t (c INT) ON COMMIT DELETE ROWS; 
      INSERT INTO t VALUES (1); 
      SELECT COUNT(*) FROM t;  -- 0, incorrect
      

      Leads to:

      MDEV-35915-v11 CS 12.2.0 033918c96079e4e39e9aabb0d94c077b8ec9470c (Optimized, Clang 21.1.3-20250923) Build 14/01/2026

      12.2.0-opt>SET autocommit=0; 
      Query OK, 0 rows affected (0.000 sec)
       
      12.2.0-opt># Original
      12.2.0-opt>CREATE GLOBAL TEMPORARY TABLE t (c INT) ON COMMIT DELETE ROWS;
      Query OK, 0 rows affected (0.011 sec)
       
      12.2.0-opt>INSERT INTO t VALUES (1);
      Query OK, 1 row affected (0.000 sec)
       
      12.2.0-opt>SELECT COUNT(*) FROM t;  -- 1, correct
      +----------+
      | COUNT(*) |
      +----------+
      |        1 |
      +----------+
      1 row in set (0.000 sec)
       
      12.2.0-opt># Drop
      12.2.0-opt>DROP TABLE t;
      Query OK, 0 rows affected (0.005 sec)
       
      12.2.0-opt># Repeat
      12.2.0-opt>CREATE GLOBAL TEMPORARY TABLE t (c INT) ON COMMIT DELETE ROWS; 
      Query OK, 0 rows affected (0.005 sec)
       
      12.2.0-opt>INSERT INTO t VALUES (1); 
      Query OK, 1 row affected (0.000 sec)
       
      12.2.0-opt>SELECT COUNT(*) FROM t;  -- 0, incorrect
      +----------+
      | COUNT(*) |
      +----------+
      |        0 |
      +----------+
      1 row in set (0.001 sec)
      

      Testcase is CLI and MTR compatible. Adding COMMIT after the DROP TABLE makes no difference.

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              Roel Roel Van de Paar
              Roel Van de Paar 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.