Thread: feature idea

feature idea

From
hubert depesz lubaczewski
Date:
hi

would it be possible to allow (in psql) syntax like:
\do = | grep ...
or even:
select * from table; | zcat - > /tmp/table.data.gz

i.e. - adding | ... at the end of command to send its output via pipe to
another program?

usecase that i had today was pretty simple - check list of operators
that are defined using "password" datatype.

generally - i could:
psql -c '\do' | grep -i password

but simple way of doing it from shell would be so much nicer.

we gave this feature already with \do - but i think it would be cool to
be able to do it on statement level - in more natural (to unix veterans)
way.

what do you think?

best regards,

depesz


--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

Re: feature idea

From
Steve Crawford
Date:
hubert depesz lubaczewski wrote:
> hi
>
> would it be possible to allow (in psql) syntax like:
> \do = | grep ...
> or even:
> select * from table; | zcat - > /tmp/table.data.gz
>
> ...

What's wrong with:

\o '| gzip -c - > foo.gz'
\d
\o


I use:
\o '|lpr'
all the time.

Cheers,
Steve

Re: feature idea

From
hubert depesz lubaczewski
Date:
On Mon, Oct 06, 2008 at 11:45:44AM -0700, Steve Crawford wrote:
> What's wrong with:
> \o '| gzip -c - > foo.gz'
> \d
> \o
> I use:
> \o '|lpr'
> all the time.

it's too long. and it requires disabling. i'd like something that would
work exactly like unix pipe - send input of one command to another.

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

Re: feature idea

From
Martijn van Oosterhout
Date:
On Mon, Oct 06, 2008 at 09:18:00PM +0200, hubert depesz lubaczewski wrote:
> it's too long. and it requires disabling. i'd like something that would
> work exactly like unix pipe - send input of one command to another.

Isn't this what \g does?

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

Re: feature idea

From
hubert depesz lubaczewski
Date:
On Mon, Oct 06, 2008 at 09:32:00PM +0200, Martijn van Oosterhout wrote:
> Isn't this what \g does?

only for queries. it doesn't work for psql builtins - like \do which i
used in my original mail.

best regards,

depesz


--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

Re: feature idea

From
Tom Lane
Date:
hubert depesz lubaczewski <depesz@depesz.com> writes:
> On Mon, Oct 06, 2008 at 11:45:44AM -0700, Steve Crawford wrote:
>> What's wrong with:
>> \o '| gzip -c - > foo.gz'
>> \d
>> \o

> it's too long. and it requires disabling. i'd like something that would
> work exactly like unix pipe - send input of one command to another.

The fact that it's possible now means that the case for adding syntax
for it is extremely weak.  You'd need to convince people that this is so
useful that we should go to the trouble of figuring out how to shoehorn
it into the syntax of every backslash command (and in at least some
cases that'd be pretty tricky).  Given that it never got requested
before, I think it'll be hard to show that.

            regards, tom lane

Re: feature idea

From
Klint Gore
Date:
hubert depesz lubaczewski wrote:
> hi
>
> would it be possible to allow (in psql) syntax like:
> \do = | grep ...
> or even:
> select * from table; | zcat - > /tmp/table.data.gz
>
> i.e. - adding | ... at the end of command to send its output via pipe to
> another program?
>
> usecase that i had today was pretty simple - check list of operators
> that are defined using "password" datatype.
>
> generally - i could:
> psql -c '\do' | grep -i password
>
> but simple way of doing it from shell would be so much nicer.
>
> we gave this feature already with \do - but i think it would be cool to
> be able to do it on statement level - in more natural (to unix veterans)
> way.
>
> what do you think?
>

Maybe pgbash is what you are looking for.

There were recent posts about it that can get to its home page.  Looks
like it will need some work to bring it up to current.
http://archives.postgresql.org/pgsql-general/2008-09/msg01234.php

klint.

--
Klint Gore
Database Manager
Sheep CRC
A.G.B.U.
University of New England
Armidale NSW 2350

Ph: 02 6773 3789
Fax: 02 6773 3266
EMail: kgore4@une.edu.au