ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result

Description

1 2 3 4 DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a DECIMAL(30,0)); INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); SELECT * FROM t1;

returns

1 2 3 4 5 +----------------------+ | a | +----------------------+ | 18446744073709551615 | +----------------------+

So far so good.

Now if I do:

1 2 ALTER TABLE t1 MODIFY a BIGINT UNSIGNED; SELECT * FROM t1;

it erroneously returns:

1 2 3 4 5 +---------------------+ | a | +---------------------+ | 9223372036854775807 | +---------------------+

The expected result is 18446744073709551615.

Environment

None

Status

Assignee

Alexander Barkov

Reporter

Alexander Barkov

Labels

None

External issue ID

None

External issue ID

None

Components

Fix versions

Affects versions

10.0
10.1
5.5
10.2

Priority

Major