Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 411879F9DFF for ; Tue, 21 Aug 2007 13:21:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 35347-02 for ; Tue, 21 Aug 2007 13:21:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.190]) by postgresql.org (Postfix) with ESMTP id 958949F9DDC for ; Tue, 21 Aug 2007 13:21:04 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so1199786rvb for ; Tue, 21 Aug 2007 09:21:03 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=cSceKLHR9GftYw0cqR1Vqu/fjJgapFYfDPCc2eL7QDM4/R7XbzlXDKPeIGDGaefHclh+DXgIvdDrvr7kkhSz5K2TmThuRJP7eI1AMzPnpzH8/eXmQY5GDvadKqrcW/GmUNj9NCiQ6iCiu7Yz8x8x2pudZ/ZVPMoYvnEv61xADE8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=RJrIhvonkZwLnBj1u9zfVmGqEeQY3SkERIDC9MeignTqSFiVqjGJeY6LgVC5r9e2qj7phyuFpJJSKmFmz74qHm8C8WndKFkHcOdhnMXq9cvnI63DoZHtx1Ru1rtW86DF3LANmPvhxSi+ZD2RDlqQrZ72lfUrENzPe0fO+7r4kKg= Received: by 10.141.107.13 with SMTP id j13mr3480115rvm.1187713263596; Tue, 21 Aug 2007 09:21:03 -0700 (PDT) Received: by 10.141.98.12 with HTTP; Tue, 21 Aug 2007 09:21:03 -0700 (PDT) Message-ID: Date: Tue, 21 Aug 2007 11:21:03 -0500 From: "Scott Marlowe" To: "Chris Hoover" Subject: Re: How to export query results Cc: "pgsql-admin@postgresql.org Admin" In-Reply-To: <1d219a6f0708210909t663a6a1al8c25bd6f76c99031@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1d219a6f0708210754v456fecaer68d0420cf2526c12@mail.gmail.com> <1d219a6f0708210909t663a6a1al8c25bd6f76c99031@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/257 X-Sequence-Number: 26588 On 8/21/07, Chris Hoover wrote: > On 8/21/07, Scott Marlowe wrote: > > > > Yes. you need to use the copy command inside a function and use > > security definer to say that the function runs as a superuser. > > > > > Ok, I thought from the documentation that copy could only extract entire > table or a specific column. > > If I want to extract this: > > select x.name,x.create_date > from x > where x.id = new.id > > how do I get copy to do this (simple example, I know)? Well, there are a couple of ways to approach this. One is to select it into a temp table and then copy that to a file. Another would be to use an untrusted pl language (plperlu etc...) to do it.