Re: pgsql: Add regression tests for CSV and \., and add

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: momjian(at)postgresql(dot)org, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Add regression tests for CSV and \., and add
Date: 2005-12-28 15:09:24
Message-ID: 200512281509.jBSF9OE29574@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Andrew Dunstan wrote:
> Andrew Dunstan said:
> > Bruce Momjian said:
> >> Log Message:
> >> -----------
> >> Add regression tests for CSV and \., and add automatic quoting of a
> single column dump that has a \. value, so the load works properly. I also
> added documentation describing this issue.
> >>
> >
> > This seems unnecessarily elaborate, in code that is already byzantine. I
> think we can safely quote *any* field that has \. regardless of whether or
> not it is a singleton. There's no need to make a single column a special
> case - if it's valid for a singleton it's valid for any, and vice versa.
> >
>
>
> Now that I've woken up properly I realise that it's also just wrong - it
> will miss the case we need to catch of the first column of a multi-column
> line beginning with \. - just treat them all the same and all will be well.
>
> Also, this test is suspicious:
>
> strcmp(string, "\\.") == 0
>
> Don't we also want to quote it if the field reads \.x ?
> strncmp(string, "\\.",2) == 0
> seems like it would be a better test.

Have you looked at the regression tests I added? \.x will no longer be
interpreted as an end-of-data marker:

COPY testeoc FROM stdin CSV;
a\.
\.b
c\.d
"\."
\.

COPY testeoc TO stdout CSV;
a\.
\.b
c\.d
"\."

Our documentation says \. must appear alone on a line. With non-CSV, we
allow \. to appear on the end of a line too because it can not be a data
value, but for CSV, we have to enforce that.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2005-12-28 15:36:20 Re: pgsql: Add regression tests for CSV and \., and add
Previous Message Bruce Momjian 2005-12-28 15:07:13 pgsql: Add COPY CSV test that tests CSV output of \.