From: rsmogura <rsmogura@softperience.eu>
To: Oliver Jowett <oliver@opencloud.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Florian Pflug <fgp@phlo.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Lukas Eder <lukas.eder@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Date: Thu, 17 Feb 2011 10:30:51 +0100
Message-ID: <ddad5b2ae284e8dfe189c057390dafcd@mail.softperience.eu> (raw)
In-Reply-To: <4D5C6876.7060805@opencloud.com>
References: <c63c0e3d-cd3b-4b82-b891-50f8ef43bfdb@j25g2000vbs.googlegroups.com>
<201101111946.33083.rsmogura@softperience.eu>
<AANLkTi=UH_9qC8CmQBN7aEwsdUMYAzjRUCJmDiWFTQQH@mail.gmail.com>
<4d7cc4033a655539995c240a6f282ab5@mail.softperience.eu>
<AANLkTi=EAbWpOZhXUaG0OG7smtExwoE4M9dv2ykzPVcZ@mail.gmail.com>
<4D33CD00.6000408@opencloud.com>
<AANLkTin_UwaAjVKOqY3ZGpHtEt4WiX8f-ERJhA16JWX+@mail.gmail.com>
<AANLkTimvqQmkvG0QcruFGGxCrQ63U8srtDtMZBH8WjQU@mail.gmail.com>
<AANLkTi=Nf_eqY0Ao1W41rMc4vp-B6+8j+AENJ2x-qJ--@mail.gmail.com>
<AANLkTikWLBniH-QRKa0AL+O71+DnTyizn770Hd89d5Lu@mail.gmail.com>
<AANLkTi=0KS71rnnLjFrQ4G8VaOXsbYqndbmLStwL9aRt@mail.gmail.com>
<AANLkTikNjPoca5n7CusTEL2GoXNQuZeeF0vyegpsz3UF@mail.gmail.com>
<AANLkTikHdYF407NgX=giNEizY8Z2tcN47xkxuLBO73J=@mail.gmail.com>
<4D5BBD1A.7010005@opencloud.com>
<AANLkTimg0nEjma8MgFT-ZPrcQ7EHGZ4m2FZBhF5e+Hdt@mail.gmail.com>
<4D5BC65D.8070507@opencloud.com>
<A7BF4EA6-9385-! 47B3-B9BC-34649BBD4F6F@phlo.org>
<24907.1297869823@sss.pgh.pa.us>
<4D5C6876.7060805@opencloud.com>
Something like this,
Everything must be done on call, due to polymorphic signatures, this
can be kept in short living cache, but bear in mind user can alter
procedure in meantime.
When JDBC driver will detect if procedure call statement is created.
1. Determine procedure oid - how? procedures may have not qualified
name. Is any function on backend that will deal with schema search path?
You may need to pass procedure parameters or at least types? or we need
to mirror backend code to Java?
2. Download procedure signature and parse, determine what is input and
what is output.
3. Determine how many output parameters user registered, if 1st
parameter is ? = exec(?, ?)
4. If only 1 parameter is output (and its UDT, pure UDT due to relkind)
use SELECT (RESULT) as "your_param_name" FROM f(params) AS RESULT, if I
remember well using () puts all in on record
Above will resolve some other problems in JDBC.
Ad 3. Problem is with 1st parameter, actually result of such procedure
may be record, so I think I should get in our address example, when call
? = ench(addres ?), result set like
address, address
But this is to discussion.
Postgresql has own roads, far away from support of any standard.
On Thu, 17 Feb 2011 13:14:46 +1300, Oliver Jowett wrote:
> On 17/02/11 04:23, Tom Lane wrote:
>> Florian Pflug <fgp@phlo.org> writes:
>>> Hm, I've browsed through the code and it seems that the current
>>> behaviour
>>> was implemented on purpose.
>>
>> Yes, it's 100% intentional. The idea is to allow function authors
>> to
>> use OUT-parameter notation (in particular, the convention of
>> assigning
>> to a named variable to set the result) without forcing them into the
>> overhead of returning a record when all they want is to return a
>> scalar.
>> So a single OUT parameter is *supposed* to work just like a function
>> that does "returns whatever" without any OUT parameters.
>>
>> Even if you think this was a bad choice, which I don't, it's far too
>> late to change it.
>
> 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.
>
> The current approach is to say "SELECT * FROM f(params) AS RESULT"
> which
> works in all cases *except* for the case where there is exactly one
> OUT
> parameter and it has a record/UDT type.
>
> Oliver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: rsmogura@softperience.eu, oliver@opencloud.com, tgl@sss.pgh.pa.us, fgp@phlo.org, robertmhaas@gmail.com, lukas.eder@gmail.com, pgsql-hackers@postgresql.org
Subject: Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
In-Reply-To: <ddad5b2ae284e8dfe189c057390dafcd@mail.softperience.eu>
References: <c63c0e3d-cd3b-4b82-b891-50f8ef43bfdb@j25g2000vbs.googlegroups.com> <AANLkTi=UH_9qC8CmQBN7aEwsdUMYAzjRUCJmDiWFTQQH@mail.gmail.com> <4d7cc4033a655539995c240a6f282ab5@mail.softperience.eu> <AANLkTi=EAbWpOZhXUaG0OG7smtExwoE4M9dv2ykzPVcZ@mail.gmail.com> <4D33CD00.6000408@opencloud.com> <AANLkTin_UwaAjVKOqY3ZGpHtEt4WiX8f-ERJhA16JWX+@mail.gmail.com> <AANLkTimvqQmkvG0QcruFGGxCrQ63U8srtDtMZBH8WjQU@mail.gmail.com> <AANLkTi=Nf_eqY0Ao1W41rMc4vp-B6+8j+AENJ2x-qJ--@mail.gmail.com> <AANLkTikWLBniH-QRKa0AL+O71+DnTyizn770Hd89d5Lu@mail.gmail.com> <AANLkTi=0KS71rnnLjFrQ4G8VaOXsbYqndbmLStwL9aRt@mail.gmail.com> <AANLkTikNjPoca5n7CusTEL2GoXNQuZeeF0vyegpsz3UF@mail.gmail.com> <AANLkTikHdYF407NgX=giNEizY8Z2tcN47xkxuLBO73J=@mail.gmail.com> <4D5BBD1A.7010005@opencloud.com> <AANLkTimg0nEjma8MgFT-ZPrcQ7EHGZ4m2FZBhF5e+Hdt@mail.gmail.com> <4D5BC65D.8070507@opencloud.com> <24907.1297869823@sss.pgh.pa.us> <4D5C6876.7060805@opencloud.com> <ddad5b2ae284e8dfe189c057390dafcd@mail.softperience.eu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox