Re: proposal: multiple psql option -c

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: "'Pavel Stehule'" <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: multiple psql option -c
Date: 2015-07-17 14:44:36
Message-ID: B6F6FD62F2624C4C9916AC0175D56D8828C071AB@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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?

Hi,
Can't you handle this with a script on the target server ?

I have this one due to a profile issue:

cat cicrunpsql.sh
#!/bin/sh

# set the isdbx environment before calling psql with the passed arguments.
# required for remote calls with ssh

#example
# cicrunpsql.sh -Uisdb3 -c "select1"
# ssh isdb3(at)localhost cicrunpsql.sh -Uisdb3 -c "select1"

# remote calls per ssh do not get the profile automatically...
. ~/.profile || exit 1

psql "$@"

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2015-07-17 14:57:10 Re: RFC: replace pg_stat_activity.waiting with something more descriptive
Previous Message Shulgin, Oleksandr 2015-07-17 14:40:39 Re: [PATCH] Generalized JSON output functions