flamerobin icon indicating copy to clipboard operation
flamerobin copied to clipboard

Incorrect representation of NUMERIC fields

Open mlazdans opened this issue 1 month ago • 3 comments

CREATE TABLE TESTN18
(
    ID INTEGER,
    NUMERIC_18 NUMERIC(18,18)
);
INSERT INTO TESTN18 (ID, NUMERIC_18) VALUES (100, 9.223372036854775807);
SELECT NUMERIC_18 FROM TESTN18 WHERE ID = 100;

Expected:

           NUMERIC_18
=====================
 9.223372036854775807

Actual: Image

Looks like internal conversion to float / double somewhere.

mlazdans avatar Nov 16 '25 13:11 mlazdans

When you edit a row and paste 9.223372036854775807 into NUMERIC_18 this will throw an error:

Image

Notice the 9.223372036854776468 in error.

mlazdans avatar Nov 16 '25 16:11 mlazdans

I can't see this in the next weeks, but asap I'll take a look By the way, it's strange that the simple update raised a error, can you copy the update and try in isql too?

arvanus avatar Nov 18 '25 12:11 arvanus

9.223372036854776468 via isql also raises an error:

Statement failed, SQLSTATE = 22003 arithmetic exception, numeric overflow, or string truncation -numeric value is out of range

which is expected because 9.223372036854775807 is maximum that will fit in numeric(18,18) which is signed int64: eg max 2^63-1 and min is -(2^63)

Not sure but it feels like there might be some float/double conversation somewhere in the middle. If so this is bad because one might lose precision even not at the edge cases like this one.

mlazdans avatar Nov 18 '25 13:11 mlazdans