Re: Fwd: [JDBC] Weird issues when reading UDT from stored function - Mailing list pgsql-hackers

From Oliver Jowett
Subject Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Date
Msg-id 4D5BC65D.8070507@opencloud.com
Whole thread Raw
In response to Re: Fwd: [JDBC] Weird issues when reading UDT from stored function  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Fwd: [JDBC] Weird issues when reading UDT from stored function  (Florian Pflug <fgp@phlo.org>)
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: rsmogura
Date:
Subject: Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Next
From: Greg Smith
Date:
Subject: Re: [PERFORM] pgbench to the MAXINT