pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedFix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null")
6+ messages / 2 participants
[nested] [flat]
* Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null")
@ 2005-01-27 22:55 Oliver Jowett <oliver@opencloud.com>
2005-01-30 06:22 ` Re: Fix for changing parameter types with server prepared statements Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 6+ messages in thread
From: Oliver Jowett @ 2005-01-27 22:55 UTC (permalink / raw)
To: pgsql-jdbc
Oliver Jowett wrote:
> We currently break in the case where parameter types change between
> executions, but that's more easily fixable since we have all the
> necessary information already available.
I just fixed this in CVS, it wasn't as painful to do as I originally
thought. It should also work for the NULL-as-oid-0 case if we go back to
doing that -- any change in parameter type oids causes a reprepare.
-O
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Fix for changing parameter types with server prepared statements
2005-01-27 22:55 Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null") Oliver Jowett <oliver@opencloud.com>
@ 2005-01-30 06:22 ` Kris Jurka <books@ejurka.com>
2005-01-30 06:36 ` Re: Fix for changing parameter types with server prepared Kris Jurka <books@ejurka.com>
2005-01-30 06:49 ` Re: Fix for changing parameter types with server prepared Kris Jurka <books@ejurka.com>
2005-01-30 19:08 ` Re: Fix for changing parameter types with server prepared statements Oliver Jowett <oliver@opencloud.com>
2005-01-30 19:13 ` Re: Fix for changing parameter types with server prepared statements Oliver Jowett <oliver@opencloud.com>
0 siblings, 4 replies; 6+ messages in thread
From: Kris Jurka @ 2005-01-30 06:22 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
On Fri, 28 Jan 2005, Oliver Jowett wrote:
> I just fixed this in CVS, it wasn't as painful to do as I originally
> thought. It should also work for the NULL-as-oid-0 case if we go back to
> doing that -- any change in parameter type oids causes a reprepare.
>
The attached patch implements the Describe (Statement) protocol
message which allows us to do a number of things.
First it re-enables untyped nulls. When a statement with an untyped null
is executed (and we expect it to be reused) a describe statement is issued
to get the backend to resolve its type for us which is then fed back into
the ParameterList. This allows the following code to not require
re-parses for every execution:
PreparedStatement ps = conn.prepareStatemet("SELECT 1 + ? ");
ps.setObject(1, null);
ps.executeQuery();
ps.setInt(1, 1);
ps.executeQuery();
ps.setObject(1, null);
ps.executeQuery();
ps.setInt(1, 1);
ps.executeQuery();
A problem I came across is that it will actually require a reparse on the
second execution above because the prepared statements parameters are
cloned and stored during QueryExecutorImpl.sendParse which is before the
results of the describe statement message can be fed back into the system.
Any ideas on this would be appreciated.
Additionally a new QueryExecutor.QUERY_ flag has been added that indicates
we only want to describe the statement and not actually execute. This
uses the new Describe(Statement) support to implement
PreparedStatement.getMetaData() for an unexecuted statement and
PreparedStatement.getParameterMetaData().
Kris Jurka
Attachments:
statement.describe.patch.gz (application/octet-stream, 7.8K) download
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Fix for changing parameter types with server prepared
2005-01-27 22:55 Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null") Oliver Jowett <oliver@opencloud.com>
2005-01-30 06:22 ` Re: Fix for changing parameter types with server prepared statements Kris Jurka <books@ejurka.com>
@ 2005-01-30 06:36 ` Kris Jurka <books@ejurka.com>
3 siblings, 0 replies; 6+ messages in thread
From: Kris Jurka @ 2005-01-30 06:36 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
On Sun, 30 Jan 2005, Kris Jurka wrote:
> The attached patch implements the Describe (Statement) protocol
> message which allows us to do a number of things.
>
Incremental diff for minor bug. If we are going to execute this statement
after a describe message the doneAfterRowDescNoData code will not be
called, so we need to increment the describeIndex ourselves.
Kris Jurka
Attachments:
statement.describe-fix1.patch (text/plain, 442B) download
*** app/org/postgresql/core/v3/QueryExecutorImpl.java Sat Jan 29 22:29:35 2005
--- md/org/postgresql/core/v3/QueryExecutorImpl.java Sat Jan 29 22:28:39 2005
***************
*** 1154,1159 ****
--- 1154,1161 ----
if (describeOnly)
doneAfterRowDescNoData = true;
+ else
+ describeIndex++;
}
break;
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Fix for changing parameter types with server prepared
2005-01-27 22:55 Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null") Oliver Jowett <oliver@opencloud.com>
2005-01-30 06:22 ` Re: Fix for changing parameter types with server prepared statements Kris Jurka <books@ejurka.com>
@ 2005-01-30 06:49 ` Kris Jurka <books@ejurka.com>
3 siblings, 0 replies; 6+ messages in thread
From: Kris Jurka @ 2005-01-30 06:49 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc
On Sun, 30 Jan 2005, Kris Jurka wrote:
>
> The attached patch implements the Describe (Statement) protocol
> message which allows us to do a number of things.
>
Another incremental fix to make sure PSQLParameterMetaData gets built.
Kris Jurka
Attachments:
statement.describe-fix2.patch (text/plain, 504B) download
*** app/build.xml Sat Jan 29 22:29:17 2005
--- md/build.xml Sat Jan 29 22:43:34 2005
***************
*** 137,142 ****
--- 137,143 ----
<!-- jdbc3 subpackage -->
<include name="${package}/jdbc3/Abstract*.java" if="jdbc3any" />
<include name="${package}/jdbc3/PSQLSavepoint.java" if="jdcb3any" />
+ <include name="${package}/jdbc3/PSQLParameterMetaData.java" if="jdbc3any" />
<include name="${package}/jdbc3/Jdbc3Array.java" if="jdbc3"/>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Fix for changing parameter types with server prepared statements
2005-01-27 22:55 Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null") Oliver Jowett <oliver@opencloud.com>
2005-01-30 06:22 ` Re: Fix for changing parameter types with server prepared statements Kris Jurka <books@ejurka.com>
@ 2005-01-30 19:08 ` Oliver Jowett <oliver@opencloud.com>
3 siblings, 0 replies; 6+ messages in thread
From: Oliver Jowett @ 2005-01-30 19:08 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris Jurka wrote:
> A problem I came across is that it will actually require a reparse on the
> second execution above because the prepared statements parameters are
> cloned and stored during QueryExecutorImpl.sendParse which is before the
> results of the describe statement message can be fed back into the system.
> Any ideas on this would be appreciated.
Also store the statement itself in the describe queue, and update (in
the cloned array attached to the statement) any parameter OIDs that are
currently 0 when the ParameterDescription arrives?
-O
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Fix for changing parameter types with server prepared statements
2005-01-27 22:55 Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null") Oliver Jowett <oliver@opencloud.com>
2005-01-30 06:22 ` Re: Fix for changing parameter types with server prepared statements Kris Jurka <books@ejurka.com>
@ 2005-01-30 19:13 ` Oliver Jowett <oliver@opencloud.com>
3 siblings, 0 replies; 6+ messages in thread
From: Oliver Jowett @ 2005-01-30 19:13 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris Jurka wrote:
> On Fri, 28 Jan 2005, Oliver Jowett wrote:
>
>>I just fixed this in CVS, it wasn't as painful to do as I originally
>>thought. It should also work for the NULL-as-oid-0 case if we go back to
>>doing that -- any change in parameter type oids causes a reprepare.
>
> The attached patch implements the Describe (Statement) protocol
> message which allows us to do a number of things.
Looks good to me.
-O
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2005-01-30 19:13 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27 22:55 Fix for changing parameter types with server prepared statements (was Re: setObject on PGInterval throws "Unknown Type null") Oliver Jowett <oliver@opencloud.com>
2005-01-30 06:22 ` Re: Fix for changing parameter types with server prepared statements Kris Jurka <books@ejurka.com>
2005-01-30 06:36 ` Re: Fix for changing parameter types with server prepared Kris Jurka <books@ejurka.com>
2005-01-30 06:49 ` Re: Fix for changing parameter types with server prepared Kris Jurka <books@ejurka.com>
2005-01-30 19:08 ` Re: Fix for changing parameter types with server prepared statements Oliver Jowett <oliver@opencloud.com>
2005-01-30 19:13 ` Re: Fix for changing parameter types with server prepared statements Oliver Jowett <oliver@opencloud.com>
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