Re: VIP: new format for psql - shell - simple using psql in shell

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: VIP: new format for psql - shell - simple using psql in shell
Date: 2012-05-27 03:16:20
Message-ID: CAFj8pRCkLh_kV13ARaEySz7uX+41uRNYzdRDSMArWe-c4HxJxA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/5/26 Bruce Momjian <bruce(at)momjian(dot)us>:
> On Sat, May 26, 2012 at 12:43:40PM -0400, Tom Lane wrote:
>> Bruce Momjian <bruce(at)momjian(dot)us> writes:
>> > On Sat, May 26, 2012 at 05:39:23PM +0200, Pavel Stehule wrote:
>> >> I proposed new psql's format "shell". This format is optimized for
>> >> processing returned result in shell:
>>
>> > I am unclear exactly how this relates to shells.
>>
>> What I'm unclear on is why we'd want to encourage that style of
>> programming.  The most charitable prediction of performance is that it
>> would suck --- not only do you have all the inefficiencies inherent in
>> row-by-row result processing with a shell script, but you're forcing a
>> separate database connection for each query.  And I don't actually see
>> where it would be especially convenient to use, compared to say perl
>> or python or other scripting languages.  I'd rather see us worrying
>> about the convenience of cases like
>
> Wouldn't you just us unaligned mode for this, and set IFS  to '|'?
>
>        $ psql --no-align --tuples-only -c 'SELECT 1,2' test
>        1|2
>
>        $ export IFS="|"
>        $ IFS='|' sql --no-align --tuples-only -c 'SELECT 1,2' test |
>        while read x y; do echo $x; echo $y; done
>        1
>        2
>
> Are you worried about pipes in data?  Does you idea fix this?

I can do use IFS, but it is not easy when you would to work with
multicolumn tables - because you have to two IFS. Processing single
column tables is simple now - difference is in multicolumn tables.

My idea is secure to separator - because separator is just space and
new line and these symbols are escaped.

Regards

Pavel

>
> --
>  Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
>  EnterpriseDB                             http://enterprisedb.com
>
>  + It's impossible for everything to be true. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2012-05-27 03:18:32 Re: VIP: new format for psql - shell - simple using psql in shell
Previous Message Daniel Farina 2012-05-27 01:00:32 Re: --disable-shared is entirely broken these days