Re: allow CSV quote in NULL

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: allow CSV quote in NULL
Date: 2007-07-27 11:38:47
Message-ID: 20070727113847.GJ4887@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

* Gregory Stark (stark(at)enterprisedb(dot)com) wrote:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
> > Stephen Frost <sfrost(at)snowman(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-07-27 12:17:23 Re: LSN grouping within clog pages
Previous Message Gregory Stark 2007-07-27 09:22:42 Re: allow CSV quote in NULL

Browse pgsql-patches by date

  From Date Subject
Next Message Zdenek Kotala 2007-07-27 13:00:29 pgcrypto
Previous Message Gregory Stark 2007-07-27 09:22:42 Re: allow CSV quote in NULL