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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY incorrectly uses null instead of an empty string in last field
Date: 2002-02-26 18:24:02
Message-ID: 4262.1014747842@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Oliver Elphick <olly(at)lfix(dot)co(dot)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 | foo
test2 |
(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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Teodor Sigaev 2002-02-26 18:28:17 Please, apply patch for contrib/tsearch
Previous Message Bruce Momjian 2002-02-26 18:13:30 Re: quotes in SET grammar