dbTalk Databases Forums  

[BUGS] 8.1.2 -32768::smallint

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] 8.1.2 -32768::smallint in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jean-Gérard Pailloncy
 
Posts: n/a

Default [BUGS] 8.1.2 -32768::smallint - 12-13-2006 , 09:26 AM






Hi,

On PostgreSQL 8.1.2
select -32768::smallint
throws the error
ERROR: smallint out of range

select -32767::smallint
is OK.

The documentation states that -32768 is OK.
http://www.postgresql.org/docs/8.1/i...TATYPE-NUMERIC

Cordialement,
Jean-Gérard Pailloncy


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply With Quote
  #2  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] 8.1.2 -32768::smallint - 12-13-2006 , 09:35 AM






On Wed, Dec 13, 2006 at 03:03:43PM -0000, Jean-Gérard Pailloncy wrote:
Quote:
On PostgreSQL 8.1.2
select -32768::smallint
throws the error
ERROR: smallint out of range
I think the cast is binding tighter than the unary minus, so the
above is equivalent to

select -(32768::smallint)

which is why you're getting "smallint out of range." This should work:

select (-32768)::smallint

--
Michael Fuhr

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


Reply With Quote
  #3  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] 8.1.2 -32768::smallint - 12-13-2006 , 09:44 AM



On Wed, Dec 13, 2006 at 08:34:38AM -0700, Michael Fuhr wrote:
Quote:
On Wed, Dec 13, 2006 at 03:03:43PM -0000, Jean-Gérard Pailloncy wrote:
On PostgreSQL 8.1.2
select -32768::smallint
throws the error
ERROR: smallint out of range

I think the cast is binding tighter than the unary minus,
Indeed it is; see the Operator Precedence table:

http://www.postgresql.org/docs/8.1/i...SQL-PRECEDENCE

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


Reply With Quote
  #4  
Old   
Jean-Gérard Pailloncy
 
Posts: n/a

Default Re: [BUGS] 8.1.2 -32768::smallint - 12-13-2006 , 10:03 AM



Quote:
select -(32768::smallint)

which is why you're getting "smallint out of range." This should work:

select (-32768)::smallint
Exact. Thank you for the answer.
But really conter-intuitive.

Cordialement,
Jean-Gérard Pailloncy


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.