Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctlib: Implement full Unicode support for TDS 7+ (MSSQL). #576

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ucko
Copy link
Contributor

@ucko ucko commented May 30, 2024

  • Introduce CS_NLONGCHAR_TYPE and CS_NVARCHAR_TYPE, both corresponding to SYBNVARCHAR (along with CS_UNICHAR_TYPE); have ct_param automatically promote CS_{LONG,VAR}CHAR_TYPE to CS_N{LONG,VAR}CHAR_TYPE for TDS 7+ when non-ASCII characters appear in the data. (Unnecessary use of Unicode types can make parameterized queries against 8-bit text columns run very slowly.)
  • ctlib/cs.c (cs_convert): Formally support Unicode destination types (SYBNVARCHAR and SYBNTEXT).
  • ctlib/ct.c (paraminfoalloc): When setting maximum length automatically, account for possible conversion to UCS-2.
  • tds/convert.c (tds_convert), tds/tds_willconvert.*: Formally support Unicode types, giving type 103 (0x67) the benefit of the doubt as SYBNVARCHAR rather than SYBSENSITIVITY.
  • tds/data.c (tds_set_param_type): Map SYBNVARCHAR to XSYBNVARCHAR for TDS 7+.
  • tds/unittests/convert.c: Accommodate Unicode types, albeit with strings left narrow to match real-life usage, wherein encoding conversion occurs separately.

Split from #555.

* Introduce CS_NLONGCHAR_TYPE and CS_NVARCHAR_TYPE, both corresponding to
  SYBNVARCHAR (along with CS_UNICHAR_TYPE); have ct_param automatically
  promote CS_{LONG,VAR}CHAR_TYPE to CS_N{LONG,VAR}CHAR_TYPE for TDS 7+
  when non-ASCII characters appear in the data.  (Unnecessary use of
  Unicode types can make parameterized queries against 8-bit text
  columns run very slowly.)
* ctlib/cs.c (cs_convert): Formally support Unicode destination types
  (SYBNVARCHAR and SYBNTEXT).
* ctlib/ct.c (paraminfoalloc): When setting maximum length automatically,
  account for possible conversion to UCS-2.
* tds/convert.c (tds_convert), tds/tds_willconvert.*: Formally support
  Unicode types, giving type 103 (0x67) the benefit of the doubt as
  SYBNVARCHAR rather than SYBSENSITIVITY.
* tds/data.c (tds_set_param_type): Map SYBNVARCHAR to XSYBNVARCHAR for
  TDS 7+.
* tds/unittests/convert.c: Accommodate Unicode types, albeit with
  strings left narrow to match real-life usage, wherein encoding
  conversion occurs separately.

Signed-off-by: Aaron M. Ucko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant