Re: psql - better support pipe line

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql - better support pipe line
Date: 2015-08-24 20:04:25
Message-ID: CAFj8pRD9TUw0oJC_4eph23CTQVKpY-54oxXWzuy0TRnJPaH9fQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-08-24 16:02 GMT+02:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> > On 08/24/2015 08:06 AM, Pavel Stehule wrote:
> >> 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?
>
> > Seems like a one-tricky-pony to me. You're just as likely to need to
> > print a relation name or something else, as the current database.
>
> Not only that, but:
>
> (1) there is no reason to believe that the db name and only the db name
> is needed to do another connection; what about port, host, user, etc?
>

I have to agree - the possibilities is much more than database name - so
one option is not good idea.

>
> (2) this commandeers the pipe connection to transmit out-of-band data,
> making it impossible to use the pipe for its natural function, viz
> transmitting ordinary data from one processing step to the next. Sure,
> there are use-cases where there's no such data and you can repurpose the
> pipe like that, but that's an enormous limitation.
>

I wrote some bash or perl scripts and I don't think so described style is
less readable than other.

But it has one pretty advantage - paralelism without any line more, without
higher complexity.

Regards

Pavel

>
> > Overall, once your pipeline gets that complicated, I'd rather write a
> > little bash or perl script with for-loops and variables.
>
> Yeah, on the whole this seems like a band-aid to let a bad scripting
> approach limp a few steps further before it collapses completely.
>

>
> regards, tom lane
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-08-24 22:27:15 Re: PostgreSQL for VAX on NetBSD/OpenBSD
Previous Message Greg Stark 2015-08-24 18:55:52 Re: PostgreSQL for VAX on NetBSD/OpenBSD