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

From Fabien COELHO
Subject Re: Re: csv format for psql
Date
Msg-id alpine.DEB.2.20.1803231841580.13537@lancre
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  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Hello Daniel,

>> Do you know when you'll have an updated patch that addresses the minor
>> issues brought up in review and the concern above?
>
> Here's an update addressing the issues discussed:
>
> - fieldsep and recordsep are used, no more fieldsep_csv
> - the command line option is --csv without short option and is equivalent
> to -P format=csv -P fieldsep=','
> - pset output formats are reordered alphabetically on display
> - a couple more cases in the regression tests

Patch applies cleanly, compiles, doc gen ok, "make check" ok.

The patch adds a simple way to generate csv output from "psql" queries, 
much simpler than playing around with COPY or \copy. It allows to generate 
a clean CSV dump from something as short as:

   sh> psql --csv -c 'TABLE foo' > foo.csv

Documentation is clear.

Test cover a significant number of cases (fieldsep, expanded, tuples-only).
Although recordsep changes are not actually tested, it worked interactively
and I think that tests are sufficient as is.

There are somehow remaining point about which a committer/other people input
would be nice:

(1) There are some mild disagreement whether the fieldsep should be format
     specific shared with other format. I do not think that a specific fieldsep
     is worth it, but this is a marginal preference, and other people opinion
     differ. What is best is not obvious.

     Pavel also suggested to have a special handling based on whether
     the fieldsep is explicitely set or not. I'm not too keen on that because
     it departs significantly from the way psql formatting is currently
     handled, and what is happening becomes unclear to the user.

(2) For interactive use, two commands are required: \pset format csv +
     \pset fieldsep ',' (or ';' or '\t' or whatever...). Maybe some \csv
     command similar  to \H would be appropriate, or not, to set both values
     more efficiently. Could be something for another patch.

Not sure what is the status of the patch if we do not have a clear 
consensus.

-- 
Fabien.


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Backend memory dump analysis
Next
From: Vladimir Sitnikov
Date:
Subject: Re: Backend memory dump analysis