Skip site navigation (1) Skip section navigation (2)

Re: [PATCHES] allow CSV quote in NULL

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] allow CSV quote in NULL
Date: 2007-07-27 16:03:19
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
[redirecting to -hackers]

Stephen Frost wrote:
> * 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?

Not very, no :-)
>> 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.

This looks too clever by half, to me. Someone facing the problem you are 
facing would have to dig quite deep to find the solution you're promoting.

A much better way IMNSHO would be to add an extra FORCE switch. On 
input, FORCE NOT NULL says to treat an unquoted null as the literal 
value rather than as a null field for the columns named. The reverse 
would be to tell it to treat a quoted null as null rather than as the 
literal value, for the named columns. Perhaps that should just be "FORCE 
NULL columnlist". It would be more explicit and at the same time would 
only apply to the named columns, rather than discarding totally the 
ability to distinguish between null and not null values.

This should probably be discussed on -hackers, anyway.



In response to


pgsql-hackers by date

Next:From: Gregory StarkDate: 2007-07-27 17:17:21
Subject: Re: [HACKERS] Document and/or remove unreachable code in tuptoaster.c from varvarlena patch
Previous:From: Simon RiggsDate: 2007-07-27 15:49:05
Subject: Re: stats_block_level

pgsql-patches by date

Next:From: Erwin BrandstetterDate: 2007-07-27 16:17:19
Subject: Obsolete bits in docs for SQL-GRANT
Previous:From: Gregory StarkDate: 2007-07-27 15:36:22
Subject: Document and/or remove unreachable code in tuptoaster.c from varvarlena patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group