Обсуждение: pg_dump and psql disagree on numerical precision (powerpc)
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
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
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
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
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