[MDEV-5911] CAST(SUM(double_field) AS SIGNED) returns a wrong result Created: 2014-03-20  Updated: 2022-11-01  Resolved: 2022-11-01

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 5.5.36, 10.0.9
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
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.



 Comments   
Comment by Sergei Golubchik [ 2022-11-01 ]

fixed somewhere before 10.3.37

Generated at Thu Feb 08 07:07:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.