Re: proposal: multiple psql option -c - Mailing list pgsql-hackers

From Marc Mamin
Subject Re: proposal: multiple psql option -c
Date
Msg-id B6F6FD62F2624C4C9916AC0175D56D8828C18B8B@jenmbs01.ad.intershop.net
Whole thread Raw
In response to Re: proposal: multiple psql option -c  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers

>
>
>2015-07-28 10:43 GMT+02:00 Marc Mamin <M.Mamin@intershop.de>:
>
>
>    >
>    >
>    >2015-07-28 5:24 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
>    >
>    >    2015-07-27 21:57 GMT+02:00 Andrew Dunstan <andrew@dunslane.net>:
>    >
>    >        On 07/27/2015 02:53 PM, Pavel Stehule wrote:
>    >
>    >            I am trying to run parallel execution
>    >
>    >            psql -At -c "select datname from pg_database" postgres | xargs -n 1 -P 3 psql -c "select current_database()"
>    >
>    >
>    >
>    >        I don't think it's going to be a hugely important feature, but I don't see a problem with creating a new option (-C seems fine) which would have the same effect as if the arguments were contatenated into a file which is then used with -f. IIRC -c has some special characteristics which means it's probably best not to try to extend it for this feature.
>    >
>    >
>    >    ok, I'll try to write patch.
>    >
>    >
>    >I have a question. Can be -C option multiple?
>
>
>    hello,
>    Have you thought of how to support -1 along with -C ?
>
>    > handle the input as with -f
>         that is, -1 -C would be equivalent to -c
>
>    and
>    psql -1 -C "sql_1; sql_2;" -C "sql_3; sql_4;"
>
>    => ?
>
>    BEGIN;         
>    sql_1;         
>    sql_2;         
>    END;         
>
>    BEGIN;
>    sql_3;
>    sql_4;
>    END;
>
>    thoughts ?
>
>
>"-1" option is global -, I expected so following steps are more natural
>
>BEGIN
>  sql_1;
>  sql_2;
>  sql_3;
>  sql_4;
>END;

This is then exactly the same as -c.
If introducing multiple -C to better manage transaction handling,
why not enrich this new feature with the abilities to define batches of transactions ?

Marc

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: pg_dump -Fd and compression level
Next
From: Kouhei Kaigai
Date:
Subject: Re: [DESIGN] ParallelAppend