Re: [HACKERS] numeric & decimal - Mailing list pgsql-hackers

From José Soares
Subject Re: [HACKERS] numeric & decimal
Date
Msg-id 372706EC.56E37CE6@sferacarta.com
Whole thread Raw
In response to Re: [HACKERS] numeric & decimal  (jwieck@debis.com (Jan Wieck))
Responses Re: [HACKERS] numeric & decimal  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
<tt>Jan Wieck ha scritto:</tt><blockquote type="CITE"><tt>> Hi all,</tt><br /><tt>></tt><br /><tt>> I'm trying
numeric& decimal types in v6.5beta1 and I have two questions</tt><br /><tt>> about it.</tt><br
/><tt>></tt><br/><tt>> [...]</tt><br /><tt>></tt><br /><tt>> Second question:</tt><br /><tt>>     Why
PostgreSQLallows to insert 14 digits into a numeric(5,1) ?</tt><br /><tt>></tt><br /><tt>> create table
test(</tt><br/><tt>>         n numeric(10,3),</tt><br /><tt>>         d decimal(5,1)</tt><br /><tt>>
);</tt><tt></tt><p><tt>   For  some reason (dunno why) the parser ignores the precision</tt><br /><tt>    for DECIMAL. 
atttypmodis set hardcoded to -1.  So the above</tt><br /><tt>    is identical to a</tt><tt></tt><p><tt>        CREATE
TABLEtest (n numeric(10,3), d decimal);</tt><tt></tt><p><tt>    I'll  test  what  happens  if I enable it in gram.y and
ifit</tt><br /><tt>    doesn't break any regression commit the changes.</tt><tt></tt><p><tt>Jan</tt><br
/><tt></tt> </blockquote>Great! <br />I have other questions about NUMERICs: <blockquote type="CITE"><tt>create table
test(</tt><br/><tt>        num0 numeric,</tt><br /><tt>        num1 numeric(1),</tt><br /><tt>        num4
numeric(4,1)</tt><br/><tt>);</tt><br /><tt>CREATE</tt><br /><tt>insert into test values
(11111111,11111111,-9,9,-999.99,-999.99);</tt><br/><tt>INSERT 78190 1</tt><br /><tt>select * from test;</tt><br
/><tt>          num0|num1|   num4</tt><br /><tt>---------------+----+-------</tt><br /><tt>11111111.000000|  
9|-1000.0</tt><br/>                  ^^^^^^            ^^^^^^^</blockquote> - I don't understand this default: <br /> 
NUMERIC without size is interpreted as NUMERIC(x,6). Why ? <br />  Standard SQL92 says that NUMERIC without size is
equivalentto NUMERIC(1) <p>- NUMERIC(4,1)  transalte value -999.99 as -1000.0 (greater than his size) <p>Comments?
<p>José<br />  

pgsql-hackers by date:

Previous
From: "Cary O'Brien"
Date:
Subject: Re: [HACKERS] Hacker found bug in Postgres ?
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Issues with the latest 6.5 source