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

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

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.5.36, 10.0.9
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:
      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.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: