X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6C6F59FA5F0 for ; Wed, 31 May 2006 12:28:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 61737-01 for ; Wed, 31 May 2006 12:28:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fetter.org (dsl092-188-065.sfo1.dsl.speakeasy.net [66.92.188.65]) by postgresql.org (Postfix) with ESMTP id 587ED9FA5DD for ; Wed, 31 May 2006 12:28:37 -0300 (ADT) Received: by fetter.org (Postfix, from userid 500) id 1755FC62BA; Wed, 31 May 2006 08:28:33 -0700 (PDT) Date: Wed, 31 May 2006 08:28:33 -0700 From: David Fetter To: Tom Lane Cc: pgsql-hackers@postgreSQL.org Subject: Re: Possible TODO item: copy to/from pipe Message-ID: <20060531152832.GB27220@fetter.org> References: <12436.1149087794@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12436.1149087794@sss.pgh.pa.us> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/1328 X-Sequence-Number: 84193 On Wed, May 31, 2006 at 11:03:14AM -0400, Tom Lane wrote: > After re-reading what I just wrote to Andreas about how compression > of COPY data would be better done outside the backend than inside, > it struck me that we are missing a feature that's fairly common in > Unix programs. Perhaps COPY ought to have the ability to pipe its > output to a shell command, or read input from a shell command. > Maybe something like > > COPY mytable TO '| gzip >/home/tgl/mytable.dump.gz'; That's a great syntax :) Similarly, COPY mytable FROM 'create_sample_data --table mytable --rows 10000000 |'; would be cool. > (I'm not wedded to the above syntax, it's just an off-the-cuff > thought.) It will be familiar to Perl users, for better or worse. Come to that, should the prefixes > and >> also mean their corresponding shell things? > Of course psql would need the same capability, since the server-side > copy would still be restricted to superusers. Roight. > You can accomplish COPY piping now through psql, but it's a bit awkward: > > psql -c "COPY mytable TO stdout" mydb | gzip ... > > Thoughts? Is this worth doing, or is the psql -c approach good enough? I think it's worth doing :) Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote!