Re: [GENERAL] Different exponent in error messages

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, Andrus <eetasoft(at)online(dot)ee>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [GENERAL] Different exponent in error messages
Date: 2006-01-23 20:02:22
Message-ID: 200601232002.k0NK2Mp20081@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
> > I think this is what Andrus is seeing:
>
> > test=> CREATE TABLE foo (n numeric(9,3));
> > CREATE TABLE
> > test=> INSERT INTO foo VALUES (1000000);
> > ERROR: numeric field overflow
> > DETAIL: The absolute value is greater than or equal to 10^6 for field with precision 9, scale 3.
> > test=> INSERT INTO foo VALUES (1000000000);
> > ERROR: numeric field overflow
> > DETAIL: The absolute value is greater than or equal to 10^9 for field with precision 9, scale 3.
>
> Hm, I thought I tested that same case, but I must've messed up somehow.
>
> Anyway, the code seems to be intentionally reporting the log10 of the
> actual input value, not the limiting log10 for the field size. This
> behavior goes at least as far back as PG 7.0, so I'm disinclined to
> change it. We could talk about altering the message wording though,
> if you have a suggestion for something you'd find less confusing.
> Pre-7.4 versions say
>
> ERROR: overflow on numeric ABS(value) >= 10^9 for field with precision 9 scale 3
>
> so it looks like we just fixed the grammar during the 7.4 message
> wording cleanup, without reflecting about whether the meaning was clear.

Yes, this message clearly needs help. Here is what I developed:

test=> CREATE TABLE foo (n numeric(9,3));
CREATE TABLE
test=> INSERT INTO foo VALUES (10000000);
ERROR: numeric field overflow
DETAIL: A field with precision 9, scale 3 must have an absolute value less than 10^6.

and the 10^6 is based on the max digits to the left of the decimal
point, not the input value.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 1.0 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Wheeler 2006-01-23 20:06:55 ANN: Bricolage 1.10
Previous Message Brian A. Seklecki 2006-01-23 19:54:21 Re: psql(18967) malloc: *** vm_allocate(size=8421376)

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-01-23 21:55:02 CIDR/INET structure member renaming
Previous Message Jim C. Nasby 2006-01-23 17:00:51 Re: [PATCHES] postmaster/postgres merge for testing