Skip to content

Conversation

gargsaumya
Copy link
Contributor

@gargsaumya gargsaumya commented Aug 13, 2025

Work Item / Issue Reference

AB#33395

GitHub Issue: #<ISSUE_NUMBER>


Summary

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] [2] [3] [4]
  • 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] [2]
  • Added ODBC DAE API function pointers (SQLParamData, SQLPutData) and integrated their loading and usage into the driver handle setup. [1] [2] [3] [4]
  • 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] [2]

Build and warning improvements:

  • Adjusted MSVC compiler flags to remove the "treat warnings as errors" option, making builds less strict on warnings.

@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 04:35
@github-actions github-actions bot added pr-size: medium Moderate update size labels Aug 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 adds support for Data At Execution (DAE) streaming in SQL Server for large parameters, particularly NVARCHAR(MAX) fields. The implementation allows streaming of large Unicode strings and binary data through ODBC's DAE mechanism instead of buffering them entirely in memory.

  • Introduces DAE support for streaming large parameters (>4000 characters for strings, >8000 bytes for binary)
  • Updates parameter type mapping to correctly calculate UTF-16 string sizes and identify streamable parameters
  • Refactors C++ bindings to handle SQLParamData/SQLPutData execution flow for large data

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
mssql_python/pybind/ddbc_bindings.h Adds function pointer declarations for SQLParamData and SQLPutData DAE APIs
mssql_python/pybind/ddbc_bindings.cpp Implements DAE streaming logic, extends ParamInfo struct, and handles SQLParamData/SQLPutData execution flow
mssql_python/pybind/CMakeLists.txt Removes /WX compiler flag to make builds less strict on warnings
mssql_python/cursor.py Updates parameter type mapping to return DAE flags and correctly calculate UTF-16 string sizes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gargsaumya gargsaumya changed the title FEAT: NVARCHAR (MAX) support in execute() FEAT: Support for streaming large parameters in execute() Aug 13, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 13, 2025
@microsoft microsoft deleted a comment from Copilot AI Aug 13, 2025
@microsoft microsoft deleted a comment from Copilot AI Aug 13, 2025
@microsoft microsoft deleted a comment from Copilot AI Aug 13, 2025
@gargsaumya gargsaumya force-pushed the saumya/nvarcharmax-execute branch from a17e198 to c0a91a2 Compare August 13, 2025 08:02
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 13, 2025
Copy link
Contributor

@sumitmsft sumitmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite an important feature and very complex too. Hence, we need to make sure it's robust, performant and scalable. Have added some comments to be discussed and requesting some changes in the architecture per se.

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 26, 2025
@gargsaumya gargsaumya force-pushed the saumya/nvarcharmax-execute branch from d0fd54e to 8e53235 Compare August 28, 2025 13:39
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@gargsaumya gargsaumya force-pushed the saumya/nvarcharmax-execute branch from 8e53235 to 48338d6 Compare August 28, 2025 16:32
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: medium Moderate update size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants