Skip to content

Conversation

vlsi
Copy link
Member

@vlsi vlsi commented Jun 6, 2025

Previously, the code for .isValid() was using executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)

However, the execution still went with extended query protocol since QueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.

It does not feel right to trim the flag there since the intention of the option was to "prefer" query mode unless specified explicitly.

The case is identified and tested in AutoRollbackTest: isValid should return true after statements like DEALLOCATE, DISCARD, and so on.

See #3631
Fixes #3630

…ents deallocate

Previously, the code for .isValid() was using
 executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)

However, the execution still went with extended query protocol since
QueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.

It does not feel right to trim the flag there since the intention
of the option was to "prefer" query mode unless specified explicitly.

The case is identified and tested in AutoRollbackTest: isValid should
return true after statements like DEALLOCATE, DISCARD, and so on.

See pgjdbc#3631
Fixes pgjdbc#3630
@vlsi vlsi added the bug label Jun 6, 2025
@vlsi vlsi merged commit cb10dce into pgjdbc:master Jun 6, 2025
16 of 17 checks passed
@@ -318,8 +318,6 @@ private int updateQueryMode(int flags) {
switch (getPreferQueryMode()) {
case SIMPLE:
return flags | QUERY_EXECUTE_AS_SIMPLE;
case EXTENDED:
return flags & ~QUERY_EXECUTE_AS_SIMPLE;
default:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, how long has that been there ?

Copy link
Member Author

@vlsi vlsi Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been sitting there for almost 9 years since 232569c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect execute, should be execute withFlags
2 participants