Re: [RFC] Unsigned integer support. - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: [RFC] Unsigned integer support.
Date
Msg-id 87sktykz8h.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: [RFC] Unsigned integer support.  ("Ryan Bradetich" <rbradetich@gmail.com>)
Responses Re: [RFC] Unsigned integer support.  ("Ryan Bradetich" <rbradetich@gmail.com>)
Re: [RFC] Unsigned integer support.  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
"Ryan Bradetich" <rbradetich@gmail.com> writes:

> My plans for the example above would be:
>
>   1. SELECT 1500000000 + 1500000000  --> Throws overflow error.
>   2. SELECT 1500000000::uint4 + 1500000000 --> Returns 3000000000::uint4.

I think that wouldn't actually work. Postgres's parser immediately assigns a
type to the bare unquoted integral constant so it would end up with a int4
type. Then when it has to pick an operator for uint4+int4 it wouldn't be able
to cast the int4 to uint4 because there would be no implicit cast.

You could make it work by having a uint4+int4 operator which returns uint4 but
then you're going to need a *lot* of operators....

One other idea that's been mentioned before is treating integral constants
like 150000 as type "unknown" like the quoted '150000' constant is. That way
the parser would see uint4+unknown and could pick the uint4 operator. But that
would be a pretty massive semantics change.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!


pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Column level privileges was:(Re: Extending grant insert on tables to sequences)
Next
From: Peter Eisentraut
Date:
Subject: Re: [RFC] Unsigned integer support.