Re: Different exponent in error messages

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Andrus <eetasoft(at)online(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: Different exponent in error messages
Date: 2006-01-11 22:52:46
Message-ID: 28917.1137019966@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

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.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-01-11 22:57:15 Re: getting access to geodistance (what do I need to install/enable) in an existing db install
Previous Message Michael Fuhr 2006-01-11 22:34:31 Re: Different exponent in error messages

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-01-11 22:53:00 Re: [HACKERS] Inconsistent syntax in GRANT
Previous Message Alvaro Herrera 2006-01-11 22:35:42 Re: [PATCHES] Summary table trigger example race condition