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 658769FA5DC for ; Thu, 1 Jun 2006 09:39:20 -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 97799-03 for ; Thu, 1 Jun 2006 09:39:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from outland.mohawksoft.com (unknown [64.46.156.80]) by postgresql.org (Postfix) with ESMTP id C72C29FA040 for ; Thu, 1 Jun 2006 09:39:11 -0300 (ADT) Received: from outland.mohawksoft.com (outland.mohawksoft.com [127.0.0.1]) by outland.mohawksoft.com (8.13.6/8.9.3) with ESMTP id k51Cr41u007782; Thu, 1 Jun 2006 08:53:04 -0400 Received: (from mohawk@localhost) by outland.mohawksoft.com (8.13.6/8.13.3/Submit) id k51CqxUl007781; Thu, 1 Jun 2006 08:52:59 -0400 X-Authentication-Warning: outland.mohawksoft.com: mohawk set sender to pgsql@mohawksoft.com using -f Received: from 24.91.171.78 (SquirrelMail authenticated user pgsql) by mail.mohawksoft.com with HTTP; Thu, 1 Jun 2006 08:52:59 -0400 (EDT) Message-ID: <18397.24.91.171.78.1149166379.squirrel@mail.mohawksoft.com> In-Reply-To: <12436.1149087794@sss.pgh.pa.us> References: <12436.1149087794@sss.pgh.pa.us> Date: Thu, 1 Jun 2006 08:52:59 -0400 (EDT) Subject: Re: Possible TODO item: copy to/from pipe From: "Mark Woodward" To: "Tom Lane" Cc: pgsql-hackers@postgresql.org User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/7 X-Sequence-Number: 84240 > 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'; > > (I'm not wedded to the above syntax, it's just an off-the-cuff thought.) > > Of course psql would need the same capability, since the server-side > copy would still be restricted to superusers. > > 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? To be honest, I don't see much benefit in it. You can already accomplish what you want to accomplish easily enough. If you want to muck with COPY, I'd like to see it accept a query as: psql -c "COPY select * from mytable where foo='bar' TO stdout" mydb | gzip ...