1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
Description: SQL/ODBC: add another check to detect unicode availability in driver
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.
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f19320748d282b1e
Last-Update: 2023-06-30
Index: qtbase-opensource-src-5.15.2+dfsg/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
===================================================================
--- qtbase-opensource-src-5.15.2+dfsg.orig/src/plugins/sqldrivers/odbc/qsql_odbc.cpp 2024-04-28 17:59:07.172222178 +0200
+++ qtbase-opensource-src-5.15.2+dfsg/src/plugins/sqldrivers/odbc/qsql_odbc.cpp 2024-04-28 17:59:07.172222178 +0200
@@ -2109,7 +2109,18 @@
hDbc,
&hStmt);
- r = SQLExecDirect(hStmt, toSQLTCHAR(QLatin1String("select 'test'")).data(), SQL_NTS);
+ // 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) {
+ r = SQLExecDirect(hStmt, toSQLTCHAR(statement).data(), SQL_NTS);
+ if (r == SQL_SUCCESS)
+ break;
+ }
if(r == SQL_SUCCESS) {
r = SQLFetch(hStmt);
if(r == SQL_SUCCESS) {
|