Re: [HACKERS] numeric & decimal

Jose Soares <jose@sferacarta.com>

From: José Soares <jose@sferacarta.com>
To: Jan Wieck <jwieck@debis.com>
Cc: pgsql-hackers@postgresql.org
Date: 1999-04-28T13:02:36Z
Lists: pgsql-hackers
Jan Wieck ha scritto:

> > Hi all,
> >
> > I'm trying numeric & decimal types in v6.5beta1 and I have two questions
> > about it.
> >
> > [...]
> >
> > Second question:
> >     Why PostgreSQL allows to insert 14 digits into a numeric(5,1) ?
> >
> > create table test(
> >         n numeric(10,3),
> >         d decimal(5,1)
> > );
>
>     For  some reason (dunno why) the parser ignores the precision
>     for DECIMAL.  atttypmod is set hardcoded to -1.  So the above
>     is identical to a
>
>         CREATE TABLE test (n numeric(10,3), d decimal);
>
>     I'll  test  what  happens  if I enable it in gram.y and if it
>     doesn't break any regression commit the changes.
>
> Jan
>

Great!
I have other questions about NUMERICs:

> create table test(
>         num0 numeric,
>         num1 numeric(1),
>         num4 numeric(4,1)
> );
> CREATE
> insert into test values (11111111,11111111,-9,9,-999.99,-999.99);
> INSERT 78190 1
> select * from test;
>            num0|num1|   num4
> ---------------+----+-------
> 11111111.000000|   9|-1000.0
>                   ^^^^^^            ^^^^^^^

- I don't understand this default:
  NUMERIC  without size is interpreted as NUMERIC(x,6). Why ?
  Standard SQL92 says that NUMERIC without size is equivalent to NUMERIC(1)

- NUMERIC(4,1)  transalte value -999.99 as -1000.0 (greater than his size)

Comments?

José