-
Notifications
You must be signed in to change notification settings - Fork 438
Handled sp_prepexec call for Column encryption enabled #2663
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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2663 +/- ##
============================================
+ Coverage 51.62% 51.70% +0.08%
- Complexity 4008 4030 +22
============================================
Files 147 147
Lines 33800 33804 +4
Branches 5650 5652 +2
============================================
+ Hits 17448 17479 +31
+ Misses 13888 13881 -7
+ Partials 2464 2444 -20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ADO pipeline is successful. |
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.
No general objections to these changes. But we should add tests to cover the scenario this is fixing.
…rypted columns can handle string values of varying sizes correctly
src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/RegressionAlwaysEncryptedTest.java
Outdated
Show resolved
Hide resolved
…ressionAlwaysEncryptedTest.java Co-authored-by: David Engel <davidengel@microsoft.com>
…om/microsoft/mssql-jdbc into user/divang/Encrypted_Column_issue
ADO pipeline is successful. |
…t be encrypted using deterministic encryption.
…lue is not set for the parameter numbers
…SQLServerPreparedStatement.java
Successful run ADO pipeline |
Description:
The incident involved unexpected behavior when inserting strings using Always Encrypted with Secure Enclaves in Azure SQL DB.
Unexpected insert results when using Always Encrypted.
Subsequent inserts into encrypted columns fail after initial successful inserts.
Issue in details at code level:
The buildPreparedStrings method compares the last prepared statement with the current one to be executed. If both statements are identical, it signals that calling sp_prepexec is unnecessary. Otherwise, sp_prepexec will be invoked later in the driver's execution flow. However, multiple calls to buildPreparedStrings overwrite the preparedTypeDefinitions variable, which stores the current prepared statement. As a result, repeated invocations can lead to the loss of the original statement, affecting the logic that determines whether sp_prepexec should be called with updated data types and lengths.
Resolution details:
Within the buildPreparedStrings method, the preparedTypeDefinitions variable is cached in preparedTypeDefinitionsPrev to prevent it from being overwritten. If isAEv2() is enabled, renewDefinition is false, and isInternalEncryptionQuery is true, then the driver caches the preparedTypeDefinitions value into preparedTypeDefinitionsPrev. In subsequent calls to buildPreparedStrings, if isAEv2() is still enabled, renewDefinition is true, and isInternalEncryptionQuery is false, the driver restores preparedTypeDefinitions from the cached preparedTypeDefinitionsPrev. This caching mechanism prevents the loss of the original statement and ensures the correct signal is returned regarding whether to invoke sp_prepexec.
Testing