[Pkg-owncloud-commits] [owncloud-client] 73/211: NewSQL: minor fixes to get stuff going

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 357c08c5b3fa858529cb49d1de0f039811ab6f62
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue Oct 14 12:18:33 2014 +0200

    NewSQL: minor fixes to get stuff going
---
 src/mirall/ownsql.cpp        | 16 +++++++++++-----
 src/mirall/syncjournaldb.cpp |  2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/mirall/ownsql.cpp b/src/mirall/ownsql.cpp
index ee18274..6d61465 100644
--- a/src/mirall/ownsql.cpp
+++ b/src/mirall/ownsql.cpp
@@ -17,11 +17,12 @@
 
 #include "ownsql.h"
 
-#define SQLITE_DO(A) if(1) { _errId = SQLITE_OK; \
-    if( A != SQLITE_OK ) { _error= QString::fromUtf8(sqlite3_errmsg(_db)); \
-    _errId = sqlite3_extended_errcode(_db ); } }
+#define SQLITE_DO(A) if(1) { \
+    _errId = (A); if(_errId != SQLITE_OK) { _error= QString::fromUtf8(sqlite3_errmsg(_db)); \
+     } }
 
 SqlDatabase::SqlDatabase()
+    :_db(NULL)
 {
 
 }
@@ -33,7 +34,12 @@ bool SqlDatabase::isOpen()
 
 bool SqlDatabase::open( const QString& filename )
 {
-    SQLITE_DO( sqlite3_open_v2(filename.toUtf8().constData(), &_db, SQLITE_OPEN_NOMUTEX, NULL) );
+    if(isOpen()) {
+        return true;
+    }
+
+    int flag = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_NOMUTEX;
+    SQLITE_DO( sqlite3_open_v2(filename.toUtf8().constData(), &_db, flag, NULL) );
 
     if( _errId != SQLITE_OK ) {
         close(); // FIXME: Correct?
@@ -94,7 +100,7 @@ SqlQuery::SqlQuery(const QString& sql, SqlDatabase db)
 
 void SqlQuery::prepare( const QString& sql)
 {
-    SQLITE_DO(sqlite3_prepare_v2(_db, sql.toUtf8(), -1, &_stmt, NULL));
+    SQLITE_DO(sqlite3_prepare_v2(_db, sql.toUtf8().constData(), -1, &_stmt, NULL));
 }
 
 bool SqlQuery::exec()
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index d831d82..b643c75 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -210,7 +210,7 @@ bool SyncJournalDb::checkConnect()
             return sqlFail("Remove version", createQuery);
         }
     }
-    createQuery.prepare("INSERT INTO version (major, minor, patch) VALUES ( ? , ? , ? );");
+    createQuery.prepare("INSERT INTO version (major, minor, patch) VALUES ( ?1 , ?2 , ?3 );");
     createQuery.bindValue(0, MIRALL_VERSION_MAJOR);
     createQuery.bindValue(1, MIRALL_VERSION_MINOR);
     createQuery.bindValue(2, MIRALL_VERSION_PATCH);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list