Re: csv format for psql

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: csv format for psql
Date: 2018-08-23 08:30:05
Message-ID: alpine.DEB.2.21.1808230905490.31897@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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

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>

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

\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.


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-08-23 08:44:10 Re: [HACKERS] proposal: schema variables
Previous Message Fabien COELHO 2018-08-23 08:17:28 Re: [HACKERS] proposal: schema variables