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

mysqldump restores a negative zero as a positive zero

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.1.67, 5.2.14, 5.3.12, 5.5, 10.0, 10.1
    • 10.1
    • Scripts & Clients

    Description

      Hello and thank you for MariaDB,

      While importing a database using mysqldump, I noticed table checksums were not the same, a diff on the mysqldump showed that negative zero values in a double field were represented as -0 in the mysqldump which was being imported as positive zero when the mysqldump was run using the mysql client.

      If I add the following to mysql-test/t/mysqldump_restore.test , notice to obtain a negative zero I enclose it in quotes:

      --echo #
      --echo # Negative zero
      --echo #
      CREATE TABLE t1 (a double);
      INSERT INTO t1 VALUES ('-0');
      --exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile
      let $table_name = test.t1;
      --source include/mysqldump.inc

      and then run:

      ./mysql-test-run mysqldump_restore
      ...
      # Recreate table from mysqldump output
      # Compare original and recreated tables
      # Recreated table: test.t1
      # Original table: test.t1_orig
      include/diff_tables.inc [test.t1, test.t1_orig]
      --- mysql-test/var/mysqld.1/data//diff_table--test-t1   2015-10-09 07:51:27.890186982 -0400
      +++ mysql-test/var/mysqld.1/data//diff_table--test-t1_orig      2015-10-09 07:51:27.918591757 -0400
      @@ -1 +1 @@
      -0
      +-0

      I suspect in the case of the data being worked on that the negative zero was written as a string in error, and had it been numeric then it would have been stored as positive zero and we would have not seen a difference between the original and restored data.

      I am not sure if test_if_special_chars in client/mysqldump.c could return 1 if passed "-0", or if INSERT -0 should be expected to store a negative zero.

      Thank you.

      Attachments

        Activity

          People

            bar Alexander Barkov
            thatsafunnyname Peter (Stig) Edwards
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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