Re: csv format for psql - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: csv format for psql
Date
Msg-id alpine.DEB.2.21.1808230905490.31897@lancre
Whole thread Raw
In response to Re: csv format for psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: csv format for psql
List pgsql-hackers
Bonjour Daniel,

> '\n' gets translated by libc when the output is in text mode.
> We discussed this upthread, but maybe it should be a code comment:
> added now.

My point was more about the documentation which should be clear about what 
is the EOL. I understand from your point above that the EOL is the 
platform-specific one, which is yet again fine with me, but should be said 
clearly in the documentation?

>> There seems to be a test in the code to set an empty string "" by 
>> default, but it is unclear to me when this is triggered.
>
> Where is that code?

  + else if (strcmp(param, "fieldsep_csv") == 0)
  +     return pset_quoted_string(popt->topt.fieldSepCsv
  +                               ? popt->topt.fieldSepCsv
  +                               : "");

It is unclear to me when this "" is triggered. Never? If so, maybe a 
comment should say so?

A few comments about v6: Patch applies cleanly, make check ok, doc build 
ok.

Why removing "-C"? As we already have "-A" an "-H", I was fine with it.

It seems that you changed the indentation in "psql-ref.sgml":

       </varlistentry>
  -    <varlistentry>
  +     <varlistentry>

but maybe this is just the previous entry which was misaligned...

  -  {"unaligned", "aligned", "wrapped", "html", "asciidoc",
  -   "latex", "latex-longtable", "troff-ms", NULL};
  +  {"aligned", "asciidoc", "csv", "html", "latex", "latex-longtable",
  +   "unaligned", "troff-ms", "wrapped", NULL};

If you want alphabetical, 'u' > 't'.

While testing I found a small issue if "fieldsep_csv" is set to a strange 
value:

   \pset format_csv ',,'
   SELECT ',', ',';
   -- gives the ambiguous:
   ,,,,

The rule to decide whether to quote should be made safer/smarter. I'd 
suggest that if the string contains any of the caracters used in format 
csv it should be quoted.

-- 
Fabien.


pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: [HACKERS] proposal: schema variables
Next
From: Pavel Stehule
Date:
Subject: Re: [HACKERS] proposal: schema variables