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.
bugfix: always encrypted result metadata for logical types #519
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
base: main
Are you sure you want to change the base?
bugfix: always encrypted result metadata for logical types #519
Changes from all commits
a11815f47da05aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
Suggestion. The early
if metadata.is_plp() { return 0; }just above tests the wiretype_info. Encrypted columns can be PLP on the wire — the codebase already recognizes this case (io/token_stream.rs:592, "Always Encrypted paused PLP streaming"). So a bounded encrypted column whose ciphertext is transmitted asvarbinary(max)returnscolumn_size == 0even though its effective type has a finite length, leaving this part of #469 unfixed for large encrypted string/binary columns while the rest of the function was converted toeffective_*.Evidence gap worth closing first: the only citation for "encrypted ciphertext is PLP" is the outbound RPC path (
rpc_parameters.rs); I could not confirm from here that inboundCOLMETADATAadvertises a bounded-plaintext encrypted column asvarbinary(max)without a live AE server. If it does, add an effective/logical PLP predicate and use it here — keep the existing wireis_plp()for the decoder/streaming callers that need wire semantics:and test both: wire-PLP + bounded logical (e.g.
nvarchar(4000)) → 4000, and wire-PLP + logicalnvarchar(max)→ 0. Not a regression — pre-PR also returned 0.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.
Suggestion.
effective_data_type()/effective_type_info()(and theget_scale/get_precision/get_collationswitch just above) select plaintext whenevercrypto_metadataisSome, unconditionally. But the doc says "type information for the logical value delivered to consumers", and that only holds when the row was actually decrypted.Under a per-command
ExecutionColumnEncryptionSetting::Disabled,resolve_cell_decryptorreturnsNoneanddecode_or_decrypt_columnreturns the raw ciphertext varbinary (io/token_stream.rs, the(true, None)arm), while these accessors still report the plaintext type — the same metadata/value mismatch this PR fixes, reversed. Return values have the same gap underDisabledandResultSetOnly(see thefinalize_return_valuedoc atconnection/tds_client.rs:4761). Issue #469 itself scopes the fix to "whenever column decryption is active."Not reachable through mssql-py-core today (it does not expose the per-command CE setting, and a connection without CE never populates
crypto_metadata), so no current consumer is wrong — this is about the mssql-tds public contract. Please pick one contract and make the docs match:data_type/type_info. Then this PR is fine as-is.Either is defensible; today the doc wording asserts the delivery contract while the code implements the schema contract.