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

SELECT does not create a snapshot when the WHERE condition evaluates to false

    XMLWordPrintable

Details

    Description

      Isolation Level: Repeatable Read.
      The SELECT statement does not create a snapshot when the WHERE condition evaluates to false.

      /* init */ DROP TABLE IF EXISTS t;
      /* init */ CREATE TABLE t (c1 CHAR(1));
      /* init */ INSERT INTO t(c1) VALUES ('A');
       
      /* t1 */ BEGIN;
      /* t2 */ BEGIN;
      /* t2 */ SELECT * FROM t WHERE TIMESTAMPDIFF(MONTH,'2025-11-6','2025-11-11');
      /* t1 */ DELETE FROM t WHERE TRUE;
      /* t2 */ INSERT INTO t(c1) VALUES ('B'); -- blocked
      /* t1 */ COMMIT; -- t2 unblocked
      /* t2 */ SELECT * FROM t ; -- [('B')]
      /* t2 */ COMMIT;
      

      The expectation is that transaction t2 will establish a snapshot at the first SELECT statement, so that the second SELECT statement can retrieve [('A'), ('B')]. However, in actual execution, the second SELECT statement in transaction t2 only retrieved [('B')] when the WHERE condition of the first SELECT statement was evaluated as false.

      Attachments

        Activity

          People

            marko Marko Mäkelä
            John Jove John Jove
            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.