By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
-- smallint
SELECT -32768::int2; -- fails
ERROR: smallint out of range
-- integer
SELECT -2147483648::int4; -- fails
ERROR: integer out of range
-- bigint
SELECT -9223372036854775808::int8; -- fails
ERROR: bigint out of range
-- these work: :)
SELECT '-32768'::int2
, '-2147483648'::int4
, '-9223372036854775808'::int8;
int2 | int4 | int8 |
---|---|---|
-32768 | -2147483648 | -9223372036854775808 |
-- Why? Operator precedence. To emphasize what happens:
-- +2147483648 is out of range, as the range is -2147483648 to 2147483647
SELECT - (2147483648::int4);
ERROR: integer out of range