pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
double precision to numeric overflow error
6+ messages / 4 participants
[nested] [flat]

* double precision to numeric overflow error
@ 2003-01-07 23:12  Thomas O'Connell <tfo@monsterlabs.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Thomas O'Connell @ 2003-01-07 23:12 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

is this expected behavior? if so, then why?

-tfo

db=# create table foo( col timestamp );
db=# select cast( extract( epoch from col ) as numeric( 15, 6 ) ) from 
foo;
 date_part 
-----------
(0 rows)
db=# insert into foo values( current_timestamp );
INSERT 1705954 1
db=# select cast( extract( epoch from col ) as numeric( 15, 6 ) ) from 
foo;
ERROR:  overflow on numeric ABS(value) >= 10^9 for field with precision 
15 scale 6



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] double precision to numeric overflow error
@ 2003-01-07 23:36  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Thomas O'Connell <tfo@monsterlabs.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Stephan Szabo @ 2003-01-07 23:36 UTC (permalink / raw)
  To: Thomas O'Connell <tfo@monsterlabs.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql


On Tue, 7 Jan 2003, Thomas O'Connell wrote:

> is this expected behavior? if so, then why?

I'd guess so if the timestamp value's integer part is
10 digits long since I believe trying to fit that into
a numeric(15,6) wouldn't work (9 digits . 6 digits).

> db=# create table foo( col timestamp );
> db=# select cast( extract( epoch from col ) as numeric( 15, 6 ) ) from
> foo;
>  date_part
> -----------
> (0 rows)
> db=# insert into foo values( current_timestamp );
> INSERT 1705954 1
> db=# select cast( extract( epoch from col ) as numeric( 15, 6 ) ) from
> foo;
> ERROR:  overflow on numeric ABS(value) >= 10^9 for field with precision
> 15 scale 6






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: double precision to numeric overflow error
@ 2003-01-08 03:01  Thomas O'Connell <tfo@monsterlabs.com>
  parent: Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Thomas O'Connell @ 2003-01-08 03:01 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

Indeed, it seems as though my inability to count digits was the real 
problem. Still, does this not strike anyone as a somewhat abstruse error 
message?

-tfo

In article <20030107152951.R67168-100000@megazone23.bigpanda.com>,
 sszabo@megazone23.bigpanda.com (Stephan Szabo) wrote:

> On Tue, 7 Jan 2003, Thomas O'Connell wrote:
> 
> > is this expected behavior? if so, then why?
> 
> I'd guess so if the timestamp value's integer part is
> 10 digits long since I believe trying to fit that into
> a numeric(15,6) wouldn't work (9 digits . 6 digits).
> 
> > db=# create table foo( col timestamp );
> > db=# select cast( extract( epoch from col ) as numeric( 15, 6 ) ) from
> > foo;
> >  date_part
> > -----------
> > (0 rows)
> > db=# insert into foo values( current_timestamp );
> > INSERT 1705954 1
> > db=# select cast( extract( epoch from col ) as numeric( 15, 6 ) ) from
> > foo;
> > ERROR:  overflow on numeric ABS(value) >= 10^9 for field with precision
> > 15 scale 6



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: double precision to numeric overflow error
@ 2003-01-08 04:15  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas O'Connell <tfo@monsterlabs.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2003-01-08 04:15 UTC (permalink / raw)
  To: Thomas O'Connell <tfo@monsterlabs.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

"Thomas O'Connell" <tfo@monsterlabs.com> writes:
> Indeed, it seems as though my inability to count digits was the real 
> problem. Still, does this not strike anyone as a somewhat abstruse error 
> message?

How would you phrase it?

> ERROR:  overflow on numeric ABS(value) >= 10^9 for field with precision
> 15 scale 6

It's technically correct, but if you think you can word it better,
let's see your proposal...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: double precision to numeric overflow error
@ 2003-01-08 05:36  Thomas O'Connell <tfo@monsterlabs.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Thomas O'Connell @ 2003-01-08 05:36 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

Well, it would've immediately (rather than the several minutes it took) 
given away the problem if it read something like:

ERROR:  overflow caused by cast of double precision value to numeric 
without sufficient precision, scale (15, 6)

or even, depending on how much detail is available or how much worth 
assigned to error reporting:

ERROR:  a double precision value requiring at least precision 16 cannot 
be cast to a numeric value with precision 15, scale 6.

i understand the need for balancing correctness with readability, 
though. if there's anything technically incorrect about either of my 
proprosals, they clearly should not be used.

i'm usually a fan of breaking error messages down as far as the details 
will allow them to be correctly broken down.

in this situtation, it seems like it is this specific cast (double 
precision -> numeric) in this specific scenario (insufficient precision) 
that generates the error.

unfortunately, i haven't read the code... :(

-tfo

In article <726.1041999309@sss.pgh.pa.us>, tgl@sss.pgh.pa.us (Tom Lane) 
wrote:

> "Thomas O'Connell" <tfo@monsterlabs.com> writes:
> > Indeed, it seems as though my inability to count digits was the real 
> > problem. Still, does this not strike anyone as a somewhat abstruse error 
> > message?
> 
> How would you phrase it?
> 
> > ERROR:  overflow on numeric ABS(value) >= 10^9 for field with precision
> > 15 scale 6
> 
> It's technically correct, but if you think you can word it better,
> let's see your proposal...



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: double precision to numeric overflow error
@ 2003-01-17 20:43  Jan Wieck <JanWieck@Yahoo.com>
  parent: Thomas O'Connell <tfo@monsterlabs.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Jan Wieck @ 2003-01-17 20:43 UTC (permalink / raw)
  To: Thomas O'Connell <tfo@monsterlabs.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

Thomas O'Connell wrote:
> 
> Well, it would've immediately (rather than the several minutes it took)
> given away the problem if it read something like:
> 
> ERROR:  overflow caused by cast of double precision value to numeric
> without sufficient precision, scale (15, 6)
> 
> or even, depending on how much detail is available or how much worth
> assigned to error reporting:

The message will be exactly the same in all cases, since there is no
more detail. I think words about casting and such could be fairly
confusing in the case someone just inserts a literal value - no?


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2003-01-17 20:43 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-07 23:12 double precision to numeric overflow error Thomas O'Connell <tfo@monsterlabs.com>
2003-01-07 23:36 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-01-08 03:01   ` Thomas O'Connell <tfo@monsterlabs.com>
2003-01-08 04:15     ` Tom Lane <tgl@sss.pgh.pa.us>
2003-01-08 05:36       ` Thomas O'Connell <tfo@monsterlabs.com>
2003-01-17 20:43         ` Jan Wieck <JanWieck@Yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox