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

Triggers can't see DEFAULT values

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Won't Fix
    • 5.1.67, 5.2.14, 5.3.12, 5.5.36, 10.0.8
    • None
    • None

    Description

      I spoke about this in the list moths ago, but I forgot to file a bug.

      Try the following code:

      DROP TABLE IF EXISTS t;
      CREATE TABLE t (a INT DEFAULT 999) ENGINE = InnoDB;
      DELIMITER ||
      CREATE TRIGGER t_bi
      	BEFORE INSERT
      	ON t
      	FOR EACH ROW
      BEGIN
      	SET NEW.a = DEFAULT;
      END;
      ||
      DELIMITER ;
      INSERT INTO t VALUES (0);
      SELECT * FROM t;

      I get no errors, but t.a is NULL (which would be ok if a.t had no default value).

      Since I'm not sure about the syntax, I tried DEFAULT(a) and DEFAULT(t.a), but in both cases I got an error. I have no idea if the errors are expected or not, but as far as I understand the syntax in the example should work.

      Attachments

        Activity

          People

            Unassigned Unassigned
            f_razzoli Federico Razzoli
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.