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

Sometimes triggers are not invoked by LOAD DATA

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Cannot Reproduce
    • 10.0.21, 10.0.21-galera
    • N/A
    • Triggers

    Description

      In MySQL docs:

      https://dev.mysql.com/doc/refman/5.6/en/create-trigger.html

      I read:
      "INSERT: The trigger activates whenever a new row is inserted into the table; for example, through INSERT, LOAD DATA, and REPLACE statements."

      In MariaDB, it doesn't seem to be always the case. I didn't try all types of triggers, or all versions, or MySQL. But see this test case.

      MariaDB [test]> \! cat /tmp/test.csv
      1,2,3
      4,5,6
      7,8,9
       
      SET @trigger_invocations := 0;
       
      USE test;
       
      CREATE OR REPLACE TABLE t (
              a INT,
              b INT,
              c INT
      )
              ENGINE = MyISAM
      ;
       
      DELIMITER ||
       
      CREATE TRIGGER t_ai
              AFTER INSERT
              ON t
              FOR EACH ROW
      BEGIN
              SET @trigger_invocations := @trigger_invocations + 1;
      END ||
       
      DELIMITER ;
       
      LOAD DATA LOCAL INFILE '/tmp/test.csv'
              INTO TABLE t
              FIELDS TERMINATED BY ','
      ;
       
      SELECT @trigger_invocations;

      Attachments

        Activity

          People

            Unassigned Unassigned
            f_razzoli Federico Razzoli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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