Thread

  1. pg_dump and psql disagree on numerical precision (powerpc)

    Christof Petig <christof@petig-baender.de> — 2003-11-14T09:55:42Z

    I didn't believe it at first:
    
    create table test ( x double precision);
    
    insert into test values (0.3);
    
    test=# select * from test;
       x
    -----
      0.3
    
    --
    -- Data for TOC entry 3 (OID 53248)
    -- Name: test; Type: TABLE DATA; Schema: public; Owner: christof
    --
    COPY test (x) FROM stdin;
    0.29999999999999999
    \.
    
    psql --version
    psql (PostgreSQL) 7.4RC1
    
    \set
    VERSION = 'PostgreSQL 7.4RC1 on powerpc-unknown-linux-gnu, compiled by 
    GCC powerpc-linux-gcc (GCC) 3.3.2 (Debian)'
    
    pg_dump --version
    pg_dump (PostgreSQL) 7.4RC1
    
    
    
  2. Re: pg_dump and psql disagree on numerical precision (powerpc)

    Tom Lane <tgl@sss.pgh.pa.us> — 2003-11-14T14:50:32Z

    Christof Petig <christof@petig-baender.de> writes:
    > COPY test (x) FROM stdin;
    > 0.29999999999999999
    > \.
    
    This is not a bug; it's pg_dump trying to recreate the actual floating
    point value as accurately as it can.  See the discussion of
    extra_float_digits from six months or a year back.
    
    			regards, tom lane
    
    
  3. Re: pg_dump and psql disagree on numerical precision (powerpc)

    Christof Petig <christof@petig-baender.de> — 2003-11-14T15:47:10Z

    Tom Lane schrieb:
    > Christof Petig <christof@petig-baender.de> writes:
    > 
    >>COPY test (x) FROM stdin;
    >>0.29999999999999999
    >>\.
    > 
    > 
    > This is not a bug; it's pg_dump trying to recreate the actual floating
    > point value as accurately as it can.  See the discussion of
    > extra_float_digits from six months or a year back.
    
    Oh, I see (and generally appreciate). Thank you for reminding me.
    
    Commenting out "set extra_float_digits=2" in pg_dump.c gives me the old 
    behaviour. Is it only me wishing for a command line parameter for 
    pg_dump to set desired precision?
    
        Christof
    
    
    
  4. Re: pg_dump and psql disagree on numerical precision (powerpc)

    Tom Lane <tgl@sss.pgh.pa.us> — 2003-11-14T16:25:07Z

    Christof Petig <christof@petig-baender.de> writes:
    > Commenting out "set extra_float_digits=2" in pg_dump.c gives me the old 
    > behaviour. Is it only me wishing for a command line parameter for 
    > pg_dump to set desired precision?
    
    It seems to me that you should be using type NUMERIC if you think there
    is a difference between 0.3 and 0.29999999999999999.
    
    			regards, tom lane
    
    
  5. Re: pg_dump and psql disagree on numerical precision (powerpc)

    Christof Petig <christof@petig-baender.de> — 2003-11-14T22:07:46Z

    Tom Lane schrieb:
    > Christof Petig <christof@petig-baender.de> writes:
    > 
    >>Commenting out "set extra_float_digits=2" in pg_dump.c gives me the old 
    >>behaviour. Is it only me wishing for a command line parameter for 
    >>pg_dump to set desired precision?
    > 
    > 
    > It seems to me that you should be using type NUMERIC if you think there
    > is a difference between 0.3 and 0.29999999999999999.
    
    Touché. (you score)
    
       Christof