Unix Technical Forum

BUG #1526: SHRT_MIN out of range on explicit type conversion

This is a discussion on BUG #1526: SHRT_MIN out of range on explicit type conversion within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 1526 Logged by: Kelly Burkhart Email address: pgkrb@kkcsm.net PostgreSQL version: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:37 AM
Kelly Burkhart
 
Posts: n/a
Default BUG #1526: SHRT_MIN out of range on explicit type conversion


The following bug has been logged online:

Bug reference: 1526
Logged by: Kelly Burkhart
Email address: pgkrb@kkcsm.net
PostgreSQL version: 7.4.2
Operating system: SuSE Linux 9.1 i386 & x86-64
Description: SHRT_MIN out of range on explicit type conversion
Details:

An explicit type conversion of an integer constant representing the minimum
value that type can hold results in an 'integer out of range' error.

From psql, the following will fail:

select -32768::int2;
select -2147483648::int4;
select -9223372036854775808::int8;

If the constants are strings, there is no failure. For instance the
following will succeed:

select '-32768'::int2;
select '-2147483648'::int4;
select '-9223372036854775808'::int8;

Also increasing the value by one does not result in failure. The following
will succeed:

select -32767::int2;
select -2147483647::int4;
select -9223372036854775807::int8;

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:38 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #1526: SHRT_MIN out of range on explicit type conversion

"Kelly Burkhart" <pgkrb@kkcsm.net> writes:
> From psql, the following will fail:


> select -32768::int2;


This is not a bug. The reason is that :: binds more tightly than -,
so what you have written is equivalent to

select -(32768::int2);

which obviously *should* fail. Try it as

select (-32768)::int2;

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:54 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com