Repository navigation
SqlConnection: decide the SQLite narrow-text mode the way the driver does - #712
Merged
christianparpart merged 1 commit intoNov 22, 2026
Merged
Conversation
…does The SQLite ODBC driver takes its OEMCP option from the connection string, then from the data source's profile, and defaults it to on for a data-source connect (SQLConnect) and to off for a connection string. Lightweight only looked at the connection string, so a DSN with OEMCP in its profile, or any data-source connect, still bound narrow text as SQL_C_CHAR, which the driver then converted with the thread's ANSI code page. The mode now follows the same order: the connection-string key, else the data source's profile (SQLGetPrivateProfileString, user then system DSN), else the connect path's default. Connect(SqlConnectionDataSource) records its data source so the mode is decided for it too. The narrow paths that ignored the mode follow it now as well: the char binder (parameters, output columns, column-wise batches) and the backup batch layer's narrow text columns, which restore passes the target connection's mode. Statement text needs nothing: on Windows it always goes through the wide entry points. Signed-off-by: Christian Parpart <christian@parpart.family>
christianparpart
force-pushed
the
fix/sqlite-narrow-text-mode-follows-driver
branch
from
November 22, 2026 18:47
984735d to
fda900e
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
christianparpart
deleted the
fix/sqlite-narrow-text-mode-follows-driver
branch
November 22, 2026 19:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #708.
Problem
#708 decides whether a SQLite connection binds narrow text wide (converted with the process ANSI code page) from the connection string's
OEMCPkey only. The sqliteodbc driver decidesOEMCPdifferently, so where the two disagree, narrow text is still bound asSQL_C_CHARand converted with the thread's ANSI code page.Measured on Windows (thread code page 1251, process 1252;
0xDFbound asSQL_C_CHAR, stored bytes):OEMCPSQLConnectD0AFSQLConnect1D0AFSQLConnect0DFSQLDriverConnectDSN=DFSQLDriverConnectDSN=1D0AFSQLDriverConnectDSN=0DFSQLDriverConnectDSN=…;OEMCP=01DFSQLDriverConnectDSN=…;OEMCP=1D0AFSQLDriverConnectDriver=DFSQLDriverConnectDriver=…;OEMCP=1D0AFSo the driver uses the connection-string key, then the profile, then a default that is on for
SQLConnectand off for a connection string.Fix
SqlConnectiondecides the mode in that order. The profile is read withSQLGetPrivateProfileStringW(user, then system DSN).Connect(SqlConnectionDataSource)now records its data source so the mode is decided for data-source connects too. Doxygen ofNarrowTextBindingModeupdated; only a borrowed handle keeps the narrow default.SqlDataBinder<char>: parameters, output columns,GetColumnand column-wise batches go throughSQL_C_WCHARunder the process-code-page mode.BatchManagertakes the target connection's mode (restore passes it); narrow text columns are sent as UTF-16 under that mode.odbccp32(pluslegacy_stdio_definitions, which its import library needs).Tests
All Windows-only, under a thread locale whose ANSI code page differs from the process one. All fail before this change: 11 of 59 assertions in 4 of the 5 cases.
OEMCP=1/0/unset) and the data-source connect default, with the connection-string key overriding the profile.OEMCPonly in its profile, and on a data-source connect.charbound, read and batched on anOEMCP=1connection.BatchManagerrestoring non-ASCII narrow text (VARCHAR and CHAR) into anOEMCP=1connection.The thread-locale helpers moved into
src/tests/ForeignThreadLocale.hpp.Locally with MSVC on SQLite: full suite green.