Skip to content

Conversation

bewithgaurav
Copy link
Collaborator

@bewithgaurav bewithgaurav commented Sep 3, 2025

Work Item / Issue Reference

AB#38479

GitHub Issue: #<ISSUE_NUMBER>


Summary

Fix string handling in executemany batch operations on Unix systems

Issue:
executemany was corrupting string data on Unix/macOS due to encoding mismatch in batch parameter binding. Strings were either truncated or returned garbage data.

Root Cause:
In BindParameterArray function, std::wstring (UTF-32 on Unix) was directly copied to SQLWCHAR buffers (UTF-16) without proper encoding conversion, while single parameter binding in execute correctly used WStringToSQLWCHAR().

Fix:

  • Added platform-specific string conversion in BindParameterArray for SQL_C_WCHAR case
  • Unix: Use WStringToSQLWCHAR() for proper UTF-32 → UTF-16 conversion
  • Windows: Keep existing direct copy (both are UTF-16)

Impact:

  • All string data (including empty strings) now correctly preserved in executemany
  • Eliminates data corruption and truncation on Unix platforms
  • Maintains existing Windows behavior
  • Consistent string handling between execute and executemany

@github-actions github-actions bot added the pr-size: large Substantial code update label Sep 3, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: large Substantial code update labels Sep 3, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 3, 2025
@bewithgaurav bewithgaurav changed the title FIX: Unix handling in Executemany FIX: Fix for executemany with empty strings and binary data on Unix systems Sep 3, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 3, 2025
@bewithgaurav bewithgaurav changed the title FIX: Fix for executemany with empty strings and binary data on Unix systems FIX: Executemany with empty strings on Unix systems Sep 3, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 3, 2025
@bewithgaurav bewithgaurav changed the title FIX: Executemany with empty strings on Unix systems FIX: Executemany on Unix systems Sep 3, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 3, 2025
@github-actions github-actions bot added the pr-size: large Substantial code update label Sep 4, 2025
@bewithgaurav bewithgaurav changed the base branch from main to bewithgaurav/fix_blank_columns September 4, 2025 10:22
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: large Substantial code update labels Sep 4, 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.

LEft a few comments.

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 5, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: medium Moderate update size labels Sep 5, 2025
sumitmsft
sumitmsft previously approved these changes Sep 5, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 5, 2025
@bewithgaurav bewithgaurav changed the base branch from bewithgaurav/fix_blank_columns to main September 6, 2025 07:42
@bewithgaurav bewithgaurav dismissed sumitmsft’s stale review September 6, 2025 07:42

The base branch was changed.

@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 6, 2025
@bewithgaurav bewithgaurav merged commit 95a1f18 into main Sep 8, 2025
18 checks passed
@bewithgaurav bewithgaurav linked an issue Sep 8, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: large Substantial code update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Executemany corrupts string data on Unix/macOS systems
3 participants