Repository navigation
fix: enable cursor-based fetching in extended protocol when transaction started via SQL command - #3996
Conversation
53437b6 to
028d380
Compare
β¦on started via SQL command When a user starts a transaction with START TRANSACTION or BEGIN SQL commands (instead of setAutoCommit(false)), cursor-based fetching was not activated because PgStatement.executeInternal() only checked getAutoCommit(). The server is already in a transaction block in this case, so server-side cursors will survive across fetches. The fix checks the actual server transaction state in addition to the autoCommit flag. The test is skipped for simple and extendedForPrepared query modes since non-prepared statements use the simple query protocol there, which does not support server-side cursors. Fixes pgjdbc#3993 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
we should probably check the transaction state before we do anything on the connection as well. |
|
What do you mean? |
|
Well since we are getting the transaction state from the queryExecutor just want to put a check in there to make sure that the query executor is instantiated correctly. So if we don't execute any statements what is the transaction state ? |
|
I am not following your question. The condition for "use vs not use" the cursor was not quite right, so the condition could be lifted. I don't understand how your question maps to the test case at hand |
|
Do you mean "add a test case that a fresh connection responds IDLE transaction state"? |
yes |
|
I've filed transaction state tests under #4006 |
When a user starts a transaction with
START TRANSACTIONorBEGINSQL commands (instead ofsetAutoCommit(false)), cursor-based fetching was not activated becausePgStatement.executeInternal()only checkedgetAutoCommit().The server is already in a transaction block in this case, so server-side cursors will survive across fetches.
The fix checks the actual server transaction state in addition to the autoCommit flag.
Fixes #3993