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

Wrong result for whole-row OLD in trigger on table with virtual columns: OLD = (...) returns NULL

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 13.2, 13.3
    • 13.3
    • Triggers
    • None
    • Can result in unexpected behaviour

    Description

      CREATE TABLE t (id INT PRIMARY KEY, a INT, b VARCHAR(10), c INT AS (a * 10) VIRTUAL, d VARCHAR(20) AS (CONCAT(b, '!')) VIRTUAL);
      INSERT INTO t (id, a, b) VALUES (1, 1, 'b1');
      CREATE TRIGGER t_bd BEFORE DELETE ON t FOR EACH ROW SET @v = (OLD = (1, 1, 'b1', 10, 'b1!'));
      DELETE FROM t WHERE id = 1;
      SELECT @v;  -- NULL
      

      CLI Output

      13.2.0-opt>CREATE TABLE t (id INT PRIMARY KEY, a INT, b VARCHAR(10), c INT AS (a * 10) VIRTUAL, d VARCHAR(20) AS (CONCAT(b, '!')) VIRTUAL);
      Query OK, 0 rows affected (0.009 sec)
       
      13.2.0-opt>INSERT INTO t (id, a, b) VALUES (1, 1, 'b1');
      Query OK, 1 row affected (0.001 sec)
       
      13.2.0-opt>CREATE TRIGGER t_bd BEFORE DELETE ON t FOR EACH ROW SET @v = (OLD = (1, 1, 'b1', 10, 'b1!'));
      Query OK, 0 rows affected (0.005 sec)
       
      13.2.0-opt>DELETE FROM t WHERE id = 1;
      Query OK, 1 row affected (0.001 sec)
       
      13.2.0-opt>SELECT @v;  # Expected 1, got NULL
      +------+
      | @v   |
      +------+
      | NULL |
      +------+
      1 row in set (0.000 sec)
       
      13.2.0-opt>
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 10m
                  10m

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.