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

From: Lukas Eder <lukas(dot)eder(at)gmail(dot)com>
To: Florian Pflug <fgp(at)phlo(dot)org>, Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(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-17 09:45:06
Message-ID: AANLkTik+AK69B=QqV2N5f7p12WPUx1vfrJLZWiqotghM@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

2011/2/17 Florian Pflug <fgp(at)phlo(dot)org>

> On Feb17, 2011, at 01:14 , Oliver Jowett wrote:
> > Any suggestions about how the JDBC driver can express the query to get
> > the behavior that it wants? Specifically, the driver wants to call a
> > particular function with N OUT or INOUT parameters (and maybe some other
> > IN parameters too) and get a resultset with N columns back.
>
> There's no sane way to do that, I fear. You could of course look up the
> function definition in the catalog before actually calling it, but with
> overloading and polymorphic types finding the right pg_proc entry seems
> awfully complex.
>
> Your best option is probably to just document this caveat...
>

But there still is a bug in the JDBC driver as I originally documented it.
Even if you say it's not simple to know whether the signature is actually a
single UDT with 6 attributes or just 6 OUT parameters, the result is wrong
(as stated in my original mail):

The nested UDT structure completely screws up fetching results. This
> is what I get with JDBC:
> ====================================
>
> PreparedStatement stmt = connection.prepareStatement("select *
> from p_enhance_address2()");
> ResultSet rs = stmt.executeQuery();
>
> while (rs.next()) {
> System.out.println("# of columns: " +
> rs.getMetaData().getColumnCount());
> System.out.println(rs.getObject(1));
> }
> ====================================
> Output:
> # of columns: 6
> ("(""Parliament Hill"",77)",NW31A9)
>

The result set meta data correctly state that there are 6 OUT columns. But
only the first 2 are actually fetched (because of a nested UDT)...

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2011-02-17 09:53:19 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Florian Pflug 2011-02-17 09:39:17 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function

Browse pgsql-jdbc by date

  From Date Subject
Next Message Pavel Stehule 2011-02-17 09:53:19 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Florian Pflug 2011-02-17 09:39:17 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function