- Notifications
You must be signed in to change notification settings - Fork904
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 |
vlsi commentedMay 13, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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} */@Overridepublicbooleanexecute(Stringsql,intautoGeneratedKeys)throwsSQLException {if (autoGeneratedKeys ==Statement.NO_GENERATED_KEYS) {returnexecute(sql); }returnexecute(sql, (String[])null); } WDYT of adding a check there so it ensures The test could be located in error-prone (seegoogle/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. |
vlsi commentedMay 13, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
Could you update the PR title (and the commit message) so it conveys the change to the end-users? |
2de9b94
intopgjdbc:masterUh oh!
There was an error while loading.Please reload this page.
vlsi commentedJun 2, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The PR did not change much though as pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java Lines 317 to 322 in0a88ea4
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 deallocatePreviously, the code for .isValid() was using executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)However, the execution still went with extended query protocol sinceQueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.It does not feel right to trim the flag there since the intentionof the option was to "prefer" query mode unless specified explicitly.The case is identified and tested in AutoRollbackTest: isValid shouldreturn true after statements like DEALLOCATE, DISCARD, and so on.Seepgjdbc#3631
I ran that test and it did not fail locally ? |
…ents deallocatePreviously, the code for .isValid() was using executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)However, the execution still went with extended query protocol sinceQueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.It does not feel right to trim the flag there since the intentionof the option was to "prefer" query mode unless specified explicitly.The case is identified and tested in AutoRollbackTest: isValid shouldreturn true after statements like DEALLOCATE, DISCARD, and so on.Seepgjdbc#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 in10e3546
.isValid(4) executes anextended query.An alternative option is to add
.isValid . |
…ents deallocatePreviously, the code for .isValid() was using executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)However, the execution still went with extended query protocol sinceQueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.It does not feel right to trim the flag there since the intentionof the option was to "prefer" query mode unless specified explicitly.The case is identified and tested in AutoRollbackTest: isValid shouldreturn true after statements like DEALLOCATE, DISCARD, and so on.Seepgjdbc#3631
…ents deallocatePreviously, the code for .isValid() was using executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)However, the execution still went with extended query protocol sinceQueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.It does not feel right to trim the flag there since the intentionof the option was to "prefer" query mode unless specified explicitly.The case is identified and tested in AutoRollbackTest: isValid shouldreturn true after statements like DEALLOCATE, DISCARD, and so on.Seepgjdbc#3631Fixespgjdbc#3630
…ents deallocatePreviously, the code for .isValid() was using executeWithFlags("", QueryExecutor.QUERY_EXECUTE_AS_SIMPLE)However, the execution still went with extended query protocol sinceQueryExecutorImpl#updateQueryMode trimmed the flag in preferQueryMode=extended (default) mode.It does not feel right to trim the flag there since the intentionof the option was to "prefer" query mode unless specified explicitly.The case is identified and tested in AutoRollbackTest: isValid shouldreturn true after statements like DEALLOCATE, DISCARD, and so on.See#3631Fixes#3630
Uh oh!
There was an error while loading.Please reload this page.
No description provided.