psql - better support pipe line - Mailing list pgsql-hackers

From Pavel Stehule
Subject psql - better support pipe line
Date
Msg-id CAFj8pRBdu3uTC6wJefy5f_qNzn2Dr1ReGwc9Ey_wzVyggWo+rQ@mail.gmail.com
Whole thread Raw
Responses Re: psql - better support pipe line
List pgsql-hackers
Hi

I found so a set "psql" and "xargs" is pretty strong. But I miss a psql option for simple returning current database and continuing in pipeline.

What I am doing:

psql postgres -At -c "select datname from pg_database" |
xargs -P 3 -I % psql % -At -c "select current_databe() from pg_stat_all_tables
where relname = 'pg_attribute' and n_dead_tup > 100000" |
xargs -P 3 -I % sh -c "psql % -q -c 'analyze pg_attribute'; echo %" |
xargs -P 3 -I % psql % -At -c "select curren_database() from ..."

it works perfectly - but the line

xargs -P 3 -I % sh -c "psql % -q -c 'analyze pg_attribute'; echo %"

is little bit ugly - with some psql option it can be cleaned to

xargs -P3 -I % psql % -q --echo-db -c "analyze pg_attribute" | ...

--echo-db requires -q option

What are you thinking about this idea?

Regards

Pavel

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: checkpointer continuous flushing
Next
From: Stefan Kaltenbrunner
Date:
Subject: Re: (full) Memory context dump considered harmful