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

CAST(SUM(double_field) AS SIGNED) returns a wrong result

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 5.5.36, 10.0.9
    • N/A
    • Data types
    • None

    Description

      This SQL script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DOUBLE);
      INSERT INTO t1 VALUES (1e30);
      SELECT SUM(a), CAST(SUM(a) AS SIGNED) FROM t1;

      returns a wrong result for CAST(SUM(a) AS SIGNED):

      +--------+------------------------+
      | SUM(a) | CAST(SUM(a) AS SIGNED) |
      +--------+------------------------+
      |   1e30 |   -9223372036854775808 |
      +--------+------------------------+

      The expected result is +9223372036854775807,
      which is the maximum possible positive signed integer value.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            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.