Re: proposal: multiple psql option -c

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: dinesh kumar <dineshkumar02(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: multiple psql option -c
Date: 2015-07-17 03:18:34
Message-ID: CAFj8pRD5b0WZBw8p-8vvvjhFHhhEO1uBvDi_apkygj2t_j9gaw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-07-17 0:03 GMT+02:00 dinesh kumar <dineshkumar02(at)gmail(dot)com>:

> On Thu, Jul 16, 2015 at 12:42 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
>> Hi
>>
>> can we support multiple "-c" option?
>>
>> Why? Because some statements like VACUUM cannot be used together with any
>> other statements with single -c option. The current solution is using echo
>> and pipe op, but it is a complication in some complex scripts - higher
>> complication when you run psql via multiple sudo statement.
>>
>> Example:
>>
>> psql -c "select pg_stat_reset()" -c "vacuum full analyze" dbname
>>
>> or on all db
>>
>> psql -At -c "select datname from pg_databases" postgres | \
>> xargs -n 1 -P 3 psql -c "..." -c "..."
>>
>> Ideas, notes, comments?
>>
>>
> IMO, rather having multiple -c args, it would be good to have another flag
> like "-C" which do accept and execute multiple SQL statements in sequential.
>

it is one possible solution too

multiple -c option has advantage of simple evaluation of backslash
statements .. -c "\l" -c "\dt" - but this advantage is not high important.

Pavel

>
> Best Regards,
> Dinesh
> manojadinesh.blogspot.com
>
>
>> Regards
>>
>> Pavel
>>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2015-07-17 03:20:14 Re: Support for N synchronous standby servers - take 2
Previous Message Robert Haas 2015-07-17 03:17:52 Re: Re: [COMMITTERS] pgsql: Map basebackup tablespaces using a tablespace_map file