Re: Fwd: [JDBC] Weird issues when reading UDT from stored function

From: Lukas Eder <lukas(dot)eder(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Oliver Jowett <oliver(at)opencloud(dot)com>, rsmogura <rsmogura(at)softperience(dot)eu>, pgsql-jdbc(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Date: 2011-02-16 12:16:32
Message-ID: AANLkTimvh5JFRi=ZS+a3HCDUEh=efx-VOUVuckmVfipU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Hmm, good point. I should try that. I have only tried these syntaxes:

====================================
connection.prepareStatement("select * from p_enhance_address2()");
connection.prepareCall("{ call p_enhance_address2(?) }"); // with an
output parameter registered
====================================

Since I'm doing this for my database abstraction tool
http://jooq.sourceforge.net, I could add a specialised Postgres stored
procedures abstraction and hide these details from the outside world...
Thanks for the hint!

2011/2/16 Robert Haas <robertmhaas(at)gmail(dot)com>

> On Wed, Feb 16, 2011 at 7:03 AM, Oliver Jowett <oliver(at)opencloud(dot)com>
> wrote:
> > On 17/02/11 00:58, Robert Haas wrote:
> >> On Wed, Feb 16, 2011 at 3:30 AM, Lukas Eder <lukas(dot)eder(at)gmail(dot)com>
> wrote:
> >>> I'm not trying to fix the signature. I want exactly that signature. I
> want
> >>> to return 1 UDT as an OUT parameter from a function.
> >>>
> >>> Somewhere between JDBC and the database, this signature is lost, and
> JDBC's
> >>> internal code tells me that I have to bind 6 OUT parameters, instead of
> 1.
> >>> It happens to be so, because the UDT contains 6 attributes, so somehow
> the
> >>> JDBC/database protocol flattens the UDT, and I think that's a bug,
> either in
> >>> JDBC or in the protocol or in the database. My findings were that I can
> >>> correctly read the UDT OUT parameter using the pgAdmin III tool, so I
> >>> excluded the database as a bug holder candidate.
> >>
> >> Oh, OK. Sorry, I can't help you any with the JDBC side...
> >
> > Well, the underlying problem is that "SELECT * from
> > function_with_one_out_parameter()" is returning *6* columns, not 1
> > column. I don't know if that's expected or not on the plpgsql side, but
> > the JDBC driver has no way of distinguishing that sort of result from a
> > function that has 6 OUT parameters.
>
> 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?
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Jowett 2011-02-16 12:43:09 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Lukas Eder 2011-02-16 12:12:42 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2011-02-16 12:43:09 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Lukas Eder 2011-02-16 12:12:42 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function