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

Incorrect time returned by now() in trigger, in replication

    XMLWordPrintable

Details

    Description

      We have setup a replication from MySQL Master, to MariaDB.
      if we perform "select now();" in mysql console, both master and mariadb return correct time.

      However, the now() in trigger is incorrect.
      (Remarks: the timezone in Mariadb is "US/Eastern", the timezone in MySQL is "America/New_York")

      ------------------------------------------------------------------------------------
      Here is the script to reproduce the bug:

      select now();
      /*both mysql and mariadb return '2016-09-07 22:09:47' */
       
      /*In mysql: */
      CREATE TABLE `table_a` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `price` int(11) NOT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB;
       
      CREATE TABLE `table_a_log` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `price` int(11) NOT NULL,
        `logged_at` datetime NOT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB;
       
      DELIMITER ;;
      CREATE TRIGGER table_a_trigger AFTER UPDATE ON table_a
        FOR EACH ROW
        BEGIN
            INSERT INTO table_a_log (id, price, logged_at)
            VALUES (NEW.id, NEW.price, NOW());
        END;;
      DELIMITER ;
       
      insert into table_a(id, price) values (90, 9999);
      update table_a set price = 8888;
      

      Result

      The table_a_log in mysql has time '2016-09-07 22:09:47'.
      The table_a_log in mariadb has time '2016-09-08 02:09:47'.
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Triton Ho Triton Ho
            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.