-
Notifications
You must be signed in to change notification settings - Fork 897
fix: isValid incorrectly called execute, instead of executeWithFlags fixes Issue #3630 #3631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can we somehow test the change? |
What's bothersome to me is that the compiler can't detect the problem either. I'll think about how to test the change |
How about adding a check to Here's the current code: /**
* ...
* @param autoGeneratedKeys a flag indicating whether auto-generated keys
* should be made available for retrieval;
* one of the following constants:
* {@code Statement.RETURN_GENERATED_KEYS}
* {@code Statement.NO_GENERATED_KEYS}
*/
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS) {
return execute(sql);
}
return execute(sql, (String[]) null);
} WDYT of adding a check there so it ensures The test could be located in error-prone (see google/error-prone#3684), or in |
For the reference, I've executed "remove redundant cast(s)" inspection in IDEA, and it does not reveal the other problems like this one. There are 13 extra redundant casts, however, they are harmless. |
|
Could you update the PR title (and the commit message) so it conveys the change to the end-users? |
The PR did not change much though as pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java Lines 317 to 322 in 0a88ea4
We'd better write explicit tests rather than rely on the code change alone. So it still ends up with the unwanted error when calling
|
I think |
…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
I ran that test and it did not fail locally ? |
…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
The test did not fail because it was not named properly I believe it was just ignored. I discovered the failure when working on #3652 |
Yes, I changed the name and ran the test by itself. I wonder if it makes a difference if I run all of the tests ? |
The full sequence is as follows:
Then the test fails:
As I analyzed the failure, I put |
I guess I need your PR to test this |
pgjdbc/pgjdbc/src/test/java/org/postgresql/test/jdbc2/AutoRollbackTestSuite.java Lines 313 to 315 in 10e3546
.isValid(4) executes an extended query.
An alternative option is to add
.isValid .
|
…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
…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
…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 #3631 Fixes #3630
No description provided.