On 17 July 2015 at 03:42, Pavel Stehule <pavel.stehule@gmail.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
I don't see the point. Taking your 'sudo' issue into account, just:
sudo -u postgres psql <'__END__'
select pg_stat_reset();
vacuum full analyze;
__END__
or
echo -e 'select pg_stat_reset()\n vacuum full analyze;' | sudo -u postgres psql
or, of course, just run two commands.
There are plenty of existing ways to do this. Personally I find -c
awkward due to the need to worry about shell quoting and tend to
prefer a quoted here-document lots of the time anyway.
-- Craig Ringer http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services