MySQL version: 5.5.38-0ubuntu0.14.04.1
Table structure:
CREATE TABLE `route_points2` (
`dist` tinyint(4) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Data: 1 row with dist
equal to 200
Sql:
SELECT * FROM route_points2 WHERE -1*dist < 1;
Error:
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(<cache>(-(1)) * `db_name`.`route_points2`.`dist`)'
Why mysql casts -1*dist
to BIGINT UNSIGNED
?
The error above can be solved by casting dist
to SIGNED
:
SELECT * FROM route_points2 WHERE -1*CAST(dist AS SIGNED) < 1;
And this works fine.
But I do not understand why mysql chose BIGINT UNSIGNED
for -1*dist