Repository navigation
Conversation
On Db2 LUW 12.1, SQLDARD describes a CHAR(n CODEUNITS32) or GRAPHIC(n CODEUNITS32) column as fixed-length (SQLTYPE 452/468), but QRYDSC declares it with LIDs 0xB2/0xB3 or 0xB0/0xB1 and QRYDTA sends a 2-byte count before each value. Decoding those values as fixed-width shifted every later column and row, so a query failed with "query ended with undecoded row data" or returned wrong values and fewer rows. The QRYDSC layout is now applied to the SQLDARD descriptors, and the decoder reads these columns as a UTF-8 byte count (0xB2/0xB3) or a UTF-16 code-unit count (0xB0/0xB1) followed by the value. The compact GDA path maps the same LIDs. Fixes gurungabit#42
The QRYDSC layout was copied onto the SQLDARD descriptors only when QRYDSC arrived second. A reply carrying SQLDARD after QRYDSC replaced the descriptors without it, and the length-prefixed CODEUNITS32 values were decoded as fixed-width again. Add tests that run captured Db2 12.1 reply frames through process_query_frames with SQLDARD before and after QRYDSC, and with QRYDSC alone.
This branch has not been deployed
This file contains hidden or 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
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.
Fixes #42
On Db2 LUW 12.1,
CHAR(n CODEUNITS32)andGRAPHIC(n CODEUNITS32)are fixed-length in SQLDARD (SQLTYPE 452/468), but QRYDSC declares them with LIDs 0xB0-0xB3 and QRYDTA sends a 2-byte count before each value.Reading them as fixed-width shifted every later column and row.
Changes:
crates/db2-proto/src/fdoca.rs: newapply_qrydsc_string_layoutcopies the QRYDSC wire type onto the matching SQLDARD descriptor;decode_column_valuereads 0xB2/0xB3 as a UTF-8 byte count and 0xB0/0xB1 as a UTF-16 code-unit count;compact_gda_descriptor_typemaps the same LIDs.crates/db2-client/src/connection.rs:process_query_framesapplies the QRYDSC layout to the SQLDARD descriptors whichever of the two arrives first, andnormalize_luw_descriptorstreats 0xB0 like the other graphic types.The layout is applied only when both descriptor lists have the same column count, so the LOB row envelope case keeps its current behaviour.
Tests use QRYDSC and QRYDTA bytes captured from Db2 12.1.0.0 for both types, with ASCII and non-ASCII values:
test_codeunits32_fixed_strings_are_length_prefixed_on_the_wiredecodes the rows with the layout applied and fails without thefdoca.rschange.query_frames_decode_codeunits32_fixed_strings_in_either_descriptor_orderruns the reply frames throughprocess_query_frameswith SQLDARD before and after QRYDSC.query_frames_decode_codeunits32_fixed_strings_from_qrydsc_alonecovers a reply with no SQLDARD.Verified live on Db2 12.1.0.0: 60 type, width and row-count combinations, all rows correct.
Locally:
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warningsand unit tests pass, plus integration and Node.js tests against the CI Db2 11.5.9 setup.Not run: the release workflow and the docs build.