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

From: rsmogura <rsmogura(at)softperience(dot)eu>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Florian Pflug <fgp(at)phlo(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Lukas Eder <lukas(dot)eder(at)gmail(dot)com>, <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 12:18:30
Message-ID: d955df8cad5299b45e7672972c7b9c45@mail.softperience.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

<snip>
>> testdb=# CREATE FUNCTION p_enhance_address4 (address OUT
>> u_address_type) AS $$ BEGIN address := (SELECT t_author.address FROM
>> t_author WHERE first_name = 'George'); END; $$ LANGUAGE plpgsql;
>> CREATE FUNCTION
>> testdb=# SELECT * FROM p_enhance_address4();
>> street | zip | city | country | since
>> | code
>>
>> ------------------------+--------+-----------+---------+------------+------
>> ("Parliament Hill",77) | NW31A9 | Hampstead | England | 1980-01-01
>> |
>> (1 row)
>
> The second problem is that the JDBC driver always generates calls in
> the
> "SELECT * FROM ..." form, but this does not work correctly for
> one-OUT-parameter-that-is-a-UDT, as seen in the example immediately
> above. Here's how to do the call for that particular case:
>
>> testdb=# SELECT p_enhance_address4();
>> p_enhance_address4
>> -------------------------------------------------------------------
>> ("(""Parliament Hill"",77)",NW31A9,Hampstead,England,1980-01-01,)
>> (1 row)
>
> The challenge is that the bare SELECT form doesn't work for multiple
> OUT
> parameters, so the driver has to select one form or the other based
> on
> the number of OUT parameters.
>
> Any questions? (I'm sure there will be questions. Sigh.)
>
> Oliver

I don't want to blame or anything similar, any idea is good, as any
effort as well, but if user will register one output parameter, but
procedure will have two will it be possible to check this? I'm little
lost in this nested records. If there will be no such check I suggest to
configure this by connection parameter, because in any way UDTs aren't
such popular, user should have choice to decide "I want better checks",
or "I need this! Everything is on my side".

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2011-02-17 12:30:05 Re: Fix for Index Advisor related hooks
Previous Message Oliver Jowett 2011-02-17 12:15:36 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maurin, Marion 2011-02-17 13:02:28 Re: PGXAConnection and autocommit problem
Previous Message Oliver Jowett 2011-02-17 12:15:36 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function