-
Notifications
You must be signed in to change notification settings - Fork 35
Revert "FIX: varchar columnsize does not account for utf8 conversion" #403
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
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.
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
|
Reverts #392