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

MIN()/MAX() over BIGINT UNSIGNED loses the UNSIGNED flag when converted to a float

    XMLWordPrintable

Details

    • Unexpected results

    Description

      The following scripts demonstrate this inconsistency, which might be unexpected

      CREATE TABLE t (sh BIGINT UNSIGNED, g INT);
      INSERT INTO t VALUES (18446744073709551588, 1);   -- 2^64 - 28
       
      SELECT MIN(sh)                  FROM t;   -- 18446744073709551588        correct
      SELECT CAST(sh AS DOUBLE)       FROM t;   -- 1.8446744073709552e+19      correct (no aggregate)
      SELECT CAST(MIN(sh) AS DOUBLE)  FROM t;   -- -28.0                       WRONG
      SELECT MIN(sh) + 0e0            FROM t;   -- -28.0                       WRONG (no CAST needed)
      SELECT SQRT(MIN(sh))            FROM t;   -- NULL   (expected 4294967296) WRONG
      

      Attachments

        Activity

          People

            raghunandan.bhat Raghunandan Bhat
            jesse0623 Junwen An
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Remaining Estimate - 2d
                2d
                Logged:
                Time Spent - Not Specified
                Not Specified

                Git Integration

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