Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 92AE3B5DBD0 for ; Sun, 18 Sep 2011 23:55:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 45978-06 for ; Mon, 19 Sep 2011 02:55:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id DAF69B5DBCE for ; Sun, 18 Sep 2011 23:55:10 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p8J2tAdj011041 for ; Mon, 19 Sep 2011 02:55:10 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p8J2tAX0011023; Mon, 19 Sep 2011 02:55:10 GMT (envelope-from www) Date: Mon, 19 Sep 2011 02:55:10 GMT Message-Id: <201109190255.p8J2tAX0011023@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6213: COPY does not work as expected in a plpgsql function From: "Ramanujam" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201109/111 X-Sequence-Number: 31128 The following bug has been logged online: Bug reference: 6213 Logged by: Ramanujam Email address: innomotive@gmail.com PostgreSQL version: 9.0 Operating system: linux x86_64 Description: COPY does not work as expected in a plpgsql function Details: A function like this: CREATE OR REPLACE FUNCTION test(parm character varying(3)) RETURNS SETOF integer AS $BODY$ BEGIN COPY (SELECT $1) TO '/tmp/test.txt' CSV; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 100; Throws an error: NUM:42P02, DETAILS:there is no parameter $1 Substrituting $1 with parm gives this error: NUM:42703, DETAILS:column "parm" does not exist