Commit d185d52
authored
FEAT: Support for streaming large parameters in execute() (#176)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#33395](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/33395)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request adds support for streaming large parameters to SQL
Server using ODBC's Data At Execution (DAE) mechanism, particularly for
long Unicode strings and binary data. The changes update both the Python
and C++ layers to correctly identify large parameters, mark them for
DAE, and handle the streaming process during execution. Additional
refactoring improves parameter type mapping and memory handling for
these cases.
**Large parameter streaming (DAE) support:**
* Updated the `_map_sql_type` method in `cursor.py` to return an
`is_dae` flag for parameters that require streaming (e.g., long Unicode
strings, long binary data), and to calculate the correct size for
Unicode strings using UTF-16 encoding.
[[1]](diffhunk://#diff-deceea46ae01082ce8400e14fa02f4b7585afb7b5ed9885338b66494f5f38280R227-R231)
[[2]](diffhunk://#diff-deceea46ae01082ce8400e14fa02f4b7585afb7b5ed9885338b66494f5f38280R329-R366)
[[3]](diffhunk://#diff-deceea46ae01082ce8400e14fa02f4b7585afb7b5ed9885338b66494f5f38280R376-R383)
[[4]](diffhunk://#diff-deceea46ae01082ce8400e14fa02f4b7585afb7b5ed9885338b66494f5f38280R393-R419)
* Modified `_create_parameter_types_list` in `cursor.py` to set
DAE-related fields (`isDAE`, `strLenOrInd`, `dataPtr`) in the parameter
info when streaming is needed.
**C++ bindings and execution logic:**
* Extended the `ParamInfo` struct and its Python bindings to include DAE
fields (`isDAE`, `strLenOrInd`, `dataPtr`) for use during parameter
binding and streaming.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L48-R51)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L2509-R2556)
* Added ODBC DAE API function pointers (`SQLParamData`, `SQLPutData`)
and integrated their loading and usage into the driver handle setup.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R141-R144)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R785-R787)
[[3]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L799-R798)
[[4]](diffhunk://#diff-85167a2d59779df18704284ab7ce46220c3619408fbf22c631ffdf29f794d635R121-R123)
* Refactored parameter binding and execution logic in
`ddbc_bindings.cpp` to handle DAE parameters: if a parameter is marked
for DAE, the code enters a loop to stream the data in chunks using
`SQLParamData` and `SQLPutData`. This is done for large Unicode strings
and (potentially) binary data.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R254-R288)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R997-L1007)
**Build and warning improvements:**
* Adjusted MSVC compiler flags to remove the "treat warnings as errors"
option, making builds less strict on warnings.
<!--
### 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 8968a5c commit d185d52
File tree
3 files changed
+145
-73
lines changed- mssql_python
- pybind
3 files changed
+145
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| 238 | + | |
236 | 239 | | |
237 | 240 | | |
238 | 241 | | |
239 | | - | |
| 242 | + | |
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
| |||
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| 251 | + | |
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
254 | 258 | | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
261 | 266 | | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
266 | 272 | | |
267 | 273 | | |
| 274 | + | |
268 | 275 | | |
269 | 276 | | |
270 | 277 | | |
| |||
273 | 280 | | |
274 | 281 | | |
275 | 282 | | |
| 283 | + | |
276 | 284 | | |
277 | 285 | | |
278 | 286 | | |
| |||
284 | 292 | | |
285 | 293 | | |
286 | 294 | | |
| 295 | + | |
287 | 296 | | |
288 | 297 | | |
289 | 298 | | |
| |||
297 | 306 | | |
298 | 307 | | |
299 | 308 | | |
| 309 | + | |
300 | 310 | | |
301 | 311 | | |
302 | 312 | | |
| |||
309 | 319 | | |
310 | 320 | | |
311 | 321 | | |
| 322 | + | |
312 | 323 | | |
313 | 324 | | |
314 | 325 | | |
| |||
317 | 328 | | |
318 | 329 | | |
319 | 330 | | |
| 331 | + | |
320 | 332 | | |
321 | 333 | | |
322 | 334 | | |
| |||
325 | 337 | | |
326 | 338 | | |
327 | 339 | | |
| 340 | + | |
328 | 341 | | |
329 | 342 | | |
330 | 343 | | |
331 | 344 | | |
332 | | - | |
333 | | - | |
| 345 | + | |
334 | 346 | | |
335 | | - | |
336 | 347 | | |
337 | 348 | | |
338 | 349 | | |
339 | | - | |
| 350 | + | |
340 | 351 | | |
| 352 | + | |
341 | 353 | | |
342 | 354 | | |
343 | 355 | | |
344 | 356 | | |
345 | 357 | | |
346 | 358 | | |
| 359 | + | |
347 | 360 | | |
348 | 361 | | |
349 | 362 | | |
| |||
352 | 365 | | |
353 | 366 | | |
354 | 367 | | |
| 368 | + | |
355 | 369 | | |
356 | 370 | | |
357 | 371 | | |
358 | 372 | | |
359 | 373 | | |
360 | 374 | | |
| 375 | + | |
361 | 376 | | |
362 | 377 | | |
363 | 378 | | |
| |||
367 | 382 | | |
368 | 383 | | |
369 | 384 | | |
| 385 | + | |
370 | 386 | | |
371 | 387 | | |
372 | 388 | | |
373 | 389 | | |
374 | 390 | | |
375 | 391 | | |
| 392 | + | |
376 | 393 | | |
377 | 394 | | |
378 | 395 | | |
| |||
382 | 399 | | |
383 | 400 | | |
384 | 401 | | |
| 402 | + | |
385 | 403 | | |
386 | 404 | | |
387 | 405 | | |
388 | 406 | | |
389 | 407 | | |
390 | 408 | | |
| 409 | + | |
391 | 410 | | |
392 | 411 | | |
393 | 412 | | |
| |||
396 | 415 | | |
397 | 416 | | |
398 | 417 | | |
| 418 | + | |
399 | 419 | | |
400 | 420 | | |
401 | 421 | | |
| |||
404 | 424 | | |
405 | 425 | | |
406 | 426 | | |
| 427 | + | |
407 | 428 | | |
408 | 429 | | |
409 | 430 | | |
| |||
412 | 433 | | |
413 | 434 | | |
414 | 435 | | |
| 436 | + | |
415 | 437 | | |
416 | 438 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
| 439 | + | |
| 440 | + | |
423 | 441 | | |
424 | 442 | | |
425 | 443 | | |
| |||
495 | 513 | | |
496 | 514 | | |
497 | 515 | | |
498 | | - | |
| 516 | + | |
499 | 517 | | |
500 | 518 | | |
501 | 519 | | |
502 | 520 | | |
503 | 521 | | |
504 | 522 | | |
505 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
506 | 529 | | |
507 | 530 | | |
508 | 531 | | |
| |||
762 | 785 | | |
763 | 786 | | |
764 | 787 | | |
765 | | - | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
766 | 791 | | |
767 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
768 | 798 | | |
769 | 799 | | |
770 | 800 | | |
| |||
0 commit comments