public inbox for [email protected]
help / color / mirror / Atom feedINTEGER range ("-2147483648" is not accepted.)
14+ messages / 7 participants
[nested] [flat]
* INTEGER range ("-2147483648" is not accepted.)
@ 2010-06-22 08:27 Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 08:44 ` Re: INTEGER range ("-2147483648" is not accepted.) Magnus Hagander <[email protected]>
0 siblings, 2 replies; 14+ messages in thread
From: Satoshi Nagayasu @ 2010-06-22 08:27 UTC (permalink / raw)
To: pgsql-docs
Hi all,
I've found a bit strange thing on the INTEGER range in the official manual.
http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
However, my example in below shows that "-2147483648" is not accepted.
Is this correct? Any suggestions?
Regards,
---------------------------------------------------------------------
template1=# SELECT version();
version
------------------------------------------------------------------------------------------------------------
PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42), 32-bit
(1 row)
template1=# SELECT -2147483647::integer;
?column?
-------------
-2147483647
(1 row)
template1=# SELECT -2147483648::integer;
ERROR: integer out of range
template1=# SELECT +2147483648::integer;
ERROR: integer out of range
template1=# SELECT +2147483647::integer;
?column?
------------
2147483647
(1 row)
template1=#
---------------------------------------------------------------------
--
NAGAYASU Satoshi <[email protected]>
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
@ 2010-06-22 08:36 ` Thom Brown <[email protected]>
2010-06-22 23:07 ` Re: INTEGER range ("-2147483648" is not accepted.) David Fetter <[email protected]>
1 sibling, 1 reply; 14+ messages in thread
From: Thom Brown @ 2010-06-22 08:36 UTC (permalink / raw)
To: Satoshi Nagayasu <[email protected]>; +Cc: pgsql-docs
2010/6/22 Satoshi Nagayasu <[email protected]>:
> Hi all,
>
> I've found a bit strange thing on the INTEGER range in the official manual.
>
> http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
>
> According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
> However, my example in below shows that "-2147483648" is not accepted.
>
> Is this correct? Any suggestions?
>
> Regards,
>
> ---------------------------------------------------------------------
> template1=# SELECT version();
> version
> ------------------------------------------------------------------------------------------------------------
> PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42), 32-bit
> (1 row)
>
> template1=# SELECT -2147483647::integer;
> ?column?
> -------------
> -2147483647
> (1 row)
>
> template1=# SELECT -2147483648::integer;
> ERROR: integer out of range
> template1=# SELECT +2147483648::integer;
> ERROR: integer out of range
> template1=# SELECT +2147483647::integer;
> ?column?
> ------------
> 2147483647
> (1 row)
>
> template1=#
> ---------------------------------------------------------------------
>
Hmm... yes, that's not what I'd expect either:
postgres=# SELECT -32768::smallint;
ERROR: smallint out of range
postgres=# SELECT -9223372036854775808::bigint;
ERROR: bigint out of range
I think those min values are all out by 1.
Thom
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
@ 2010-06-22 23:07 ` David Fetter <[email protected]>
2010-06-22 23:16 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: David Fetter @ 2010-06-22 23:07 UTC (permalink / raw)
To: Thom Brown <[email protected]>; +Cc: Satoshi Nagayasu <[email protected]>; pgsql-docs
On Tue, Jun 22, 2010 at 09:36:30AM +0100, Thom Brown wrote:
> 2010/6/22 Satoshi Nagayasu <[email protected]>:
> > Hi all,
> >
> > I've found a bit strange thing on the INTEGER range in the official manual.
> >
> > http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
> >
> > According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
> > However, my example in below shows that "-2147483648" is not accepted.
> >
> > Is this correct? Any suggestions?
> >
> > Regards,
> >
> > ---------------------------------------------------------------------
> > template1=# SELECT version();
> > version
> > ------------------------------------------------------------------------------------------------------------
> > PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42), 32-bit
> > (1 row)
> >
> > template1=# SELECT -2147483647::integer;
> > ?column?
> > -------------
> > -2147483647
> > (1 row)
> >
> > template1=# SELECT -2147483648::integer;
> > ERROR: integer out of range
> > template1=# SELECT +2147483648::integer;
> > ERROR: integer out of range
> > template1=# SELECT +2147483647::integer;
> > ?column?
> > ------------
> > 2147483647
> > (1 row)
> >
> > template1=#
> > ---------------------------------------------------------------------
> >
>
> Hmm... yes, that's not what I'd expect either:
>
> postgres=# SELECT -32768::smallint;
> ERROR: smallint out of range
> postgres=# SELECT -9223372036854775808::bigint;
> ERROR: bigint out of range
>
> I think those min values are all out by 1.
Nope. Same problem.
SELECT (-32768)::smallint;
-32768
SELECT (-9223372036854775808)::bigint;
-9223372036854775808
I agree that the appropriate error message should complain about the
actual error, which is that 32768, or 2147483648, or
9223372036854775808, as the case may be, is out of range in the
positive direction. Possibly the "hint" might mention that :: binds
tighter than - does.
Cheers,
David.
--
David Fetter <[email protected]> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: [email protected]
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 23:07 ` Re: INTEGER range ("-2147483648" is not accepted.) David Fetter <[email protected]>
@ 2010-06-22 23:16 ` Thom Brown <[email protected]>
2010-06-23 01:49 ` Re: INTEGER range ("-2147483648" is not accepted.) Tom Lane <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Thom Brown @ 2010-06-22 23:16 UTC (permalink / raw)
To: David Fetter <[email protected]>; +Cc: Satoshi Nagayasu <[email protected]>; pgsql-docs
On 23 June 2010 00:07, David Fetter <[email protected]> wrote:
> On Tue, Jun 22, 2010 at 09:36:30AM +0100, Thom Brown wrote:
>> 2010/6/22 Satoshi Nagayasu <[email protected]>:
>> > Hi all,
>> >
>> > I've found a bit strange thing on the INTEGER range in the official manual.
>> >
>> > http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
>> >
>> > According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
>> > However, my example in below shows that "-2147483648" is not accepted.
>> >
>> > Is this correct? Any suggestions?
>> >
>> > Regards,
>> >
>> > ---------------------------------------------------------------------
>> > template1=# SELECT version();
>> > version
>> > ------------------------------------------------------------------------------------------------------------
>> > PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42), 32-bit
>> > (1 row)
>> >
>> > template1=# SELECT -2147483647::integer;
>> > ?column?
>> > -------------
>> > -2147483647
>> > (1 row)
>> >
>> > template1=# SELECT -2147483648::integer;
>> > ERROR: integer out of range
>> > template1=# SELECT +2147483648::integer;
>> > ERROR: integer out of range
>> > template1=# SELECT +2147483647::integer;
>> > ?column?
>> > ------------
>> > 2147483647
>> > (1 row)
>> >
>> > template1=#
>> > ---------------------------------------------------------------------
>> >
>>
>> Hmm... yes, that's not what I'd expect either:
>>
>> postgres=# SELECT -32768::smallint;
>> ERROR: smallint out of range
>> postgres=# SELECT -9223372036854775808::bigint;
>> ERROR: bigint out of range
>>
>> I think those min values are all out by 1.
>
> Nope. Same problem.
>
> SELECT (-32768)::smallint;
> -32768
>
> SELECT (-9223372036854775808)::bigint;
> -9223372036854775808
>
> I agree that the appropriate error message should complain about the
> actual error, which is that 32768, or 2147483648, or
> 9223372036854775808, as the case may be, is out of range in the
> positive direction. Possibly the "hint" might mention that :: binds
> tighter than - does.
>
Is that the right behaviour though? Shouldn't the signed value reach
the cast step rather than the absolute value? Or maybe Postgres could
implicitly accept -12345::integer to be (-12345)::integer. Is there a
blocking reason as to why it must work this way? Am I asking too many
questions? Was that last question necessary?
Thom
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 23:07 ` Re: INTEGER range ("-2147483648" is not accepted.) David Fetter <[email protected]>
2010-06-22 23:16 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
@ 2010-06-23 01:49 ` Tom Lane <[email protected]>
2010-06-23 08:17 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-23 14:29 ` Re: INTEGER range ("-2147483648" is not accepted.) Mike Toews <[email protected]>
0 siblings, 2 replies; 14+ messages in thread
From: Tom Lane @ 2010-06-23 01:49 UTC (permalink / raw)
To: Thom Brown <[email protected]>; +Cc: David Fetter <[email protected]>; Satoshi Nagayasu <[email protected]>; pgsql-docs
Thom Brown <[email protected]> writes:
> Is that the right behaviour though? Shouldn't the signed value reach
> the cast step rather than the absolute value? Or maybe Postgres could
> implicitly accept -12345::integer to be (-12345)::integer. Is there a
> blocking reason as to why it must work this way?
Yes. There is no reason to assume that - means the same thing for every
datatype. In general, :: should (and does) bind tighter than *every*
operator, to ensure that the appropriately typed operator is applied.
regards, tom lane
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 23:07 ` Re: INTEGER range ("-2147483648" is not accepted.) David Fetter <[email protected]>
2010-06-22 23:16 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-23 01:49 ` Re: INTEGER range ("-2147483648" is not accepted.) Tom Lane <[email protected]>
@ 2010-06-23 08:17 ` Thom Brown <[email protected]>
1 sibling, 0 replies; 14+ messages in thread
From: Thom Brown @ 2010-06-23 08:17 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: David Fetter <[email protected]>; Satoshi Nagayasu <[email protected]>; pgsql-docs
On 23 June 2010 02:49, Tom Lane <[email protected]> wrote:
> Thom Brown <[email protected]> writes:
>> Is that the right behaviour though? Shouldn't the signed value reach
>> the cast step rather than the absolute value? Or maybe Postgres could
>> implicitly accept -12345::integer to be (-12345)::integer. Is there a
>> blocking reason as to why it must work this way?
>
> Yes. There is no reason to assume that - means the same thing for every
> datatype. In general, :: should (and does) bind tighter than *every*
> operator, to ensure that the appropriately typed operator is applied.
>
Okay. I'll admit that this won't be a common case, but could the
error message make reference to the value it took?
Thom
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 23:07 ` Re: INTEGER range ("-2147483648" is not accepted.) David Fetter <[email protected]>
2010-06-22 23:16 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-23 01:49 ` Re: INTEGER range ("-2147483648" is not accepted.) Tom Lane <[email protected]>
@ 2010-06-23 14:29 ` Mike Toews <[email protected]>
2010-06-23 15:06 ` Re: INTEGER range ("-2147483648" is not accepted.) Robert Haas <[email protected]>
1 sibling, 1 reply; 14+ messages in thread
From: Mike Toews @ 2010-06-23 14:29 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Thom Brown <[email protected]>; David Fetter <[email protected]>; Satoshi Nagayasu <[email protected]>; pgsql-docs
On 22 June 2010 18:49, Tom Lane <[email protected]> wrote:
> Thom Brown <[email protected]> writes:
>> Is that the right behaviour though? Shouldn't the signed value reach
>> the cast step rather than the absolute value? Or maybe Postgres could
>> implicitly accept -12345::integer to be (-12345)::integer. Is there a
>> blocking reason as to why it must work this way?
>
> Yes. There is no reason to assume that - means the same thing for every
> datatype. In general, :: should (and does) bind tighter than *every*
> operator, to ensure that the appropriately typed operator is applied.
>
Sorry for adding to the non-DOC drift, but why is - assumed to be a
unary operator on an unsigned integer, rather than parsed as part of
an integer? Integers have digits with an optional - or + prefix (not
unary operators). E.g., ([+\-]?[0-9]+)
-Mike
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 23:07 ` Re: INTEGER range ("-2147483648" is not accepted.) David Fetter <[email protected]>
2010-06-22 23:16 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-23 01:49 ` Re: INTEGER range ("-2147483648" is not accepted.) Tom Lane <[email protected]>
2010-06-23 14:29 ` Re: INTEGER range ("-2147483648" is not accepted.) Mike Toews <[email protected]>
@ 2010-06-23 15:06 ` Robert Haas <[email protected]>
0 siblings, 0 replies; 14+ messages in thread
From: Robert Haas @ 2010-06-23 15:06 UTC (permalink / raw)
To: Mike Toews <[email protected]>; +Cc: Tom Lane <[email protected]>; Thom Brown <[email protected]>; David Fetter <[email protected]>; Satoshi Nagayasu <[email protected]>; pgsql-docs
On Wed, Jun 23, 2010 at 10:29 AM, Mike Toews <[email protected]> wrote:
> On 22 June 2010 18:49, Tom Lane <[email protected]> wrote:
>> Thom Brown <[email protected]> writes:
>>> Is that the right behaviour though? Shouldn't the signed value reach
>>> the cast step rather than the absolute value? Or maybe Postgres could
>>> implicitly accept -12345::integer to be (-12345)::integer. Is there a
>>> blocking reason as to why it must work this way?
>>
>> Yes. There is no reason to assume that - means the same thing for every
>> datatype. In general, :: should (and does) bind tighter than *every*
>> operator, to ensure that the appropriately typed operator is applied.
>>
>
> Sorry for adding to the non-DOC drift, but why is - assumed to be a
> unary operator on an unsigned integer, rather than parsed as part of
> an integer? Integers have digits with an optional - or + prefix (not
> unary operators). E.g., ([+\-]?[0-9]+)
You can't assume that a dash followed by digits is always a negative
number. Consider:
SELECT 10-4;
If you we interpret this as "10" followed by "-4", it's a syntax
error. You have to treat it as a separate token and work out later
whether it's a binary operator or a prefix operator.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
@ 2010-06-22 08:44 ` Magnus Hagander <[email protected]>
2010-06-22 08:48 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
1 sibling, 1 reply; 14+ messages in thread
From: Magnus Hagander @ 2010-06-22 08:44 UTC (permalink / raw)
To: Satoshi Nagayasu <[email protected]>; +Cc: pgsql-docs
On Tue, Jun 22, 2010 at 10:27 AM, Satoshi Nagayasu
<[email protected]> wrote:
> Hi all,
>
> I've found a bit strange thing on the INTEGER range in the official manual.
>
> http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
>
> According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
> However, my example in below shows that "-2147483648" is not accepted.
>
> Is this correct? Any suggestions?
>
> template1=# SELECT -2147483648::integer;
> ERROR: integer out of range
This gets parsed as "cast 2147483648 to integer, then take it
negative". Which overflows, because it can only go up to 2147483647.
What you want is:
postgres=# select (-2147483648)::integer;
int4
-------------
-2147483648
(1 row)
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:44 ` Re: INTEGER range ("-2147483648" is not accepted.) Magnus Hagander <[email protected]>
@ 2010-06-22 08:48 ` Thom Brown <[email protected]>
2010-06-22 08:59 ` Re: INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Thom Brown @ 2010-06-22 08:48 UTC (permalink / raw)
To: Magnus Hagander <[email protected]>; +Cc: Satoshi Nagayasu <[email protected]>; pgsql-docs
On 22 June 2010 09:44, Magnus Hagander <[email protected]> wrote:
> On Tue, Jun 22, 2010 at 10:27 AM, Satoshi Nagayasu
> <[email protected]> wrote:
>> Hi all,
>>
>> I've found a bit strange thing on the INTEGER range in the official manual.
>>
>> http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
>>
>> According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
>> However, my example in below shows that "-2147483648" is not accepted.
>>
>> Is this correct? Any suggestions?
>>
>> template1=# SELECT -2147483648::integer;
>> ERROR: integer out of range
>
> This gets parsed as "cast 2147483648 to integer
Why? And if so, it would probably be more useful if the error message
was something more like:
ERROR: integer 2147483648 out of range
That would at least show the user what the value was seen as by the parser.
Thom
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:44 ` Re: INTEGER range ("-2147483648" is not accepted.) Magnus Hagander <[email protected]>
2010-06-22 08:48 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
@ 2010-06-22 08:59 ` Satoshi Nagayasu <[email protected]>
2010-06-22 09:46 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Satoshi Nagayasu @ 2010-06-22 08:59 UTC (permalink / raw)
To: Thom Brown <[email protected]>; Magnus Hagander <[email protected]>; +Cc: pgsql-docs
Magnus,
Thanks for your advice. I've understood how it happens.
However, it looks tricky and difficult to understand,
so I hope that the message could be more understandable
as Thom mentioned.
Regards,
On 2010/06/22 17:48, Thom Brown wrote:
> On 22 June 2010 09:44, Magnus Hagander<[email protected]> wrote:
>> On Tue, Jun 22, 2010 at 10:27 AM, Satoshi Nagayasu
>> <[email protected]> wrote:
>>> Hi all,
>>>
>>> I've found a bit strange thing on the INTEGER range in the official manual.
>>>
>>> http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html
>>>
>>> According to the official manual, the INTEGER range is "-2147483648 to +2147483647".
>>> However, my example in below shows that "-2147483648" is not accepted.
>>>
>>> Is this correct? Any suggestions?
>>>
>>> template1=# SELECT -2147483648::integer;
>>> ERROR: integer out of range
>>
>> This gets parsed as "cast 2147483648 to integer
>
> Why? And if so, it would probably be more useful if the error message
> was something more like:
> ERROR: integer 2147483648 out of range
>
> That would at least show the user what the value was seen as by the parser.
>
> Thom
>
--
NAGAYASU Satoshi <[email protected]>
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:44 ` Re: INTEGER range ("-2147483648" is not accepted.) Magnus Hagander <[email protected]>
2010-06-22 08:48 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 08:59 ` Re: INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
@ 2010-06-22 09:46 ` Thom Brown <[email protected]>
2010-06-22 09:57 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Thom Brown @ 2010-06-22 09:46 UTC (permalink / raw)
To: Satoshi Nagayasu <[email protected]>; +Cc: Magnus Hagander <[email protected]>; pgsql-docs
On 22 June 2010 09:59, Satoshi Nagayasu <[email protected]> wrote:
> Magnus,
>
> Thanks for your advice. I've understood how it happens.
>
> However, it looks tricky and difficult to understand,
> so I hope that the message could be more understandable
> as Thom mentioned.
>
> Regards,
>
This does appear to be a gotcha, as the following returns a negative
integer as expected:
postgres=# SELECT -2147483648;
?column?
-------------
-2147483648
(1 row)
postgres=# SELECT pg_typeof(-2147483648);
pg_typeof
-----------
integer
(1 row)
And just in case...
postgres=# SELECT pg_typeof(test.my_num) FROM (SELECT -2147483648) AS
test(my_num);
pg_typeof
-----------
integer
(1 row)
So it's affected by the cast operator?
Thom
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:44 ` Re: INTEGER range ("-2147483648" is not accepted.) Magnus Hagander <[email protected]>
2010-06-22 08:48 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 08:59 ` Re: INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 09:46 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
@ 2010-06-22 09:57 ` Thom Brown <[email protected]>
2010-06-22 13:37 ` Re: INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Thom Brown @ 2010-06-22 09:57 UTC (permalink / raw)
To: Satoshi Nagayasu <[email protected]>; +Cc: Magnus Hagander <[email protected]>; pgsql-docs
On 22 June 2010 10:46, Thom Brown <[email protected]> wrote:
> On 22 June 2010 09:59, Satoshi Nagayasu <[email protected]> wrote:
>> Magnus,
>>
>> Thanks for your advice. I've understood how it happens.
>>
>> However, it looks tricky and difficult to understand,
>> so I hope that the message could be more understandable
>> as Thom mentioned.
>>
>> Regards,
>>
>
> This does appear to be a gotcha, as the following returns a negative
> integer as expected:
>
> postgres=# SELECT -2147483648;
> ?column?
> -------------
> -2147483648
> (1 row)
>
> postgres=# SELECT pg_typeof(-2147483648);
> pg_typeof
> -----------
> integer
> (1 row)
>
> And just in case...
>
> postgres=# SELECT pg_typeof(test.my_num) FROM (SELECT -2147483648) AS
> test(my_num);
> pg_typeof
> -----------
> integer
> (1 row)
>
> So it's affected by the cast operator?
>
> Thom
>
Actually, come to think of it, shouldn't we have a gotchas page on the wiki?
Thom
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: INTEGER range ("-2147483648" is not accepted.)
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:44 ` Re: INTEGER range ("-2147483648" is not accepted.) Magnus Hagander <[email protected]>
2010-06-22 08:48 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 08:59 ` Re: INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 09:46 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
2010-06-22 09:57 ` Re: INTEGER range ("-2147483648" is not accepted.) Thom Brown <[email protected]>
@ 2010-06-22 13:37 ` Satoshi Nagayasu <[email protected]>
0 siblings, 0 replies; 14+ messages in thread
From: Satoshi Nagayasu @ 2010-06-22 13:37 UTC (permalink / raw)
To: Thom Brown <[email protected]>; +Cc: Magnus Hagander <[email protected]>; pgsql-docs
Thom,
> Actually, come to think of it, shouldn't we have a gotchas page on the wiki?
I agree with that it should be described in some tech document,
but I don't have any good idea where/how it should be written.
Basically, it's a parser issue, but app developers may meet it
on their type casting (my guess), and it's a bit tricky.
Regards,
On 2010/06/22 18:57, Thom Brown wrote:
> On 22 June 2010 10:46, Thom Brown<[email protected]> wrote:
>> On 22 June 2010 09:59, Satoshi Nagayasu<[email protected]> wrote:
>>> Magnus,
>>>
>>> Thanks for your advice. I've understood how it happens.
>>>
>>> However, it looks tricky and difficult to understand,
>>> so I hope that the message could be more understandable
>>> as Thom mentioned.
>>>
>>> Regards,
>>>
>>
>> This does appear to be a gotcha, as the following returns a negative
>> integer as expected:
>>
>> postgres=# SELECT -2147483648;
>> ?column?
>> -------------
>> -2147483648
>> (1 row)
>>
>> postgres=# SELECT pg_typeof(-2147483648);
>> pg_typeof
>> -----------
>> integer
>> (1 row)
>>
>> And just in case...
>>
>> postgres=# SELECT pg_typeof(test.my_num) FROM (SELECT -2147483648) AS
>> test(my_num);
>> pg_typeof
>> -----------
>> integer
>> (1 row)
>>
>> So it's affected by the cast operator?
>>
>> Thom
>>
>
> Actually, come to think of it, shouldn't we have a gotchas page on the wiki?
>
> Thom
>
--
NAGAYASU Satoshi <[email protected]>
^ permalink raw reply [nested|flat] 14+ messages in thread
end of thread, other threads:[~2010-06-23 15:06 UTC | newest]
Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-06-22 08:27 INTEGER range ("-2147483648" is not accepted.) Satoshi Nagayasu <[email protected]>
2010-06-22 08:36 ` Thom Brown <[email protected]>
2010-06-22 23:07 ` David Fetter <[email protected]>
2010-06-22 23:16 ` Thom Brown <[email protected]>
2010-06-23 01:49 ` Tom Lane <[email protected]>
2010-06-23 08:17 ` Thom Brown <[email protected]>
2010-06-23 14:29 ` Mike Toews <[email protected]>
2010-06-23 15:06 ` Robert Haas <[email protected]>
2010-06-22 08:44 ` Magnus Hagander <[email protected]>
2010-06-22 08:48 ` Thom Brown <[email protected]>
2010-06-22 08:59 ` Satoshi Nagayasu <[email protected]>
2010-06-22 09:46 ` Thom Brown <[email protected]>
2010-06-22 09:57 ` Thom Brown <[email protected]>
2010-06-22 13:37 ` Satoshi Nagayasu <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox