From: Debian Qt/KDE Maintainers Date: Sat, 8 Feb 2025 16:24:33 +0000 (+0300) Subject: SQL/ODBC: add another check to detect unicode availability in driver X-Git-Tag: archive/raspbian/5.15.15+dfsg-4+rpi1^2~24 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=849beb75b6444cf95cbc30bba1dd1f155f1c9af7;p=qtbase-opensource-src.git SQL/ODBC: add another check to detect unicode availability in driver Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f19320748d282b1e Last-Update: 2024-05-25 Since ODBC does not have a direct way finding out if unicode is supported by the underlying driver the ODBC plugin does some checks. As a last resort a sql statement is executed which returns a string. But even this may fail because the select statement has no FROM part which is rejected by at least Oracle does not allow. Therefore add another query which is correct for Oracle & DB2 as a workaround. The question why the first three statements to check for unicode availability fail is still open but can't be checked since I've no access to an oracle database. Gbp-Pq: Name sql_odbc_more_unicode_checks.diff --- diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 8e2e88365..cb7e7a629 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -2110,9 +2110,18 @@ void QODBCDriverPrivate::checkUnicode() hDbc, &hStmt); - { - auto encoded = toSQLTCHAR(QLatin1String("select 'test'")); + // for databases which do not return something useful in SQLGetInfo and are picky about a + // 'SELECT' statement without 'FROM' but support VALUE(foo) statement like e.g. DB2 or Oracle + const auto statements = { + QLatin1String("select 'test'"), + QLatin1String("values('test')"), + QLatin1String("select 'test' from dual"), + }; + for (const auto &statement : statements) { + auto encoded = toSQLTCHAR(statement); r = SQLExecDirect(hStmt, encoded.data(), SQLINTEGER(encoded.size())); + if (r == SQL_SUCCESS) + break; } if(r == SQL_SUCCESS) { r = SQLFetch(hStmt);