Hi, Is it intentional that this cast fails, even though the value fits in oid8?
SELECT 18446744073709551615::oid8;
ERROR: cannot cast type numeric to oid8
An integer literal this large is parsed as numeric, so the cast fails
because there is no numeric-to-oid8 cast. '18446744073709551615'::oid8
works.
The built-in signed integer types cannot represent the upper half of
oid8's range. Adding a numeric-to-oid8 cast would allow integer values
across that full range to be converted exactly. This would let N::oid8
work across the full range without changing how the value is written
when it exceeds INT64_MAX.
Attached is a patch adding an assignment cast. An implicit cast would
round fractional values in comparisons. For example,
SELECT 2::oid8 = 1.5;
would return true because 1.5 would be rounded to 2.
The earlier discussion says negative text input wraps around
intentionally [1]. The patch does the same for numeric input.
Comments welcome.
[1] https://www.postgresql.org/message-id/[email protected]
Koshi Shibagaki
FUJITSU LIMITED
https://www.fujitsu.com/
v1-0001-Add-an-assignment-cast-from-numeric-to-oid8.patch
Description: v1-0001-Add-an-assignment-cast-from-numeric-to-oid8.patch
