Commit 865a379
authored
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below
For external contributors: Insert Github Issue number below
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#42605](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/42605)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #427
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request addresses a segmentation fault issue that occurred
when interleaving `fetchmany()` and `fetchone()` calls on a database
cursor, as reported in GitHub Issue #427. The main improvements include
unbinding columns after fetch operations to prevent conflicts with
`SQLGetData`, and adding comprehensive tests to ensure correct
interleaved fetch behavior.
Fixes for fetch interleaving bug:
* Added calls to `SQLFreeStmt_ptr(hStmt, SQL_UNBIND)` after
`fetchmany()` and `fetchall()` operations in `ddbc_bindings.cpp` to
unbind columns, allowing subsequent `fetchone()` calls to use
`SQLGetData` without causing segmentation faults.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R4097-R4100)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R4236-R4238)
* Added column unbinding at the start of `FetchOne_wrap` to avoid
conflicts from previous fetch operations, and improved error handling
for `SQLGetData` failures.
Testing improvements:
* Introduced a new test file `test_017_fetchmany_fetchone_interleave.py`
with multiple test cases to verify that interleaving `fetchmany()` and
`fetchone()` calls works correctly and no longer causes segmentation
faults.
<!--
### PR Title Guide
> For feature requests
FEAT: (short-description)
> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description)
> For Fix requests
FIX: (short-description)
> For doc update requests
DOC: (short-description)
> For Formatting, indentation, or styling update
STYLE: (short-description)
> For Refactor, without any feature changes
REFACTOR: (short-description)
> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description)
### Contribution Guidelines
External contributors:
- Create a GitHub issue first:
https://github.com/microsoft/mssql-python/issues/new
- Link the GitHub issue in the "GitHub Issue" section above
- Follow the PR title format and provide a meaningful summary
mssql-python maintainers:
- Create an ADO Work Item following internal processes
- Link the ADO Work Item in the "ADO Work Item" section above
- Follow the PR title format and provide a meaningful summary
-->
1 parent f8a6ca1 commit 865a379
2 files changed
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4094 | 4094 | | |
4095 | 4095 | | |
4096 | 4096 | | |
| 4097 | + | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
4097 | 4101 | | |
4098 | 4102 | | |
4099 | 4103 | | |
| |||
4228 | 4232 | | |
4229 | 4233 | | |
4230 | 4234 | | |
| 4235 | + | |
| 4236 | + | |
| 4237 | + | |
4231 | 4238 | | |
4232 | 4239 | | |
4233 | 4240 | | |
| |||
4254 | 4261 | | |
4255 | 4262 | | |
4256 | 4263 | | |
| 4264 | + | |
| 4265 | + | |
| 4266 | + | |
| 4267 | + | |
| 4268 | + | |
4257 | 4269 | | |
4258 | 4270 | | |
4259 | 4271 | | |
4260 | 4272 | | |
4261 | 4273 | | |
4262 | 4274 | | |
| 4275 | + | |
| 4276 | + | |
| 4277 | + | |
| 4278 | + | |
4263 | 4279 | | |
4264 | 4280 | | |
4265 | 4281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments