patch: add get/setPrepareThreshold to PGStatement, PGConnection, datasources - Mailing list pgsql-jdbc

From Oliver Jowett
Subject patch: add get/setPrepareThreshold to PGStatement, PGConnection, datasources
Date
Msg-id 20031202081849.GK19205@opencloud.com
Whole thread Raw
List pgsql-jdbc
This patch adds setPrepareThreshold() and getPrepareThreshold() to
PGStatement, PGConnection, and the myriad Datasource implementations. It
also supports setting the threshold via a connection URL (this needs
testing).

The prepare threshold controls automatic use of server-side prepared
statements without the need for a postgresql-specific interface (at least if
you do it via reflection at the datasource level, or via a URL parameter). A
threshold is stored at each level of the datasource/connection/statement
hierarchy; the threshold on datasources and connections controls the initial
threshold of connections and statements (respectively) created from them.

If the prepare threshold of a Statement is 0 (the default) then server-side
prepared statements are not used (equivalent to the current default).

If the prepare threshold of a Statement is some value N > 0, server-side
prepare will be used for that statement on its Nth reuse, assuming the query
is suitable for server-side preparation. This means if N = 1, server-side
prepare is always used (equivalent to PGStatement.setUseServerPrepare(true)
in the current code).

The threshold only really makes sense for PreparedStatements and
CallableStatements as plain Statements can't actually be "reused" -- each
query is independent. Currently, though, no distinction is made i.e. with a
threshold of 1 everything does PREPARE/EXECUTE including queries via the
plain Statement methods.

-O

Attachment

pgsql-jdbc by date:

Previous
From: pginfo
Date:
Subject: Re: autocommit trouble with jdbc on Postgres 7.4
Next
From: "Ethan Perry"
Date:
Subject: string character corruption problem and broken connection problem