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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: depesz(at)depesz(dot)com
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-27 13:16:28
Message-ID: CAFj8pRAqD2bqiW=7BmVhhmcbacLmshdr7t=Y26VMN-mPkgnHFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

2012/5/27 hubert depesz lubaczewski <depesz(at)depesz(dot)com>:
> 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:
>
> While I generally like the idea, please note that safe reading output
> from queries is possible, with COPY, and proper IFS, like:

I newer say so it is impossible

>
> =$ psql -c "select * from t"
>  a  |  b  |     c
> ----+-----+-----------
>  a1 | b 2 | c|3
>  a +| b  +| c:|     6
>  4  | 5  +|
>    |     |
> (2 rows)
>
>
> =$ psql -qAtX -c "copy (select * from t) to stdout" | while IFS=$'\t' read -r a b c; do echo -e "a=[$a] b=[$b] c=[$c]"; done
> a=[a1] b=[b 2] c=[c|3]
> a=[a
> 4] b=[b
> 5
> ] c=[c:|        6]
>

I know about this feature

http://archives.postgresql.org/pgsql-hackers/2012-05/msg01169.php

but may "shell format" patch is very simple and can really simplify
usage in shell.

> that being said - I would love to get more functional psql.

This patch doesn't break anything - and it is only 30 lines of non
invasive simple code.

Implementation of statements to psql is probably long task - I wrote
prototype - but I have not time finish it and push to core.

Regards

Pavel
>
> Best regards,
>
> depesz
>
> --
> The best thing about modern society is how easy it is to avoid contact with it.
>                                                             http://depesz.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2012-05-27 13:45:54 Re: No, pg_size_pretty(numeric) was not such a hot idea
Previous Message Andrew Dunstan 2012-05-27 12:48:54 Re: pg_upgrade libraries check