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