Bug #959: handling of 'nan' floating point value with pg_dump incorrect - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Bug #959: handling of 'nan' floating point value with pg_dump incorrect
Date
Msg-id 20030428212232.AC58947631F@postgresql.org
Whole thread Raw
Responses Re: Bug #959: handling of 'nan' floating point value with pg_dump incorrect  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Jeff (cast_ent@yahoo.ca) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
handling of 'nan' floating point value with pg_dump incorrect

Long Description
I am using version 7.2.3-5.80 that comes with RH8.0.

Create a DB with a table in it with a float type column.  Insert the value 'NaN' into the table.

Now dump the db using pg_dump.

Now restore the DB using psql and you get an error:
psql:dumpdb:36: ERROR:  Attribute 'nan' not found

Seems that the 'dump' does not put the required '' quotes around the nan value.

You get the same error if you were to try:
INSERT INTO test VALUE(nan);
the above fails, but the following works:
INSERT INTO test VALUE('nan');  (or 'NaN' works as well).

Hope this helps.

Jeff

Sample Code
$createdb test
$psql test
>CREATE TABLE test (val float);
>INSERT INTO test VALUE(1.001);
>INSERT INTO test VALUE('NaN'); %This works fine
>\q
$pg_dump -D -C test > dumpdb
$dropdb test
$psql -f dumpdb -d template1

->output from last command:
$psql -f dumpdb -d template1
You are now connected as new user jeff.
CREATE DATABASE
You are now connected to database test as user jeff.
CREATE
INSERT 19010 1
psql:dumpdb:36: ERROR:  Attribute 'nan' not found

->examination of dumpdb file (whitespace modified for readability)
--
-- Selected TOC Entries:
--
\connect - jeff
--
-- TOC Entry ID 1 (OID 0)
--
-- Name: test Type: DATABASE Owner: jeff
--
CREATE DATABASE "test" WITH TEMPLATE = template0 ENCODING = 0;
\connect test jeff
--
-- TOC Entry ID 2 (OID 18992)
--
-- Name: test Type: TABLE Owner: jeff
--
CREATE TABLE "test" (
        "val" double precision
);
--
-- Data for TOC Entry ID 3 (OID 18992)
--
-- Name: test Type: TABLE DATA Owner: jeff
--
INSERT INTO "test" ("val") VALUES (1);
INSERT INTO "test" ("val") VALUES (NaN);


-> Note:  Replacing the last line from dumpdb from:
INSERT INTO "test" ("val") VALUES (NaN);
to:
INSERT INTO "test" ("val") VALUES ('NaN');
makes everything work fine.

No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug #958: plperl notice server log
Next
From: Tom Lane
Date:
Subject: Re: Bug #959: handling of 'nan' floating point value with pg_dump incorrect