Movatterモバイル変換


[0]ホーム

URL:


Quick Links

Make procedure OUT parameters work with JDBC

Lists:pgsql-hackers
From:Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To:pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:Make procedure OUT parameters work with JDBC
Date:2020-10-19 09:19:10
Message-ID:d7e49540-ea92-b4e2-5fff-42036102f968@2ndquadrant.com
Views:Whole Thread |Raw Message |Download mbox |Resend email
Lists:pgsql-hackers

A follow-up to the recently added support for OUT parameters for
procedures. The JDBC driver sends OUT parameters with type void. This
makes sense when calling a function, so that the parameters are ignored
in ParseFuncOrColumn(). For a procedure call we want to treat them as
unknown. This is of course a bit of a hack on top of another hack, but
it's small and contained and gets the job done.

--
Peter Eisentrauthttp://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

AttachmentContent-TypeSize
0001-Make-procedure-OUT-parameters-work-with-JDBC.patchtext/plain1.3 KB

From:Andrew Dunstan <andrew(at)dunslane(dot)net>
To:Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:Re: Make procedure OUT parameters work with JDBC
Date:2020-10-19 11:15:48
Message-ID:d1c55f8c-bd3e-df90-e293-ed455660fad5@dunslane.net
Views:Whole Thread |Raw Message |Download mbox |Resend email
Lists:pgsql-hackers


On 10/19/20 5:19 AM, Peter Eisentraut wrote:
> A follow-up to the recently added support for OUT parameters for
> procedures.  The JDBC driver sends OUT parameters with type void. 
> This makes sense when calling a function, so that the parameters are
> ignored in ParseFuncOrColumn().  For a procedure call we want to treat
> them as unknown.  This is of course a bit of a hack on top of another
> hack, but it's small and contained and gets the job done.
>
>

I've tested this and it works as expected. +1 to apply.

cheers

andrew

--
Andrew Dunstan
EnterpriseDB:http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From:Craig Ringer <craig(dot)ringer(at)enterprisedb(dot)com>
To:Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc:Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:Re: Make procedure OUT parameters work with JDBC
Date:2020-10-20 00:35:56
Message-ID:CAGRY4nwcryGTthVf+wkF2oOt1jktH-gdf-7s8M-OCVzOP+vcFw@mail.gmail.com
Views:Whole Thread |Raw Message |Download mbox |Resend email
Lists:pgsql-hackers

On Mon, 19 Oct 2020, 19:16 Andrew Dunstan, <andrew(at)dunslane(dot)net> wrote:

>
> On 10/19/20 5:19 AM, Peter Eisentraut wrote:
> > A follow-up to the recently added support for OUT parameters for
> > procedures. The JDBC driver sends OUT parameters with type void.
> > This makes sense when calling a function, so that the parameters are
> > ignored in ParseFuncOrColumn(). For a procedure call we want to treat
> > them as unknown. This is of course a bit of a hack on top of another
> > hack, but it's small and contained and gets the job done.
> >
>

The JDBC spec defines CallableStatement.registerOutPararameter(...)
variants that take SQLType enumeration value and optionally type name.

It's important that this change not break correct and fully specified use
of the CallableStatement interface.


From:Andrew Dunstan <andrew(at)dunslane(dot)net>
To:Craig Ringer <craig(dot)ringer(at)enterprisedb(dot)com>
Cc:Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:Re: Make procedure OUT parameters work with JDBC
Date:2020-10-20 12:55:37
Message-ID:7462f9f9-116f-71ba-87e2-f72f0e9812b7@dunslane.net
Views:Whole Thread |Raw Message |Download mbox |Resend email
Lists:pgsql-hackers


On 10/19/20 8:35 PM, Craig Ringer wrote:
>
>
> On Mon, 19 Oct 2020, 19:16 Andrew Dunstan, <andrew(at)dunslane(dot)net
> <mailto:andrew(at)dunslane(dot)net>> wrote:
>
>
> On 10/19/20 5:19 AM, Peter Eisentraut wrote:
> > A follow-up to the recently added support for OUT parameters for
> > procedures.  The JDBC driver sends OUT parameters with type void. 
> > This makes sense when calling a function, so that the parameters are
> > ignored in ParseFuncOrColumn().  For a procedure call we want to
> treat
> > them as unknown.  This is of course a bit of a hack on top of
> another
> > hack, but it's small and contained and gets the job done.
> >
>
>
> The JDBC spec defines CallableStatement.registerOutPararameter(...)
> variants that take SQLType enumeration value and optionally type name.
>
> It's important that this change not break correct and fully specified
> use of the CallableStatement interface.

The JDBC driver currently implements this but discards any type
information and sends VOIDOID. This patch accommodates that. This
actually works fine, except in the case of overloaded procedures, where
the workaround is to include an explicit cast in the CALL statement.

Modifying the JDBC driver to send real type info for these cases is
something to be done, but there are some difficulties in that the class
where it's handled doesn't have enough context. And there will also
always be cases where it really doesn't know what to send (user defined
types etc.), so sending VOIDOID or UNKNOWNOID will still be done.

cheers

andrew

--
Andrew Dunstan
EnterpriseDB:http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From:Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To:Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject:Re: Make procedure OUT parameters work with JDBC
Date:2020-10-27 08:12:20
Message-ID:580ddb54-0f84-7051-3e35-ce33782dabab@2ndquadrant.com
Views:Whole Thread |Raw Message |Download mbox |Resend email
Lists:pgsql-hackers

On 2020-10-19 13:15, Andrew Dunstan wrote:
> On 10/19/20 5:19 AM, Peter Eisentraut wrote:
>> A follow-up to the recently added support for OUT parameters for
>> procedures.  The JDBC driver sends OUT parameters with type void.
>> This makes sense when calling a function, so that the parameters are
>> ignored in ParseFuncOrColumn().  For a procedure call we want to treat
>> them as unknown.  This is of course a bit of a hack on top of another
>> hack, but it's small and contained and gets the job done.
>
> I've tested this and it works as expected. +1 to apply.

committed

--
Peter Eisentrauthttp://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


[8]ページ先頭

©2009-2025 Movatter.jp