Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 4DC7E13364DE for ; Wed, 16 Feb 2011 08:43:35 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 52216-01; Wed, 16 Feb 2011 12:43:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by mail.postgresql.org (Postfix) with ESMTP id 935CE133616B; Wed, 16 Feb 2011 08:43:27 -0400 (AST) Received: from 121-98-80-66.bitstream.orcon.net.nz ([121.98.80.66] helo=[192.168.1.2]) by tremor.opencloud.co.nz with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Ppgj4-0006oL-Aw; Thu, 17 Feb 2011 01:43:22 +1300 Message-ID: <4D5BC65D.8070507@opencloud.com> Date: Thu, 17 Feb 2011 01:43:09 +1300 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Robert Haas CC: Lukas Eder , rsmogura , pgsql-jdbc@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Fwd: [JDBC] Weird issues when reading UDT from stored function References: <201101111946.33083.rsmogura@softperience.eu> <4d7cc4033a655539995c240a6f282ab5@mail.softperience.eu> <4D33CD00.6000408@opencloud.com> <4D5BBD1A.7010005@opencloud.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201102/1513 X-Sequence-Number: 182302 On 17/02/11 01:10, Robert Haas wrote: > If you do SELECT function_with_one_out_parameter() rather than SELECT > * FROM function_with_one_out_parameter(), you'll get just one > argument. Does that help at all? Unfortunately, not really, because it doesn't work for cases where there's more than one OUT parameter (if you use the SELECT f() form in that case, you get one gigantic result column, not one column per OUT parameter) I dug into the code and it's actually slightly different to what I originally described. Currently given a JDBC escape of the form "{ call f(?,?,?,?) }" it will rewrite that to: "SELECT * FROM f($1,$2,$3,$4) AS RESULT" and this rewriting happens before we know which parameters are bound as OUT parameters. So we can't special-case the one-OUT-parameter case without quite a rewrite (no pun intended). Once we get to the point of query execution, we know which parameters are OUT parameters, and we bind void parameter values to those (v3 protocol). You have to do a PREPARE/EXECUTE to pass in void parameter types to get the equivalent via psql, as far as I can tell. Anyway, it's a bit counterintuitive that SELECT * FROM f($1,$2) AS RESULT where f() takes two OUT parameters always returns two columns, but SELECT * FROM f($1) AS RESULT might return any number of columns! Is that really the correct behavior here? Oliver