From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Daniel Verite <daniel(at)manitou-mail(dot)org> |
Cc: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, 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 18:44:19 |
Message-ID: | CAFj8pRB4Pi-JtYZ=LkScc4XqC+mP68oCjOuFb2jQozZhokKX3g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2018-03-23 12:59 GMT+01:00 Daniel Verite <daniel(at)manitou-mail(dot)org>:
> Pavel Stehule wrote:
>
> > 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
>
> With that patch, consider this sequence:
>
> postgres=# \pset format csv
> Output format is csv.
> postgres=# \pset fieldsep
> Field separator is "|".
> postgres=# select 1 as a,2 as b;
> a,b
> 1,2
>
> Here psql reports that fieldsep is "|" and right away is using something
> else in the output. That doesn't look good.
>
yes - my patch was proof concept - nothing more.
But this can be simply solved - if we have a table of default field
separator, then if separator is not explicit, then default for used format
is printed.
>
> You may object that it's fixable by tweaking the output of \pset,
> \pset fieldsep, and \? variables so that it knows that the current
> output format is going to use a "hidden" default separator, and
> then these commands should display that value instead.
> But that'd be somewhat playing whack-a-mole, as the following
> sequence would now be possible, with '|' being used as
> the separator instead of the ',' reported just above:
>
> postgres=# \pset format csv
> Output format is csv.
> postgres=# \pset fieldsep
> Field separator is ",".
> postgres=# \a
> Output format is aligned.
> postgres=# select 1 as a,2 as b;
> a | b
> ---+---
> 1 | 2
>
I am sorry, but path that I sent was just proof concept - I didn't
implement defaults for any other related formats.
I'll try to send cleaner patch tomorrow.
Regards
Pavel
>
>
> Best regards,
> --
> Daniel Vérité
> PostgreSQL-powered mailer: http://www.manitou-mail.org
> Twitter: @DanielVerite
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2018-03-23 18:51:08 | Re: Re: csv format for psql |
Previous Message | Tom Lane | 2018-03-23 18:33:25 | Re: Backend memory dump analysis |