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

Float value -0 gets replicated as 0 and hashes dont match

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Duplicate
    • 10.6.15
    • N/A
    • Replication
    • None
    • Not for Release Notes

    Description

      There's funny value -0 you get when you try to represent tiny negative value as float or double.

      select cast(-1e-100 as float), cast(-1e-400 as double);

      cast(-1e-100 as float) cast(-1e-400 as double)
      -0 -0

      You cannot get it directly though, I assume it gets autocorrected to 0 most of the time.

      select -0;

      -0
      0

      It can be stored in table, some clients will show it as 0, some client will show it as -0.

      create table foo(a float);
      insert into foo values(-1e-100);
      select a from foo;

      a
      -0

      Mariadb considers 0 and -0 to be equal, not negative not positive, zero-like number.

      select a, a<0, a>0, a=0, a=-0, a=cast(-1e-100 as float) from foo;

      a a<0 a>0 a=0 a=-0 a=cast(-1e-100 as float)
      -0 0 0 1 1 1

      It can be replaced with 0:

      update foo set a=0 where a=-0;
      select a from foo;

      a
      0

      However 0 cannot be replaced with -0 the same way

      update foo set a=-0 where a=0;
      select a from foo;

      a
      0

      Mysqldump dumps it as -0, but if you try to restore it from dump it will become 0.

      I dont mind any of this except it breaks replication because -0 end up as 0 and hashes dont match.

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              mugiseyebrows Stanislav Doronin
              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.