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

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Lukas Eder <lukas(dot)eder(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-16 12:43:09
Message-ID: 4D5BC65D.8070507@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2011-02-16 13:15:41 Re: [PERFORM] pgbench to the MAXINT
Previous Message Lukas Eder 2011-02-16 12:16:32 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function

Browse pgsql-jdbc by date

  From Date Subject
Next Message Florian Pflug 2011-02-16 13:36:49 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Lukas Eder 2011-02-16 12:16:32 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function