Thread: pg_dump and psql disagree on numerical precision (powerpc)

pg_dump and psql disagree on numerical precision (powerpc)

From
Christof Petig
Date:
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

Re: pg_dump and psql disagree on numerical precision (powerpc)

From
Tom Lane
Date:
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

Re: pg_dump and psql disagree on numerical precision (powerpc)

From
Christof Petig
Date:
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

Re: pg_dump and psql disagree on numerical precision (powerpc)

From
Tom Lane
Date:
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

Re: pg_dump and psql disagree on numerical precision (powerpc)

From
Christof Petig
Date:
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