jaybird icon indicating copy to clipboard operation
jaybird copied to clipboard

For FBStatement, unprepare statement after statement completion [JDBC637]

Open firebird-automations opened this issue 3 years ago • 6 comments

Submitted by: @mrotteveel

Internally, FBStatement also prepares the statement, and keeps it prepared until the next statement is executed. It would probably be a good idea to automatically unprepare (free with DSQL_unprepare) the statement on statement completion to prevent retention of existence locks.

Commits: FirebirdSQL/jaybird@517b0550a01454ebc6d9887f7dd7e9cf99893311

firebird-automations avatar Mar 06 '21 21:03 firebird-automations

Modified by: @mrotteveel

Fix Version: Jaybird 4.0.3 [ 10981 ]

Fix Version: Jaybird 3.0.11 [ 10980 ]

Fix Version: Jaybird 5 [ 10871 ]

firebird-automations avatar Mar 06 '21 21:03 firebird-automations

Commented by: @mrotteveel

Note that DSQL_unprepare was introduced in Firebird 2.5, so maybe calling free(DSQL_unprepare) on 2.1 and earlier should either be a no-op or do free(DSQL_close) instead.

firebird-automations avatar Mar 06 '21 21:03 firebird-automations

Commented by: @mrotteveel

There are some problems with doing this: getUpdateCounts can only be called after statement completion, and same goes for getLastExecutionPlan() and getLastExplainedExecutionPlan(). We could request those at statement completion, but if we do that, we should ask all of this in a single info request to avoid three extra roundtrips, or it might make more sense to (always) request the execution plans as part of prepare.

firebird-automations avatar Mar 11 '21 18:03 firebird-automations

Commented by: @mrotteveel

Given this is more complicated than I first assumed, only implement this for Jaybird 5 (if there are no more hurdles)

firebird-automations avatar Mar 11 '21 19:03 firebird-automations

Modified by: @mrotteveel

Fix Version: Jaybird 4.0.3 [ 10981 ] =>

Fix Version: Jaybird 3.0.11 [ 10980 ] =>

firebird-automations avatar Mar 11 '21 19:03 firebird-automations

Commented by: @mrotteveel

I committed an unprepare method for FbStatement and implementations, but this is not called from JDBC yet.

firebird-automations avatar Mar 11 '21 19:03 firebird-automations

The complications with the lifetime requirements has made may decide not to implement this.

mrotteveel avatar Sep 19 '22 13:09 mrotteveel