Re: [HACKERS] int8 size - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] int8 size
Date
Msg-id 3641D16E.FA29AB9E@alumni.caltech.edu
Whole thread Raw
In response to int8 size  (Sferacarta Software <sferac@bo.nettuno.it>)
List pgsql-hackers
> I'm trying to guess the size of int8...
> 
> hygea=> insert into b values (9223372036854775296);
> NOTICE:  Integer input '9223372036854775296' is out of range; promoted to float
> ERROR:  Floating point conversion to int64 is out of range

Try insert into b values ('9223372036854775296'::int8);

Otherwise the Postgres parser tries to read it as a number first, can't
do it as an int4, so forces it to float8, and then fails to convert back
to int64. The User's Guide talks about int8 and mentions that it allows
more than 18 decimal places, but isn't as specific as you might like.
The actual limit is probably +/- (2^63)-1

Hmm. On my linux/libc5 box, the number seems to peg at the top no matter
how big the input:

tgl=> select '9223372036854775296'::int8;
-------------------
9223372036854775296

tgl=> select '10000000000000000000'::int8;
-------------------
9223372036854775807

tgl=> select '100000000000000000000'::int8;
-------------------
9223372036854775807

Not so good...
                  - Tom


pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Re: bug on aggregate function AVG()
Next
From: Constantin Teodorescu
Date:
Subject: crypt not included when compiling libpgtcl !!!!!!!