-
Notifications
You must be signed in to change notification settings - Fork 426
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
Execute Stored Procedures Directly #2154
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tkyc
force-pushed
the
exec-cstmt-directly
branch
from
August 28, 2023 21:10
3009920
to
d9a47c7
Compare
This reverts commit b19dfb0.
… params as non-PLP over the wire for nvarchar and binary types
tkyc
force-pushed
the
exec-cstmt-directly
branch
from
October 23, 2023 22:02
e93eac7
to
1114154
Compare
Jeffery-Wasty
previously approved these changes
Nov 15, 2023
David-Engel
reviewed
Nov 15, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests that exercise CallableStatement with useFlexibleCallableStatements set to false and validate success and failure cases. We should detect if they are mixing named/index and throw an error. Not sure if we can detect out of order params.
src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
Outdated
Show resolved
Hide resolved
…e.java Co-authored-by: David Engel <v-davidengel@microsoft.com>
…atement.java Co-authored-by: David Engel <v-davidengel@microsoft.com>
…java Co-authored-by: David Engel <v-davidengel@microsoft.com>
…atement.java Co-authored-by: David Engel <v-davidengel@microsoft.com>
Jeffery-Wasty
previously approved these changes
Nov 16, 2023
tkyc
force-pushed
the
exec-cstmt-directly
branch
from
November 16, 2023 21:53
95d5ff6
to
2e03f12
Compare
Jeffery-Wasty
approved these changes
Nov 16, 2023
Jeffery-Wasty
added a commit
that referenced
this pull request
Aug 6, 2024
This reverts commit 11680a6.
Jeffery-Wasty
added a commit
that referenced
this pull request
Aug 6, 2024
This reverts commit 11680a6.
tkyc
added a commit
that referenced
this pull request
Aug 21, 2024
* Revert "Execute Stored Procedures Directly (#2154)" This reverts commit 11680a6. * Revert "Execute cstmt directly - Additional testing and changes (#2284)" This reverts commit 92cfe0d. * Revert "Re-added support for stored procedure 'exec' escape syntax in CallableStatements (#2325)" This reverts commit ba88da8. * Additional revert of missed lines * Added no-op for getters/setters * RequestBoundaryMethods no-op test fix
tkyc
added a commit
that referenced
this pull request
Aug 21, 2024
* Revert "Execute Stored Procedures Directly (#2154)" This reverts commit 11680a6. * Revert "Execute cstmt directly - Additional testing and changes (#2284)" This reverts commit 92cfe0d. * Revert "Re-added support for stored procedure 'exec' escape syntax in CallableStatements (#2325)" This reverts commit ba88da8. * Additional revert of missed lines * Added no-op for getters/setters * RequestBoundaryMethods no-op test fix
tkyc
added a commit
that referenced
this pull request
Aug 22, 2024
* Revert "Execute Stored Procedures Directly (#2154)" This reverts commit 11680a6. * Revert "Execute cstmt directly - Additional testing and changes (#2284)" This reverts commit 92cfe0d. * Revert "Re-added support for stored procedure 'exec' escape syntax in CallableStatements (#2325)" This reverts commit ba88da8. * Additional revert of missed lines * Added no-op for getters/setters * RequestBoundaryMethods no-op test fix
tkyc
added a commit
that referenced
this pull request
Aug 23, 2024
* Revert "Execute Stored Procedures Directly (#2154)" This reverts commit 11680a6. * Revert "Execute cstmt directly - Additional testing and changes (#2284)" This reverts commit 92cfe0d. * Revert "Re-added support for stored procedure 'exec' escape syntax in CallableStatements (#2325)" This reverts commit ba88da8. * Additional revert of missed lines * Added no-op for getters/setters * RequestBoundaryMethods no-op test fix
tkyc
added a commit
that referenced
this pull request
Aug 28, 2024
* Revert "Execute Stored Procedures Directly (#2154)" This reverts commit 11680a6. * Revert "Execute cstmt directly - Additional testing and changes (#2284)" This reverts commit 92cfe0d. * Revert "Re-added support for stored procedure 'exec' escape syntax in CallableStatements (#2325)" This reverts commit ba88da8. * Additional revert of missed lines * Added no-op for getters/setters * RequestBoundaryMethods no-op test fix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continued work from #547.
Points of interest:
In order to use parameter names and indexes interchangeably for acquiring/setting parameter eg.
cstmt.getXXX
orcstmt.registerOutputParameter
, the driver will need to continue to use metadata query to get the parameter names when the new CS propertyuseFlexibleCallableStatements=true
(default behaviour).xp_sqljdbc_xa calls have a special case registering their output parameters for CHAR and BINARY types as non-PLP. Prior to this PR, because cstmts calls were wrapped the RPC parameters sent to the server were defined within the
sp_execute
calls and so it wasn't necessary to do so.To read the output parameter return values, parsing the tds response is deferred to the
getXXX
calls. So, if a user executes a cstmt but doesn't get/read the output params, the return values in the tds response will be in limbo/waiting for resolution. In such case, on statement close we will now skip these return values in the tds response which is safe to do.Prior to the PR, it was possible to get the return value from sprocs as a byte array. This shouldn't be possible and this is corrected in this PR. It will throw a casting exception.
To allow for unordered setting/registering of parameters, we'll need to continue to use a metadata query for the parameter names (this goes along with point 1 when
useFlexibleCallableStatements=true
).If
outParams
are null then likely the statement was closed, so we throw an exception.Potentially we can skip building the type definitions as this is no longer needed since we send the RPC params directly. However, this breaks AE and so needs more investigation.
For user defined functions (UDF) to work, we need to know when the TDS's response return value is for a sproc or a UDF. To do so, new logic was added to parse the TDS's response to determine this.
On the main branch for datetime (datetime, datetime2), the RPC call would always send the parameter as datetime2(7). However, since the cstmts are wrapped, the real param definition was set in the
sp_executesql/sp_prepexec
by building the type definitions inbuildParamTypeDefinitions
which are affected by thedatetimeParameterType
CS property. Since we are executing cstmts directly, datetime (datetime, datetime2) will now do the RPC with the exact datetime parameter definition. Meaning, depending on thedatetimeParameterType
CS property, datetime2 will be sent in the RPC as datetime2(3) exactly by default (which was the prior behaviour done by/indirectly set in the build type definitions) or sent plainly as a datetime.New CS property
useFlexibleCallableStatements
. Default behaviour isuseFlexibleCallableStatements=true
, and in such case the driver will continue to usesp_sproc_columns
. Otherwise, whenuseFlexibleCallableStatements=false
, setting/registering parameters for callable statements require the following: