[MDEV-10304] CAST(string_expr AS SIGNED) does not understand scientific notation Created: 2016-06-29  Updated: 2016-06-29

Status: Open
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0, 10.1, 10.2
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Explicit cast from string to DOUBLE and DECIMAL understands scientific number notation.
Explicit cast from string to SIGNED and UNSIGNED does not understand.

SELECT CAST('1.9e19' AS DOUBLE) AS c1,
       CAST('1.9e19' AS DECIMAL(30,1)) AS c2,
       CAST('1.9e19' AS SIGNED) AS c3,
       CAST('1.9e19' AS UNSIGNED) AS c4;

+--------+------------------------+----+----+
| c1     | c2                     | c3 | c4 |
+--------+------------------------+----+----+
| 1.9e19 | 19000000000000000000.0 |  1 |  1 |
+--------+------------------------+----+----+

SELECT COLUMN_GET(COLUMN_CREATE(0, '1.9e19'), 0 AS DOUBLE) AS c1,
       COLUMN_GET(COLUMN_CREATE(0, '1.9e19'), 0 AS DECIMAL(30,1)) AS c2,
       COLUMN_GET(COLUMN_CREATE(0, '1.9e19'), 0 AS SIGNED) AS c3,
       COLUMN_GET(COLUMN_CREATE(0, '1.9e19'), 0 AS UNSIGNED) AS c4;

+--------+------------------------+------+------+
| c1     | c2                     | c3   | c4   |
+--------+------------------------+------+------+
| 1.9e19 | 19000000000000000000.0 |    1 |    1 |
+--------+------------------------+------+------+

Note, implicit cast in INSERT understands scientific notation:

CREATE OR REPLACE TABLE t1 (a BIGINT);
INSERT INTO t1 VALUES ('1.9e19');
SELECT * FROM t1;

+---------------------+
| a                   |
+---------------------+
| 9223372036854775807 |
+---------------------+

Explicit CAST to SIGNED/UNSIGNED should be fixed to understand scientific notation.


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