| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql_python/cursor.pyLines 759-771 759 if self.hstmt:
760 ret = ddbc_bindings.DDBCSQLResetStmt(self.hstmt)
761 try:
762 check_error(ddbc_sql_const.SQL_HANDLE_STMT.value, self.hstmt, ret)
! 763 except Exception:
764 logger.warning("_soft_reset_cursor failed; falling back to full reset")
! 765 self._reset_cursor()
! 766 self.last_executed_stmt = ""
! 767 return
768 self._clear_rownumber()
769
770 def close(self) -> None:
771 """Lines 1384-1392 1384 if reset_cursor:
1385 if self.hstmt:
1386 self._soft_reset_cursor()
1387 else:
! 1388 self._reset_cursor()
1389 else:
1390 # Close just the ODBC cursor (not the statement handle) so the
1391 # prepared plan can be reused. SQLFreeStmt(SQL_CLOSE) releases
1392 # the cursor associated with hstmt without destroying themssql_python/pybind/ddbc_bindings.cppLines 1379-1394 1379 }
1380
1381 SQLRETURN SQLResetStmt_wrap(SqlHandlePtr statementHandle) {
1382 if (!statementHandle || !statementHandle->get()) {
! 1383 return SQL_INVALID_HANDLE;
! 1384 }
1385 if (statementHandle->isImplicitlyFreed()) {
! 1386 return SQL_INVALID_HANDLE;
! 1387 }
1388 if (!SQLFreeStmt_ptr) {
! 1389 DriverLoader::getInstance().loadDriver();
! 1390 }
1391 SQLHANDLE hStmt = statementHandle->get();
1392
1393 SQLRETURN rc;
1394 {📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 67.9%
mssql_python.row.py: 70.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 74.6%
mssql_python.pybind.connection.connection.cpp: 75.8%
mssql_python.__init__.py: 77.3%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 85.3%🔗 Quick Links
|
Sorry, something went wrong.
There was a problem hiding this comment.
This PR adds a lightweight statement “reset” primitive to the pybind ODBC layer and uses it in Cursor.execute() to reduce overhead on the execute hot path (avoid full HSTMT reallocation, skip redundant parameter-style conversion on re-execution, and reduce diagnostic-record collection work).
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| mssql_python/pybind/ddbc_bindings.cpp | Adds SQLResetStmt_wrap and exports DDBCSQLResetStmt to Python. |
| mssql_python/cursor.py | Uses soft reset + prepare caching and optimizes parameter conversion/logging/diagnostics in execute(). |
| benchmarks/perf-benchmarking.py | Normalizes conn string for mssql-python by removing Driver= when present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
- Add _soft_reset_cursor: SQL_CLOSE + SQL_RESET_PARAMS instead of full HSTMT free/realloc on each execute() call - Add DDBCSQLResetStmt C++ wrapper exposing lightweight reset via pybind11 - Skip SQLPrepare when re-executing the same SQL (prepare caching) - Skip detect_and_convert_parameters on repeated same-SQL calls - Guard DDBCSQLGetAllDiagRecords behind SQL_SUCCESS_WITH_INFO check - Guard per-parameter debug logging behind logger.isEnabledFor(DEBUG) - Fix benchmark script to strip Driver= from mssql-python connection string
### Work Item / Issue Reference > [AB#45159](https://sqlclientdrivers.visualstudio.com/mssql-python/_sprints/taskboard/mssql-python%20Team/mssql-python/Rubidium/May%202026?workitem=45159) ------------------------------------------------------------------- ### Summary **Enhancements** - #548 — manylinux_2_28 build targets for RHEL 8 / glibc 2.28 - #542 — macOS universal2 wheel for Python 3.10 - #526 — UTF-16 string handling via simdutf - #528 — Optimized execute() hot path - #567 — Azure Linux installation docs **Bug Fixes** - #562 — Login failures now raise mssql_python exception instead of RuntimeError - #568 — GIL released during blocking SQLSetConnectAttr calls - #541 — GIL released during blocking ODBC statement/fetch/transaction calls - #560 — executemany RuntimeError when decimals change signs - #495 — Inconsistent CP1252 VARCHAR retrieval Windows vs Linux - #559 — BulkCopy empty string in NVARCHAR(MAX)/VARCHAR(MAX) (via mssql_py_core 0.1.4)
| Back | FazBrowse Home | New Git URL |
Work Item / Issue Reference
Summary
This pull request introduces performance benchmarking infrastructure improvements and optimizations to the mssql_python driver, as well as documentation and workflow updates to support a new PERF: pull request prefix. The most significant changes are grouped below.
Driver Performance Optimizations: