From 4f28464ab7dfe9f18cd72fc022257e66a8e2b279 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Sat, 30 Nov 2013 14:40:11 +0100 Subject: Fix evaluation of SQLite driver options Ensure that the options, which are passed to the SQLite driver, are evaluated in the correct order and do not overwrite each other. According to http://www.sqlite.org/c3ref/open.html the SQLITE_OPEN_READONLY and (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) are mutual exclusive, but SQLITE_OPEN_URI can be combined with both of them. Task-number: QTBUG-35186 [ChangeLog][QtSql][QSQLITE] Fixed evaluation of driver options Change-Id: I8e74fe1ce43b9118b15f7b13fc71670bdcd73f68 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Mark Brand --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/sql/drivers') diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 27bc80e63f..c98d6438fc 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -599,24 +599,32 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c if (db.isEmpty()) return false; + + int timeOut = 5000; bool sharedCache = false; - int openMode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, timeOut=5000; - QStringList opts=QString(conOpts).remove(QLatin1Char(' ')).split(QLatin1Char(';')); - foreach(const QString &option, opts) { + bool openReadOnlyOption = false; + bool openUriOption = false; + + const QStringList opts = QString(conOpts).remove(QLatin1Char(' ')).split(QLatin1Char(';')); + foreach (const QString &option, opts) { if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) { bool ok; - int nt = option.mid(21).toInt(&ok); + const int nt = option.mid(21).toInt(&ok); if (ok) timeOut = nt; - } - if (option == QLatin1String("QSQLITE_OPEN_READONLY")) - openMode = SQLITE_OPEN_READONLY; - if (option == QLatin1String("QSQLITE_OPEN_URI")) - openMode |= SQLITE_OPEN_URI; - if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE")) + } else if (option == QLatin1String("QSQLITE_OPEN_READONLY")) { + openReadOnlyOption = true; + } else if (option == QLatin1String("QSQLITE_OPEN_URI")) { + openUriOption = true; + } else if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE")) { sharedCache = true; + } } + int openMode = (openReadOnlyOption ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)); + if (openUriOption) + openMode |= SQLITE_OPEN_URI; + sqlite3_enable_shared_cache(sharedCache); if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) { -- cgit v1.2.3 From 1c47627aa022ebaffdefe1da18cb7ff8146550cc Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Sat, 30 Nov 2013 18:08:35 +0100 Subject: Fix compilation of OCI driver Add missing feature enum in switch statement to avoid warning that would lead to compilation error when compiled with -Wall. Task-number: QTBUG-34794 Change-Id: Ia2f70f27ecbb7a7dfc9d36d261103ff49b6c5e4b [ChangeLog][QtSql][QOCI] Fix compilation Reviewed-by: Mark Brand --- src/sql/drivers/oci/qsql_oci.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sql/drivers') diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index fe9ae42e6f..6843407e9c 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -2159,6 +2159,7 @@ bool QOCIDriver::hasFeature(DriverFeature f) const case SimpleLocking: case EventNotifications: case FinishQuery: + case CancelQuery: case MultipleResultSets: return false; case Unicode: -- cgit v1.2.3 From 6a6f1e3c7efc3614a4160852ccdc7534252dcdd4 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Sat, 30 Nov 2013 20:22:28 +0100 Subject: Support custom port number in IBASE SQL driver Let the IBASE SQL driver use the custom port number that is set via QSqlDatabase::setPort(). Task-number: QTBUG-33345 Change-Id: Ib55b32c8a318d82038d66e8645b416e36dad3edf [ChangeLog][QtSql][QIBASE] Support custom port number Reviewed-by: Mark Brand --- src/sql/drivers/ibase/qsql_ibase.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/sql/drivers') diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 05e9a4aac8..fefdf38bbd 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1445,7 +1445,7 @@ bool QIBaseDriver::open(const QString & db, const QString & user, const QString & password, const QString & host, - int /*port*/, + int port, const QString & connOpts) { Q_D(QIBaseDriver); @@ -1513,9 +1513,13 @@ bool QIBaseDriver::open(const QString & db, i += role.length(); } + QString portString; + if (port != -1) + portString = QStringLiteral("/%1").arg(port); + QString ldb; if (!host.isEmpty()) - ldb += host + QLatin1Char(':'); + ldb += host + portString + QLatin1Char(':'); ldb += db; isc_attach_database(d->status, 0, const_cast(ldb.toLocal8Bit().constData()), &d->ibase, i, ba.data()); -- cgit v1.2.3 From a774aa69db918dc6719e160e70780f3b644c62ca Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Mon, 2 Dec 2013 13:29:10 +0100 Subject: Clear isOpenError flag on successful open call Clear the isOpenError flag in IBase driver if the QIBaseDriver::open() call was successful, otherwise a previous, unsuccessful open() call would block any further QSqlQuery::exec() calls on this database connection. Task-number: QTBUG-13435 Change-Id: Idc64e28cd63805a13f208702ec87dc1bf6b98798 [ChangeLog][QtSql][QIBASE] Fixed the internal state of IBase driver after a failed open call Reviewed-by: Mark Brand --- src/sql/drivers/ibase/qsql_ibase.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sql/drivers') diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index fefdf38bbd..98da296240 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1530,6 +1530,7 @@ bool QIBaseDriver::open(const QString & db, } setOpen(true); + setOpenError(false); return true; } -- cgit v1.2.3