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: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: VIP: new format for psql - shell - simple using psql in shell
Date: 2012-05-26 16:42:07
Message-ID: CAFj8pRAjicw-0qLUPtmnvRBjHU7wFe=su2cWD31r5qJfg-QGVw@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 05:39:23PM +0200, Pavel Stehule wrote:
>> Hello
>>
>> I proposed new psql's format "shell". This format is optimized for
>> processing returned result in shell:
>>
>>
>> postgres=# select * from foo;
>>       a       | b  |     c
>> --------------+----+------------
>>  Hello, World | 10 | 2012-05-26
>>  Ahoj, Svete  | 20 | 2012-06-15
>> (2 rows)
>>
>> postgres=# \pset format shell
>> Output format is shell.
>> postgres=# select * from foo;
>> a b c
>> Hello,\ World 10 2012-05-26
>> Ahoj,\ Svete 20 2012-06-15
>>
>> postgres=# \x
>> Expanded display is on.
>> postgres=# select * from foo;
>> ( c l )
>> ( [a]=Hello,\ World [b]=10 [c]=2012-05-26 )
>> ( [a]=Ahoj,\ Svete [b]=20 [c]=2012-06-15 )
> ...
>> ) | while read dbname owner encoding collate ctype priv;
>
> I am unclear exactly how this relates to shells.  Do shells read this
> via read?  I am unclear that would actually work.  What do the brackets
> mean?  Does read process \space as a non-space?
>

"read" can read multicolumn files, where space is separator and real
space is escaped. It is first sample.

Second example is related to Bash's feature - associative array
support - data has format that is same like assoc array

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-05-26 16:43:40 Re: VIP: new format for psql - shell - simple using psql in shell
Previous Message Tom Lane 2012-05-26 16:33:54 Re: No, pg_size_pretty(numeric) was not such a hot idea