Re: BUG #4973: number precision or scale lost when altering table column - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4973: number precision or scale lost when altering table column
Date
Msg-id 29754.1249960293@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4973: number precision or scale lost when altering table column  ("terry" <94487509@qq.com>)
List pgsql-bugs
"terry" <94487509@qq.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

pgsql-bugs by date:

Previous
From: "terry"
Date:
Subject: BUG #4973: number precision or scale lost when altering table column
Next
From: hubert depesz lubaczewski
Date:
Subject: misleading error message in 8.5, and bad (?) way deferred uniqueness works