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

Wrong timestamps on restore from mysqldump --compact

Details

    Description

      Reproduce

      1. Set system timezone to UTC+3
      2.

      create or replace table d (t timestamp);
      insert into d values ('2000-01-01 00:00');
      

      3.

      mysqldump --compact test d > /tmp/dump.sql
      

      4.

      drop table d;
      source /tmp/dump.sql
      select * from d;
      

      Result

      Data is different from original:

      +---------------------+
      | t                   |
      +---------------------+
      | 1999-12-31 22:00:00 |
      +---------------------+
      

      Expected

      mysqldump and subsequent restore should be idempotent without any additional manipulations.

      Fix

      mysqldump must insert correct SET time_zone directive regardless --compact setting. In case when opt_tz_utc is 0 it must detect server timezone as well.

      Attachments

        Issue Links

          Activity

            midenok Aleksey Midenkov added a comment - - edited

            Testing

            main.mysqldump, main.mysqldump-no-binlog fail on Windows:

            mysqldump.exe: Couldn't find table: "non_existing"
            mysqldump.exe: Got error: 1356: "View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" when using LOCK TABLES
            

            --- D:/win32-debug/build/src/mysql-test/main/mysqldump-no-binlog.result	2018-07-11 11:59:13.915781400 +0000
            +++ D:\win32-debug\build\src\mysql-test\main\mysqldump-no-binlog.reject	2018-07-11 12:44:58.356747300 +0000
            @@ -1,3 +1,3 @@
            -mysqldump: Error: Binlogging on server not active
             /*!40103 SET @OLD_TIME_ZONE      = @@time_zone */ ;
             /*!40103 SET time_zone             = '+00:00' */ ;
            +mysqldump: Error: Binlogging on server not active
            

            midenok Aleksey Midenkov added a comment - - edited Testing main.mysqldump, main.mysqldump-no-binlog fail on Windows: mysqldump.exe: Couldn't find table: "non_existing" mysqldump.exe: Got error: 1356: "View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" when using LOCK TABLES --- D:/win32-debug/build/src/mysql-test/main/mysqldump-no-binlog.result 2018-07-11 11:59:13.915781400 +0000 +++ D:\win32-debug\build\src\mysql-test\main\mysqldump-no-binlog.reject 2018-07-11 12:44:58.356747300 +0000 @@ -1,3 +1,3 @@ -mysqldump: Error: Binlogging on server not active /*!40103 SET @OLD_TIME_ZONE = @@time_zone */ ; /*!40103 SET time_zone = '+00:00' */ ; +mysqldump: Error: Binlogging on server not active
            midenok Aleksey Midenkov added a comment - - edited

            main.mysqldump-no-binlog failure is caused by MDEV-16752.

            midenok Aleksey Midenkov added a comment - - edited main.mysqldump-no-binlog failure is caused by MDEV-16752 .

            I'm not sure I agree it's a bug.

            SET time_zone is disabled by --compact apparently quite intentionally. So is SET NAMES, that is if you change the server's character set, the dump in --compact will not corrupt the data just the same.

            I guess you need this fix to use mysqldump in tests with timestamps and without comments (to have a stable output). Perhaps you should use --skip-comments instead of --compact ?

            serg Sergei Golubchik added a comment - I'm not sure I agree it's a bug. SET time_zone is disabled by --compact apparently quite intentionally. So is SET NAMES , that is if you change the server's character set, the dump in --compact will not corrupt the data just the same. I guess you need this fix to use mysqldump in tests with timestamps and without comments (to have a stable output). Perhaps you should use --skip-comments instead of --compact ?

            I'm disabling dump history for --compact mode then.

            midenok Aleksey Midenkov added a comment - I'm disabling dump history for --compact mode then.

            People

              midenok Aleksey Midenkov
              midenok Aleksey Midenkov
              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.