Unix Technical Forum

Numeric overflow problem + patch

This is a discussion on Numeric overflow problem + patch within the Pgsql Patches forums, part of the PostgreSQL category; --> Folks, Dennis Björklund and I discovered a little problem with how CVS TIP reports overflows on cast. Please find ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 10:02 AM
David Fetter
 
Posts: n/a
Default Numeric overflow problem + patch

Folks,

Dennis Björklund and I discovered a little problem with how CVS TIP
reports overflows on cast. Please find enclosed a patch which fixes
it.

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!


---------------------------(end of broadcast)---------------------------
TIP 2: 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-18-2008, 10:02 AM
Tom Lane
 
Posts: n/a
Default Re: [HACKERS] Numeric overflow problem + patch

David Fetter <david@fetter.org> writes:
> ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1.
> [ becomes ]
> ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.


This strikes me as overly pedantic. The message needs to be clear,
and the proposed change will just confuse people.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 10:02 AM
Martijn van Oosterhout
 
Posts: n/a
Default Re: [HACKERS] Numeric overflow problem + patch

On Thu, Sep 28, 2006 at 05:11:43PM -0400, Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1.
> > [ becomes ]
> > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.

>
> This strikes me as overly pedantic. The message needs to be clear,
> and the proposed change will just confuse people.


I don't know if the code can detect the difference, but a message like:

A field with precision 4, scale 4 must *round to* an absolute value less than 1

Since that more accurately describes the actual problem.

Have a ncie day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFHDvIIB7bNG8LQkwRAlT9AJ4zEDZObaVl2ozpqP+cb8 S0lFFHXgCdGW2K
i/K2LVLuI2hXLLWLXFaGdIo=
=8Tyg
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 10:02 AM
David Fetter
 
Posts: n/a
Default Re: [HACKERS] Numeric overflow problem + patch

On Thu, Sep 28, 2006 at 05:11:43PM -0400, Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1.
> > [ becomes ]
> > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.

>
> This strikes me as overly pedantic. The message needs to be clear,
> and the proposed change will just confuse people.


It might, but the error that's currently in there is wrong. With the
patch applied, you get:

postgres=# SELECT .99995::NUMERIC(4,4);
ERROR: numeric field overflow
DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.

postgres=# SELECT .9999499999999999999999999999::NUMERIC(4,4);
numeric
---------
0.9999
(1 row)

I'd thought of changing it to the corresponding numeric piece, but
this doesn't work so well for NUMERIC(16,8) and the like.

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 10:02 AM
David Fetter
 
Posts: n/a
Default Re: [HACKERS] Numeric overflow problem + patch

On Thu, Sep 28, 2006 at 11:16:56PM +0200, Martijn van Oosterhout wrote:
> On Thu, Sep 28, 2006 at 05:11:43PM -0400, Tom Lane wrote:
> > David Fetter <david@fetter.org> writes:
> > > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1.
> > > [ becomes ]
> > > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.

> >
> > This strikes me as overly pedantic. The message needs to be
> > clear, and the proposed change will just confuse people.

>
> I don't know if the code can detect the difference, but a message
> like:
>
> A field with precision 4, scale 4 must *round to* an absolute value
> less than 1


What does .999 round to? How about .5?

> Since that more accurately describes the actual problem.


I'd say it doesn't, as worded. Maybe some other wording would be
clearer.

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 10:02 AM
David Fetter
 
Posts: n/a
Default Re: [HACKERS] Numeric overflow problem + patch

On Thu, Sep 28, 2006 at 11:16:56PM +0200, Martijn van Oosterhout wrote:
> On Thu, Sep 28, 2006 at 05:11:43PM -0400, Tom Lane wrote:
> > David Fetter <david@fetter.org> writes:
> > > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1.
> > > [ becomes ]
> > > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.

> >
> > This strikes me as overly pedantic. The message needs to be clear,
> > and the proposed change will just confuse people.

>
> I don't know if the code can detect the difference, but a message like:
>
> A field with precision 4, scale 4 must *round to* an absolute value less than 1
>
> Since that more accurately describes the actual problem.
>
> Have a ncie day,


Per your suggestion, how about this patch?

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-18-2008, 10:03 AM
Bruce Momjian
 
Posts: n/a
Default Re: [HACKERS] Numeric overflow problem + patch


Patch applied. Thanks.

---------------------------------------------------------------------------


David Fetter wrote:
> On Thu, Sep 28, 2006 at 11:16:56PM +0200, Martijn van Oosterhout wrote:
> > On Thu, Sep 28, 2006 at 05:11:43PM -0400, Tom Lane wrote:
> > > David Fetter <david@fetter.org> writes:
> > > > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1.
> > > > [ becomes ]
> > > > ! DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1 - 5 * 10^-5.
> > >
> > > This strikes me as overly pedantic. The message needs to be clear,
> > > and the proposed change will just confuse people.

> >
> > I don't know if the code can detect the difference, but a message like:
> >
> > A field with precision 4, scale 4 must *round to* an absolute value less than 1
> >
> > Since that more accurately describes the actual problem.
> >
> > Have a ncie day,

>
> Per your suggestion, how about this patch?
>
> Cheers,
> D
> --
> David Fetter <david@fetter.org> http://fetter.org/
> phone: +1 415 235 3778 AIM: dfetter666
> Skype: davidfetter
>
> Remember to vote!


[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match


--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

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

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 04:38 PM.


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