Re: Separate psql commands from arguments - Mailing list pgsql-hackers

From Decibel!
Subject Re: Separate psql commands from arguments
Date
Msg-id 6FFA4636-E6DD-4F85-A772-2DEEC2AB77A0@decibel.org
Whole thread Raw
In response to Re: Separate psql commands from arguments  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Separate psql commands from arguments  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
Am Samstag, 5. April 2008 schrieb Gregory Stark:
> On Apr 10, 2008, at 7:50 AM, Peter Eisentraut wrote:
>> I also don't see any point in allowing aliases which call other psql
>> commands.


Why disallow it? I think it could be very useful. One thing I  
sometimes find myself doing is wanting to run a command on a list of  
tables. That can be accomplished via:

SELECT 'ALTER TABLE ' || oid::regclass || 'blah;' FROM pg_class  
WHERE ...
\g | psql blah blah blah

I'd love to be able to alias something like that.

Another real example is being able to force certain output functions  
for certain queries. In particular, it would be handy if I had an  
alias that was SELECT now()-query_start,* FROM pg_stat_activity WHERE  
current_query != '<IDLE>' ORDER BY 1 and force that to be brought  
into less (which I could probably do via \g | less).
-- 
Decibel!, aka Jim C. Nasby, Database Architect  decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828



pgsql-hackers by date:

Previous
From: "Fabiana Prabhakar"
Date:
Subject:
Next
From: Decibel!
Date:
Subject: Re: Commit fest queue