diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-08-31 06:14:08 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-08-31 06:14:08 (GMT) |
commit | eb80f2386d91e9bde23fc752ad25967e99cc10dc (patch) | |
tree | 638d55217c8ee06b0e0007501a72b2ea527d23fb | |
parent | a78c47247ecf67ea8a406bb394d2837e4c18cdc8 (diff) | |
parent | 72f277c3340ad4c6182bd203d21832b9fdace78f (diff) | |
download | Qt-eb80f2386d91e9bde23fc752ad25967e99cc10dc.zip Qt-eb80f2386d91e9bde23fc752ad25967e99cc10dc.tar.gz Qt-eb80f2386d91e9bde23fc752ad25967e99cc10dc.tar.bz2 |
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
-rw-r--r-- | src/sql/drivers/sqlite/qsql_sqlite.cpp | 24 | ||||
-rw-r--r-- | src/sql/kernel/qsqldatabase.cpp | 1 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 81afbf9..db7950d 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -502,15 +502,27 @@ static int qGetSqliteTimeout(QString opts) enum { DefaultTimeout = 5000 }; opts.remove(QLatin1Char(' ')); - if (opts.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) { - bool ok; - int nt = opts.mid(21).toInt(&ok); - if (ok) - return nt; + foreach(QString option, opts.split(QLatin1Char(';'))) { + if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) { + bool ok; + int nt = option.mid(21).toInt(&ok); + if (ok) + return nt; + } } return DefaultTimeout; } +static int qGetSqliteOpenMode(QString opts) +{ + opts.remove(QLatin1Char(' ')); + foreach(QString option, opts.split(QLatin1Char(';'))) { + if (option == QLatin1String("QSQLITE_OPEN_READONLY")) + return SQLITE_OPEN_READONLY; + } + return SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; +} + /* SQLite dbs have no user name, passwords, hosts or ports. just file names. @@ -523,7 +535,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c if (db.isEmpty()) return false; - if (sqlite3_open16(db.constData(), &d->access) == SQLITE_OK) { + if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, qGetSqliteOpenMode(conOpts), NULL) == SQLITE_OK) { sqlite3_busy_timeout(d->access, qGetSqliteTimeout(conOpts)); setOpen(true); setOpenError(false); diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index d155c03..16bd05b 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -1263,6 +1263,7 @@ QSqlRecord QSqlDatabase::record(const QString& tablename) const \i \list \i QSQLITE_BUSY_TIMEOUT + \i QSQLITE_OPEN_READONLY \endlist \i |