From b542b25c47adb96350d912192d2a19cf85d75020 Mon Sep 17 00:00:00 2001 From: "Don C. Bigler" Date: Fri, 7 Dec 2018 12:18:35 -0500 Subject: [PATCH] Fix QTBUG-25260 --- src/plugins/sqldrivers/configure.json | 28 ++++++++++++++++++++--- src/plugins/sqldrivers/odbc/odbc.pro | 12 +++++++++- src/plugins/sqldrivers/odbc/qsql_odbc.cpp | 4 ++++ src/plugins/sqldrivers/odbc/qsql_odbc_p.h | 12 ++++++++-- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json index 234f880579..12ebc545c2 100644 --- a/src/plugins/sqldrivers/configure.json +++ b/src/plugins/sqldrivers/configure.json @@ -130,8 +130,30 @@ }, "sources": [ { "libs": "-lodbc32", "condition": "config.win32" }, - { "libs": "-liodbc", "condition": "config.darwin" }, - { "libs": "-lodbc", "condition": "!config.win32 && !config.darwin" } + { "libs": "-lodbc", "condition": "!config.win32" } + ] + }, + "iodbc": { + "label": "IODBC", + "test": { + "head": [ + "#if defined(__APPLE__)", + "# include ", + "# include ", + "#else", + "# include ", + "# include ", + "#endif" + ], + "main": [ + "SQLHANDLE env;", + "SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);" + ], + "qmake": ["macx:QMAKE_CXXFLAGS += -F/Library/Frameworks"] + }, + "sources": [ + { "libs": "-F/Library/Frameworks -framework iODBC", "condition": "config.darwin" }, + { "libs": "-liodbc", "condition": "!config.win32 && !config.darwin" } ] }, "sqlite2": { @@ -186,7 +208,7 @@ }, "sql-odbc": { "label": "ODBC", - "condition": "features.datestring && libs.odbc", + "condition": "features.datestring && libs.odbc || libs.iodbc", "output": [ "privateFeature" ] }, "sql-psql": { diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 17844f27d2..6ebe80d3a9 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -3,10 +3,20 @@ TARGET = qsqlodbc HEADERS += $$PWD/qsql_odbc_p.h SOURCES += $$PWD/qsql_odbc.cpp $$PWD/main.cpp -QMAKE_USE += odbc unix: DEFINES += UNICODE OTHER_FILES += odbc.json PLUGIN_CLASS_NAME = QODBCDriverPlugin include(../qsqldriverbase.pri) + +defined(QMAKE_LIBS_ODBC, var) { + QMAKE_USE += odbc +} else { + DEFINES += Q_IODBC_NO_SQLFETCHSCROLL + macx { + DEFINES += Q_IODBC_MACOS_FRAMEWORK + QMAKE_CXXFLAGS += -F/Library/Frameworks + } + QMAKE_USE += iodbc +} diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 59ef42d609..d456700753 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -2196,12 +2196,16 @@ void QODBCDriverPrivate::checkDBMS() void QODBCDriverPrivate::checkHasSQLFetchScroll() { +#ifndef Q_IODBC_NO_SQLFETCHSCROLL SQLUSMALLINT sup; SQLRETURN r = SQLGetFunctions(hDbc, SQL_API_SQLFETCHSCROLL, &sup); if ((r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) || sup != SQL_TRUE) { +#endif hasSQLFetchScroll = false; qWarning("QODBCDriver::checkHasSQLFetchScroll: Warning - Driver doesn't support scrollable result sets, use forward only mode for queries"); +#ifndef Q_IODBC_NO_SQLFETCHSCROLL } +#endif } void QODBCDriverPrivate::checkHasMultiResults() diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc_p.h b/src/plugins/sqldrivers/odbc/qsql_odbc_p.h index f4ce8bc243..1f695376a9 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc_p.h +++ b/src/plugins/sqldrivers/odbc/qsql_odbc_p.h @@ -71,12 +71,20 @@ // workaround for Borland to make sure that SQLBIGINT is defined # define _MSC_VER 900 #endif -#include +#ifdef Q_IODBC_MACOS_FRAMEWORK +# include +#else +# include +#endif #if defined(Q_CC_BOR) # undef _MSC_VER #endif -#include +#ifdef Q_IODBC_MACOS_FRAMEWORK +# include +#else +# include +#endif QT_BEGIN_NAMESPACE -- 2.17.0