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

SET TRANSACTION READ ONLY executed in a function has no effect

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      I found this while writing a test case for MDEV-39542:

      --source include/have_innodb.inc
       
      --echo #
      --echo # MDEV-39542 Assertion failed in trx_flush_log_if_needed()
      --echo #
      CREATE TABLE t (id INT) ENGINE=InnoDB;
      INSERT INTO t VALUES (1),(2),(3);
      --delimiter //
      CREATE FUNCTION f(i INT) RETURNS INT
      BEGIN
      SET TRANSACTION READ ONLY;
      RETURN i;
      END //
       
      --error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
      CREATE FUNCTION g(i INT) RETURNS INT
      BEGIN
      START TRANSACTION READ ONLY;
      RETURN i;
      END //
       
      --delimiter ;
      DELETE FROM t WHERE id=f(1);
      # FIXME: The SET TRANSACTION READ ONLY in f(1) was ignored!
      DELETE FROM t WHERE id=2;
      SET TRANSACTION READ ONLY;
      --error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
      DELETE FROM t WHERE id=3;
      SELECT * FROM t;
      DROP FUNCTION f;
      DROP TABLE t;
      

      Based on the documentation of SET TRANSACTION READ ONLY, the expected result is that only the first DELETE will execute, and both the second and third DELETE would fail in the same way.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.