Revert "FIX: varchar columnsize does not account for utf8 conversion"#403
Merged
gargsaumya merged 1 commit intomainfrom Jan 16, 2026
Merged
Revert "FIX: varchar columnsize does not account for utf8 conversion"#403gargsaumya merged 1 commit intomainfrom
gargsaumya merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request reverts PR #392, which fixed VARCHAR buffer sizing issues related to UTF-8 character encoding. The revert removes buffer size multipliers that were designed to prevent buffer overflows when the ODBC driver converts VARCHAR data containing multi-byte UTF-8 characters.
Changes:
- Removed buffer size multipliers (4x) for VARCHAR columns in multiple allocation paths
- Reverted error handling from throwing exceptions to falling back to LOB streaming
- Removed three comprehensive tests covering UTF-8 encoding edge cases with special characters
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/test_004_cursor.py | Removes 122 lines of tests validating UTF-8 buffer handling with special characters, Latin-1 encoding, and emoji support |
| mssql_python/pybind/ddbc_bindings.h | Adds SQLHSTMT parameter to column processors and restores LOB fallback paths instead of throwing errors for buffer overflow |
| mssql_python/pybind/ddbc_bindings.cpp | Reverts VARCHAR buffer sizing from 4x multiplier back to 1x in SQLGetData, SQLBindCol, and batch fetch operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql_python/pybind/ddbc_bindings.cppLines 2953-2965 2953 row.append(raw_bytes);
2954 }
2955 } else {
2956 // Buffer too small, fallback to streaming
! 2957 LOG("SQLGetData: CHAR column %d data truncated "
! 2958 "(buffer_size=%zu), using streaming LOB",
! 2959 i, dataBuffer.size());
! 2960 row.append(FetchLobColumnData(hStmt, i, SQL_C_CHAR, false, false,
! 2961 charEncoding));
2962 }
2963 } else if (dataLen == SQL_NULL_DATA) {
2964 LOG("SQLGetData: Column %d is NULL (CHAR)", i);
2965 row.append(py::none());Lines 3290-3299 3290 if (static_cast<size_t>(dataLen) <= columnSize) {
3291 row.append(py::bytes(
3292 reinterpret_cast<const char*>(dataBuffer.data()), dataLen));
3293 } else {
! 3294 row.append(
! 3295 FetchLobColumnData(hStmt, i, SQL_C_BINARY, false, true, ""));
3296 }
3297 } else if (dataLen == SQL_NULL_DATA) {
3298 row.append(py::none());
3299 } else if (dataLen == 0) {mssql_python/pybind/ddbc_bindings.h📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.hpp: 58.8%
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.row.py: 66.2%
mssql_python.helpers.py: 67.5%
mssql_python.pybind.ddbc_bindings.cpp: 69.4%
mssql_python.pybind.ddbc_bindings.h: 71.7%
mssql_python.pybind.connection.connection.cpp: 73.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 84.1%🔗 Quick Links
|
jahnvi480
approved these changes
Jan 16, 2026
sumitmsft
approved these changes
Jan 16, 2026
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.
Reverts #392