Re: COPY incorrectly uses null instead of an empty string in last field - Mailing list pgsql-hackers

From Tom Lane
Subject Re: COPY incorrectly uses null instead of an empty string in last field
Date
Msg-id 4262.1014747842@sss.pgh.pa.us
Whole thread Raw
In response to COPY incorrectly uses null instead of an empty string in last field  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-hackers
Oliver Elphick <olly@lfix.co.uk> writes:
> Where the last field of a line contains an empty string, COPY
> incorrectly inserts a NULL.

Certainly not.  Using your example table definition, I did:

regression=# insert into schau values ('test','foo');
INSERT 146293 1
regression=# insert into schau values ('test2','');
INSERT 146294 1
regression=# insert into schau values ('test2',null);
ERROR:  ExecAppend: Fail to add null value in not null attribute feld2
regression=# copy schau to '/tmp/schau.out';
COPY
regression=# delete from schau;
DELETE 2
regression=# copy schau from '/tmp/schau.out';
COPY
regression=# select * from schau ;feld1 | feld2
-------+-------test  | footest2 |
(2 rows)

regression=# select * from schau where feld2 is null;feld1 | feld2
-------+-------
(0 rows)

The contents of /tmp/schau.out are:

test    foo
test2    

(there's a tab after test2, in case you can't see it ;-))

I don't see any problem here.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Teodor Sigaev
Date:
Subject: Please, apply patch for contrib/tsearch
Next
From: "Brian Moran"
Date:
Subject: Re: setting up a trace through extended stored procedures