Re: allow CSV quote in NULL - Mailing list pgsql-patches

From Stephen Frost
Subject Re: allow CSV quote in NULL
Date
Msg-id 20070727113847.GJ4887@tamriel.snowman.net
Whole thread Raw
In response to Re: allow CSV quote in NULL  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-patches
* Gregory Stark (stark@enterprisedb.com) wrote:
> "Tom Lane" <tgl@sss.pgh.pa.us> writes:
>
> > Stephen Frost <sfrost@snowman.net> writes:
> >>   Please find attached a minor patch to remove the constraints that a
> >>   user can't include the delimiter or quote characters in a 'NULL AS'
> >>   string when importing CSV files.
> >
> > This can't really be sane can it?
>
> Including unquoted delimiter characters seems kind of insane. But including
> the quote characters or quoted delimiter characters seems reasonable.

Right.  We could write something to check if the user provides an
unquoted delimiter character but I'm not really sure it's worth it, to
be perfectly honest.  If it'll make people happier with the patch I can
do it though.

> The alternative would be interpreting NULL strings after dequoting but that
> would leave no way to include the NULL string literally. This solution means
> there's no way to include it (if it needs quoting) but only when you specify
> it this way.

Yeah, interpreting NULLs after dequoting means you've lost the
information about if it's quoted or not, or you have to add some funky
syntax to say "if it's quoted, do it differently...", which is no good,
imv.

What the patch does basically is say "give us the exact string that
shows up between the unquoted delimiters that you want to be treated
as a NULL."  This removes the complexity of the question about quoting,
unquoting, whatever, and makes it a very clear-cut, straight-forward
solution with no impact on existing users, imv.

    Thanks,

        Stephen

Attachment

pgsql-patches by date:

Previous
From: Gregory Stark
Date:
Subject: Re: allow CSV quote in NULL
Next
From: Zdenek Kotala
Date:
Subject: pgcrypto