COPY incorrectly uses null instead of an empty string in last field

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема COPY incorrectly uses null instead of an empty string in last field
Дата
Msg-id 1014741700.5762.233.camel@linda
обсуждение исходный текст
Ответы Re: COPY incorrectly uses null instead of an empty string in last field  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Release 7.2:

Where the last field of a line contains an empty string, COPY
incorrectly inserts a NULL.  This will cause data to be loaded
incorrectly from pg_dump.  This happens because, when a newline is seen,
COPY needs to know whether there was a preceding delimiter and use an
empty string in that case; there is a difference between a last field
that is an empty string and one or more last fields that are completely
unspecified.

Changing this should not affect COPY TO or pg_dump, which already put
out \N in the last field if it really is NULL.

For example:

--
-- Selected TOC Entries:
--
\connect  -  "olly"

--
-- TOC Entry ID 2 (OID 1522144)
--
-- Name: schau Type: TABLE Owner: olly
--

CREATE TABLE "schau" ("feld1" text NOT NULL,"feld2" character varying(10) NOT NULL,Constraint "pk_schau" Primary Key
("feld1","feld2")
 
);

--
-- Data for TOC Entry ID 3 (OID 1522144)
--
-- Name: schau Type: TABLE DATA Owner: olly
--


COPY "schau" FROM stdin;
Helge    
Arne    
Alle    Keiner
\.

I tried to make a fix, but managed to break it completely :-(

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
    "But God commendeth his love toward us, in that, while      we were yet sinners, Christ died for us."
                           Romans 5:8 
 



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: quotes in SET grammar
Следующее
От: Thomas Lockhart
Дата:
Сообщение: Re: quotes in SET grammar