Re: [HACKERS] Numeric type - Mailing list pgsql-hackers

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] Numeric type
Date
Msg-id m0zxvCV-000EBRC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to Re: [HACKERS] Numeric type  ("Thomas G. Lockhart" <lockhart@alumni.caltech.edu>)
List pgsql-hackers
>
> > > OK, I give up :) How do I use the numeric type?
> > Works here.  Don't you hate when that happens:
>
> postgres=> create table n1 (n numeric(10,5), d decimal(10,5));
> CREATE
> postgres=> insert into n1 values ('1.23456', '1.23456');
> ERROR:  overflow on numeric
>         ABS(value) >= 10^0 for field with precision 2086 scale 53380
>
> *sigh*
>
> Any hints on where to look? I did a CVSup update, then a "cvs -PdA" on
> my development tree, a "make clean install" and an initdb. I did not try
> a full clean checkout, but would think that it wouldn't help.

    Seems to me like the typmod value given to

        Numeric numeric(Numeric num, int dummy, int32 typmod)

    got  mangled  up  somewhere.  First you should check that the
    atttypmod in pg_attribute for n1.n and n1.d  is  correct.  It
    should have the value

        ((precision << 16) | scale) + 4

    and must be 655369 for a numeric(10,5).

    If   that   isn't   the  case,  you  might  take  a  look  at
    include/nodes/parsenodes.h.   The  typmod  field  of   struct
    TypeName  should  be  of int32 (I changed that shortly before
    moving numeric into the backend).

    If that isn't the error, it would be good if you're a  little
    familiar  with  gdb.  If  so,  set  a  breakpoint on function
    numeric()  and  try  to  find  where   on   it's   way   from
    pg_attribute.atttypmod  to  the  call  to  numeric()  it  got
    mangled up.

>
> Anyone else running on Linux/i686/libc5 having success? If so, I'll go
> back to working on outer joins...
>
>                    - Tom
>


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Numeric type
Next
From: Magnus Hagander
Date:
Subject: Libpq functions