Re: BUG #4973: number precision or scale lost when altering table column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "terry" <94487509(at)qq(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4973: number precision or scale lost when altering table column
Date: 2009-08-11 03:11:33
Message-ID: 29754.1249960293@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"terry" <94487509(at)qq(dot)com> writes:
> TEST=# CREATE TABLE B (C NUMERIC(8,3));
> CREATE TABLE
> TEST=# INSERT INTO B VALUES (12345.678);
> INSERT 0 1
> TEST=# SELECT * FROM B;
> c
> -----------
> 12345.678
> (1 row)

> TEST=# ALTER TABLE B ALTER COLUMN C TYPE NUMERIC(4,0);
> ERROR: numeric field overflow
> DETAIL: A field with precision 4, scale 0 must round to an absolute value
> less than 10^4.
> TEST=# ALTER TABLE B ALTER COLUMN C TYPE NUMERIC(5,0);
> ALTER TABLE

> /* scale lost */
> TEST=# SELECT * FROM B;
> c
> -------
> 12346
> (1 row)

This is exactly the intended behavior. We're not really interested in
Oracle's inability to handle the case.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sergei Abramov 2009-08-11 06:40:53 Malfunction in dropping database with pgAdmin
Previous Message terry 2009-08-11 02:53:01 BUG #4973: number precision or scale lost when altering table column