Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 01B989FA14D; Tue, 24 Oct 2006 09:47:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 91340-02; Tue, 24 Oct 2006 12:47:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from gmp-ea-fw-1.sun.com (gmp-ea-fw-1.sun.com [192.18.1.36]) by postgresql.org (Postfix) with ESMTP id 75EF59F9F77; Tue, 24 Oct 2006 09:47:01 -0300 (ADT) Received: from d1-emea-09.sun.com ([192.18.2.119]) by gmp-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id k9OCkxs4001255; Tue, 24 Oct 2006 13:46:59 +0100 (BST) Received: from conversion-daemon.d1-emea-09.sun.com by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0J7N002014SGQZ00@d1-emea-09.sun.com> (original mail from Zdenek.Kotala@Sun.COM); Tue, 24 Oct 2006 13:46:59 +0100 (BST) Received: from [129.150.120.213] by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPSA id <0J7N00EOX4UAOBRW@d1-emea-09.sun.com>; Tue, 24 Oct 2006 13:46:59 +0100 (BST) Date: Tue, 24 Oct 2006 14:43:20 +0200 From: Zdenek Kotala Subject: Re: [HACKERS] COPY does not work with regproc and aclitem In-reply-to: <27990.1161634170@sss.pgh.pa.us> To: Tom Lane Cc: Alvaro Herrera , pgsql-hackers@postgresql.org, pgsql-patches@postgresql.org Message-id: <453E0A68.4070506@sun.com> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_RUBdKsbwh4feq8pTxq+lEw)" References: <453D1B73.2050906@sun.com> <20061023200200.GD11409@alvh.no-ip.org> <27990.1161634170@sss.pgh.pa.us> User-Agent: Mail/News 1.5 (X11/20051211) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200610/137 X-Sequence-Number: 21461 This is a multi-part message in MIME format. --Boundary_(ID_RUBdKsbwh4feq8pTxq+lEw) Content-type: text/plain; format=flowed; charset=ISO-8859-15 Content-transfer-encoding: 7BIT Tom Lane wrote: > Alvaro Herrera writes: >> Hmm, maybe it should be using regprocedure instead? > > Not unless you want to break initdb. The only reason regproc still > exists, really, is to accommodate loading of pg_type during initdb. > Guess what: we can't do type lookup at that point. > I prepared patch which use oid output function instead regproc output. This change works only for COPY TO command. SELECT behavior is untouched. I extended copy regression test as well. Please, look on it if it is acceptable fix. With regards Zdenek --Boundary_(ID_RUBdKsbwh4feq8pTxq+lEw) Content-type: text/x-patch; name=copy.patch Content-transfer-encoding: 7BIT Content-disposition: inline; filename=copy.patch Index: src/backend/commands/copy.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/commands/copy.c,v retrieving revision 1.271 diff -c -r1.271 copy.c *** src/backend/commands/copy.c 31 Aug 2006 03:17:50 -0000 1.271 --- src/backend/commands/copy.c 24 Oct 2006 12:35:45 -0000 *************** *** 1309,1315 **** &out_func_oid, &isvarlena); else ! getTypeOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena); fmgr_info(out_func_oid, &cstate->out_functions[attnum - 1]); --- 1309,1317 ---- &out_func_oid, &isvarlena); else ! /* For regproc datatype do not lookup proc name, use OID out function instead. ! It avoids problem with COPY FROM. */ ! getTypeOutputInfo(attr[attnum - 1]->atttypid == REGPROCOID? OIDOID : attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena); fmgr_info(out_func_oid, &cstate->out_functions[attnum - 1]); Index: src/test/regress/input/copy.source =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/input/copy.source,v retrieving revision 1.14 diff -c -r1.14 copy.source *** src/test/regress/input/copy.source 2 May 2006 11:28:56 -0000 1.14 --- src/test/regress/input/copy.source 24 Oct 2006 12:35:46 -0000 *************** *** 105,107 **** --- 105,113 ---- copy copytest3 to stdout csv header; + --- test correct handling regproc data type + CREATE TEMP TABLE test_regproc (like pg_aggregate); + COPY pg_catalog.pg_aggregate TO '@abs_builddir@/results/test_regproc.data'; + COPY test_regproc FROM '@abs_builddir@/results/test_regproc.data'; + + select aggfnoid, cast(aggfnoid as oid) from pg_aggregate where aggfnoid=2147; Index: src/test/regress/output/copy.source =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/output/copy.source,v retrieving revision 1.12 diff -c -r1.12 copy.source *** src/test/regress/output/copy.source 2 May 2006 11:28:56 -0000 1.12 --- src/test/regress/output/copy.source 24 Oct 2006 12:35:46 -0000 *************** *** 70,72 **** --- 70,82 ---- c1,"col with , comma","col with "" quote" 1,a,1 2,b,2 + --- test correct handling regproc data type + CREATE TEMP TABLE test_regproc (like pg_aggregate); + COPY pg_catalog.pg_aggregate TO '@abs_builddir@/results/test_regproc.data'; + COPY test_regproc FROM '@abs_builddir@/results/test_regproc.data'; + select aggfnoid, cast(aggfnoid as oid) from pg_aggregate where aggfnoid=2147; + aggfnoid | aggfnoid + ------------------+---------- + pg_catalog.count | 2147 + (1 row) + --Boundary_(ID_RUBdKsbwh4feq8pTxq+lEw)--