Re: Re: csv format for psql

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, David Steele <david(at)pgmasters(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: csv format for psql
Date: 2018-03-23 04:55:22
Message-ID: CAFj8pRCBAf1qxoBWvs+rNDGQc73nguqr+5TeqTM_fA76pREHDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2018-03-22 20:10 GMT+01:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:

>
>
> 2018-03-22 19:28 GMT+01:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
>
>>
>>
>> 2018-03-22 18:38 GMT+01:00 Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>:
>>
>>>
>>> Hello Pavel,
>>>
>>> Using \pset format csv means overwriting field sep every time - nobody
>>>> uses
>>>> |
>>>>
>>>
>>> Yep. The alternative is to have a csv-specific separator variable, which
>>> does not seem very useful, must be remembered, but this is indeed debatable.
>>>
>>> I think so dependency on order of psql arguments is significant problem
>>>>
>>>
>>> This is intentional, and this issue/feature already exists, the last
>>> argument overwrite previous settings thus will win, eg:
>>>
>>> psql --pset=format=troff --html -c 'SELECT 1'
>>>
>>> Will output in html, not in troff.
>>>
>>
>> Can we introduce some format specific default separators - if we would
>> not to introduce csv_field_sep options?
>>
>> It should not be hard. All formats can has '|' like now, and csv can have
>> a ',' - then if field separator is not explicit, then default field
>> separator is used, else specified field separator is used.
>>
>> You can see my idea in attached patch
>>
>> Regards
>>
>> Pavel
>>
>> postgres=# \pset format csv
>> Output format is csv.
>> postgres=# select * from foo;
>> a,b,c
>> 1,2,Hello
>> 3,4,Nazdar
>> postgres=# \pset fieldsep ;
>> Field separator is ";".
>> postgres=# select * from foo;
>> a;b;c
>> 1;2;Hello
>> 3;4;Nazdar
>>
>>
>>
> The default fieldsep should be "off" that means so format defaults are
> used. ',' is used for CSV, | for any else.
>
> So all will work like now, but there will be bigger freedom with new
> format design. Now, all formats with possibility to setting fieldsep,
> should to share default '|', what I think, is not practical.
>

I can make patch, if there will be a agreement.

comments?

Regards

Pavel

>
>
>
>
>
>>
>>
>>
>>
>>>
>>> --
>>> Fabien.
>>>
>>
>>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2018-03-23 04:57:30 Re: [HACKERS] MERGE SQL Statement for PG11
Previous Message Andrew Dunstan 2018-03-23 04:49:38 Re: Faster inserts with mostly-monotonically increasing values