Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
Description
Simplification of Cast chained calls can lead to unexpected behaviour:
CAST(CAST(CAST(123456 AS TINYINT) AS INT) AS BIGINT)
is simplified to
CAST(123456 AS BIGINT)
and returns 123456 with BIGINT data type, where the first inner cast as TINYINT should already fail because the value is out of range.
For example, for PostgreSQL:
postgres=# select 123456::smallint::int::bigint; ERROR: smallint out of range