Skip to content

SS-124: SQL Server: Improve handling of CHAR(N) type when dealing with multi-byte encoding#37424

Draft
martykulma wants to merge 3 commits into
MaterializeInc:mainfrom
martykulma:maz-sqlserver-fix-char-len
Draft

SS-124: SQL Server: Improve handling of CHAR(N) type when dealing with multi-byte encoding#37424
martykulma wants to merge 3 commits into
MaterializeInc:mainfrom
martykulma:maz-sqlserver-fix-char-len

Conversation

@martykulma

@martykulma martykulma commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

SQL Server CHAR(N) type limits the number of bytes, not characters. Under different collations, this column has variable character length. Materialize expects this to contain a consistent character length.

This PR adds the test from the bug report, fix, and a minor doc addition about the encoding.

The fix has 2 parts:

  • sources created after this fix will encode CHAR(N) as STRING, so there is no character length validation, and Materialize displays the string consistently with the upstream DB.
  • sources created before this fix will continue to decode as CHARACTER with padding, but the check is relaxed to only error if the character length is greater than the byte length. This is a deprecated code path, so I didn't modify the error.

Fixes https://linear.app/materializeinc/issue/SS-124/sql-server-charn-with-utf-8-expected-n-chars-found-less-than-n

There are some formatting changes in the PR, so view with ignore white space

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