[MDEV-25174] DOUBLE columns do not accept large hex hybrids Created: 2021-03-17  Updated: 2021-04-13

Status: Open
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.5
Fix Version/s: 10.5

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-641 Full DECIMAL support in ColumnStore Closed
relates to MCOL-4361 Replace pow(10.0, (double)scale) expr... Closed

 Description   

DOUBLE columns accept hex hybrids only in the range 0x0000000000000000..x7FFFFFFFFFFFFFFF without problems:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF);
SELECT * FROM t1;

+----------------------+
| a                    |
+----------------------+
| 9.223372036854776e18 |
+----------------------+

Looks good so far.

Now let's try a larger value:

INSERT INTO t1 VALUES (0x8000000000000000);

ERROR 1264 (22003): Out of range value for column 'a' at row 1

Looks wrong. There should not be an error.
The same problem happens with all values in the range 0x8000000000000000..0xFFFFFFFFFFFFFFFF.

Note, an explicit CAST correctly handles these values:

SELECT
  CAST(0x8000000000000000 AS DOUBLE), 
  CAST(0xFFFFFFFFFFFFFFFF AS DOUBLE);

+------------------------------------+------------------------------------+
| CAST(0x8000000000000000 AS DOUBLE) | CAST(0xFFFFFFFFFFFFFFFF AS DOUBLE) |
+------------------------------------+------------------------------------+
|               9.223372036854776e18 |              1.8446744073709552e19 |
+------------------------------------+------------------------------------+


Generated at Thu Feb 08 09:35:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.