Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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

In response to

Responses

pgsql-patches by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group