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 16:27:31 |
Message-ID: | 407AC373.2010106@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Bruce Momjian wrote:
>Andrew Dunstan wrote:
>
>
>>In fact, in the patch I sent in, no quoted string is marked as null when
>>being read (so even if you use \N as the null marker, "\N" will be that
>>literal and not a null marker). And the null marker, whatever it is,
>>should be made quote safe by us throwing an error if it contains the
>>quote marker, just as we now make sure that the null marker is
>>delimiter-safe.
>>
>>
>
>What value does an int column get if the input file has ',,'. Don't
>tell me zero? :-) Error?
>
>
If the null marker is not an empty string, it gets an error, of course -
if it is it gets a null:
[andrew(at)marmaduke pginst]$ echo ',,' | bin/psql -c "create temp table
foo (a int, b text, c text); copy foo from stdin delimiter ',\"' null
'\\\\N';"
ERROR: invalid input syntax for integer: ""
CONTEXT: COPY foo, line 1, column a: ""
[andrew(at)marmaduke pginst]$ echo ',,' | bin/psql -c "create temp table
foo (a int, b text, c text); copy foo from stdin delimiter ',\"' ;"
[andrew(at)marmaduke pginst]$
I hope that is expected behaviour - it's what *I* expect, at least.
>
>
>>I will check on the write behaviour - it might need ammending too.
>>
>>I'll submit a revised patch based on the original syntax scheme, and
>>then you (Bruce) can make the syntax/psql changes that seem to be agreed
>>on now - is that ok?
>>
>>
>
>OK, go as far as you want and post it. I will turn around a new patch
>in a few hours after you post.
>
>
>
>>The default NULL value issue can be determined at the end of any
>>exhaustive debate we have - in the end it's a one line code change ;-)
>>
>>
>
>Agreed.
>
>
>
Attached patch has these additions to previously posted patch:
. quote character may not appear in NULL marker
. any non-null value that matches the NULL marker is forced to be quoted
when written.
cheers
andrew
Attachment | Content-Type | Size |
---|---|---|
csv.patch | text/plain | 12.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2004-04-12 16:59:52 | Re: COPY for CSV documentation |
Previous Message | Bruce Momjian | 2004-04-12 16:19:40 | Re: [PATCHES] New socket code for win32 |