Re: COPY for CSV documentation

From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: COPY for CSV documentation
Date: 2004-04-12 12:07:12
Message-ID: 3870.24.211.141.25.1081771632.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Bruno Wolff III said:
> On Mon, Apr 12, 2004 at 02:26:14 -0400,
> Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>>
>> a few points:
>>
>> . in CSV mode, NULL should default to '' - that was in what I sent in.
>
> Postgres normally treats an empty string as an empty string. Are you
> sure you really want it to be treated as a NULL by default in this one
> place?
>

Yes ;-)

Otherwise, what will happen when we try to import into some non-text field
for which '' is not a valid value?

Spreadsheets commonly represent missing values as empty strings when
reading/writing CSVs - that's why this behaviour should be the default.

If you want to force it to use an empty string instead, simply specify
some unlikely value for NULL, like 'frobnitz'. But if you do, be prepared
for lots of errors unless you are importing into fields where empty string
is a valid text value.

Of course, a NOT NULL constraint will also break things, unless we went to
the MySQL method of handling insertion of NULL into a NOT NULL field ...
no I really am kidding.

cheers

andrew

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-04-12 12:15:42 Re: Information/schema hiding...
Previous Message Fabien COELHO 2004-04-12 11:59:34 Re: pg_restore ignore error patch