From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Jack Bay <jack(dot)victor(dot)bay(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Support for unsigned integer types |
Date: | 2024-12-27 01:47:19 |
Message-ID: | Z24HJ9WebpC3Tv7v@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Dec 7, 2024 at 11:24:37AM -0500, Tom Lane wrote:
> Jack Bay <jack(dot)victor(dot)bay(at)gmail(dot)com> writes:
> > Would it be possible to add support for unsigned 64-bit and unsigned
> > 32-bit integers to postgresql?
>
> This has been discussed before, and we've concluded that the impact
> on the numeric promotion hierarchy (that is, implicit-cast rules
> among the integer types) would probably be catastrophic, leading
> to problems like ambiguous-operator errors in many cases that were
> fine before. Quick, is "42 + 1" an int32 or uint32 operation?
>
> That could be avoided perhaps by measures like not having any
> implicit casts between the int and uint hierarchies, but then
> there'd be a corresponding loss of usability for the uint types.
>
> Plus, the sheer magnitude of effort needed to build out a reasonable
> set of support (functions, operators, opclasses) for uint types seems
> daunting.
>
> On the flip side, it'd be great to be able to use uint32 instead
> of bigint for the SQL representation of types like BlockNumber.
> But we couldn't roll in such a change transparently unless we make
> int-vs-uint casting fairly transparent, which seems problematic
> as per above.
>
> Perhaps a sufficiently determined and creative person could put
> together a patch that'd be accepted, but it'd be a lot of work
> for uncertain reward. I'm not aware that anyone is working on
> such a thing at present.
We do have the 'oid' data type, which is an unsigned 4-byte integer, but
it lacks the casts and operator support mentioned above:
SELECT 42 + 1;
?column?
----------
43
SELECT 42::oid + 1;
ERROR: operator does not exist: oid + integer
LINE 1: SELECT 42::oid + 1;
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
SELECT 42::oid + 1::oid;
ERROR: operator does not exist: oid + oid
LINE 1: SELECT 42::oid + 1::oid;
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
Do not let urgent matters crowd out time for investment in the future.
From | Date | Subject | |
---|---|---|---|
Next Message | wenhui qiu | 2024-12-27 02:04:48 | Re: PoC: history of recent vacuum/checkpoint runs (using new hooks) |
Previous Message | Andrei Lepikhov | 2024-12-27 01:34:00 | Re: Add Postgres module info |