pg_dump and psql disagree on numerical precision (powerpc)

Started by Christof Petigover 22 years ago5 messagesbugs
Jump to latest
#1Christof Petig
christof@petig-baender.de

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christof Petig (#1)
Re: pg_dump and psql disagree on numerical precision (powerpc)

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

#3Christof Petig
christof@petig-baender.de
In reply to: Tom Lane (#2)
Re: pg_dump and psql disagree on numerical precision (powerpc)

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christof Petig (#3)
Re: pg_dump and psql disagree on numerical precision (powerpc)

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

#5Christof Petig
christof@petig-baender.de
In reply to: Tom Lane (#4)
Re: pg_dump and psql disagree on numerical precision (powerpc)

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