Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 864CD1337B4F for ; Thu, 17 Feb 2011 08:16:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 70746-02; Thu, 17 Feb 2011 12:16:06 +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 E33871336FA7; Thu, 17 Feb 2011 08:16:05 -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 1Pq2m1-00048U-Kt; Fri, 18 Feb 2011 01:15:53 +1300 Message-ID: <4D5D1168.2040209@opencloud.com> Date: Fri, 18 Feb 2011 01:15:36 +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: Florian Pflug CC: Tom Lane , Robert Haas , Lukas Eder , rsmogura , pgsql-jdbc@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Fwd: [JDBC] Weird issues when reading UDT from stored function References: <4D33CD00.6000408@opencloud.com> <4D5BBD1A.7010005@opencloud.com> <4D5BC65D.8070507@opencloud.com> <24907.1297869823@sss.pgh.pa.us> <4D5C6876.7060805@opencloud.com> <4D5CF52B.9020707@opencl oud.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.89 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_FILL_THIS_FORM_SHORT=0.01 X-Spam-Level: X-Archive-Number: 201102/1664 X-Sequence-Number: 182453 On 18/02/11 01:08, Florian Pflug wrote: >> Well, the JDBC driver does know how many OUT parameters there are before execution happens, so it could theoretically do something different for 1 OUT vs. many OUT parameters. > > Right, I had forgotten that JDBC must be told about OUT parameter with registerOutputType() > >> The problem is that currently the translation of the JDBC "{ call }" escape happens early on, well before we know which parameters are OUT parameters. Moving that translation later is, at best, tricky, so I was hoping there was one query form that would handle all cases. > > Hm, now I'm confused. Even leaving the single-OUT-parameter problem aside, the JDBC statement {call f(?,?)} either translates to > SELECT * FROM f($1) > or > SELECT * FROM f($1, $2) > depending on whether one of the parameter is OUT. Without knowing the number of output parameters, how do you distinguish these two cases? Currently it always includes *all* parameters in the call, regardless of the number of OUT parameters (as mentioned, it doesn't even know how many OUT parameters there are at that point). As we discover OUT parameters, we bind void types to them, and the server does the rest of the heavy lifting. Something roughly equivalent to this: > testdb=# PREPARE s1(void) AS SELECT * FROM p_enhance_address4($1); -- function has no IN parameters, one OUT parameter > PREPARE > testdb=# EXECUTE s1(null); > street | zip | city | country | since | code > ------------------------+--------+-----------+---------+------------+------ > ("Parliament Hill",77) | NW31A9 | Hampstead | England | 1980-01-01 | > (1 row) Oliver