summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-03-06 20:44:48 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-03-12 16:21:17 +0000
commitf19320748d282b1e68fc2e3de2b0cf9ec44b49ef (patch)
tree954892816344d35e2a270728c58bee336ffba5d4 /src/plugins/sqldrivers/odbc/qsql_odbc.cpp
parent3b2c09a13cc83a9b636eefaced674f6000048f2d (diff)
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. Pick-to: 6.5 Fixes: QTBUG-96616 Fixes: QTBUG-102958 Change-Id: I8ec0115bbfbfc40852bcfb8e94b4b4ad3e395b37 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/odbc/qsql_odbc.cpp')
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index c2252c3f77..bcd8a72e28 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -2050,7 +2050,18 @@ void QODBCDriverPrivate::checkUnicode()
hDbc,
&hStmt);
- r = SQLExecDirect(hStmt, toSQLTCHAR("select 'test'"_L1).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 = {
+ "select 'test'"_L1,
+ "values('test')"_L1,
+ "select 'test' from dual"_L1,
+ };
+ 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) {