Обсуждение: Bug #959: handling of 'nan' floating point value with pg_dump incorrect
Bug #959: handling of 'nan' floating point value with pg_dump incorrect
От
pgsql-bugs@postgresql.org
Дата:
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@postgresql.org writes: > Seems that the 'dump' does not put the required '' quotes around the nan value. Seems to be fixed in more recent versions of pg_dump ... in the meantime try it without -d or -D. regards, tom lane