Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
Description
Implicit CAST from string to signed bigint truncates the number the to maximum possible 64-bit signed value:
DROP TABLE IF EXISTS t1; |
CREATE TABLE t1 (a BIGINT); |
INSERT INTO t1 VALUES ('99999999999999999999'); |
SELECT * FROM t1; |
+---------------------+
|
| a |
|
+---------------------+
|
| 9223372036854775807 |
|
+---------------------+
|
So does explicit CAST from DECIMAL to SIGNED:
SELECT CAST(99999999999999999999 AS SIGNED); |
+--------------------------------------+
|
| CAST(99999999999999999999 AS SIGNED) |
|
+--------------------------------------+
|
| 9223372036854775807 |
|
+--------------------------------------+
|
So does explicit CAST from DOUBLE to SIGNED:
SELECT CAST(99999999999999999999e0 AS SIGNED); |
+----------------------------------------+
|
| CAST(99999999999999999999e0 AS SIGNED) |
|
+----------------------------------------+
|
| 9223372036854775807 |
|
+----------------------------------------+
|
Explicit CAST from string to SIGNED works differently:
SELECT CAST('99999999999999999999' AS SIGNED); |
+----------------------------------------+
|
| CAST('99999999999999999999' AS SIGNED) |
|
+----------------------------------------+
|
| -1 |
|
+----------------------------------------+
|
This looks wrong. Explicit CAST from string to SIGNED should also return 9223372036854775807.