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

From Pavel Stehule
Subject Re: Re: csv format for psql
Date
Msg-id CAFj8pRAUT51U93sUYKRUTLSP=M0YwP+XRxNifd46OFuZFsZuow@mail.gmail.com
Whole thread Raw
In response to Re: Re: csv format for psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: Re: csv format for psql  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers


2018-03-26 14:44 GMT+02:00 Daniel Verite <daniel@manitou-mail.org>:
        Pavel Stehule wrote:

> implemented in attached patch

Consider your initial output of \pset, when no option is specified
=================
$ ./psql
psql (11devel)
Type "help" for help.

postgres=# \pset
border                   1
columns                  0
expanded                 off
fieldsep                 not used
fieldsep_zero            ERROR
footer                   on
format                   aligned
linestyle                ascii
null                     ''
numericlocale            off
pager                    1
pager_min_lines          0
recordsep                '\n'
recordsep_zero           off
reset                    ERROR
tableattr
title
tuples_only              off
unicode_border_linestyle single
unicode_column_linestyle single
unicode_header_linestyle single
================

These entries with ERROR correspond in fact to no error at all,
or we have to pretend that the default state of psql is erroneous,
which doesn't make sense.

Also "reset" is not a variable, it seems to be a command,
so it probably shouldn't be there in the first place.

fixed
 

More generally, I'd think the point of reusing "fieldsep" was to
reuse the concept, not reimplement it, let alone changing
bits of behavior of the unaligned mode along the way.

With this patch, again without specifying any option, just looking
at what fieldsep is leads to this:

postgres=# \pset fieldsep
User didn't specified field separator.
Current format doesn't specify default field separator.

If this is the way to "solve" the fact that a user has to do
 \pset fieldsep ','
to get commas in csv mode, then IMV the proposed solution
is clearly worse than the stated problem, and worse than
simply adding fieldsep_csv to be independant from the
unaligned mode.


I don't understand what is wrong there? There can be any message (short - just "unset",...). I understand so default visual can look strange, because aligned mode has not default field separator, but I don't see any other possibility.

Can I do some recapitulation:

1. using CSV with default | as field separator is wrong - probably there is a agreement

2. partial solution is fieldsep_X where X will be format name. It is better than using | for csv, but it introduces new problems:

a) there are not new long, short options for this value

b) the list of pset options is bloating - every possible new format can introduce fieldsep_X option

c) can be messy for people, because the setting fieldsep can has zero effect on csv or some other formats that don't share default with unaligned format.

So my position - I am very strong against to introduce CSV format with | as field separator, and I am not happy if we introduce fieldsep_X like options, because it is not too good too.

Regards

Pavel

 

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Hernandez
Date:
Subject: Re: Proposal: http2 wire format
Next
From: Amit Kapila
Date:
Subject: Re: [HACKERS] [PATCH] Vacuum: Update FSM more frequently