diff options
author | Christian Kamm <mail@ckamm.de> | 2019-03-04 15:58:38 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2019-03-05 11:15:38 +0300 |
commit | a39f4a532f102e9cc60039108124ce1f572f15cb (patch) | |
tree | 325197f86d93633dfe489f03632c7bcd053899d9 /test/testownsql.cpp | |
parent | c859f87997433ebac7da7c9f00dcdc1e9573c5b9 (diff) |
OwnSql: Distinguish no-data from error #6677
This could fix a problem where the client incorrectly decides to delete
local data.
Previously any sqlite3_step() return value that wasn't SQLITE_ROW would
be interpreted as "there's no more data here". Thus an sqlite error at a
bad time could cause the remote discovery to fail to read an unchanged
subtree from the database. These files would then be deleted locally.
With this change sqlite errors from sqlite3_step are detected and
logged. For the particular case of SyncJournalDb::getFilesBelowPath()
the error will now be propagated and the sync run will fail instead of
performing spurious deletes.
Note that many other database functions still don't distinguish
not-found from error cases. Most of them won't have as severe effects on
affected sync runs though.
Diffstat (limited to 'test/testownsql.cpp')
-rw-r--r-- | test/testownsql.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/testownsql.cpp b/test/testownsql.cpp index 86ec77d28..58e9bc5b6 100644 --- a/test/testownsql.cpp +++ b/test/testownsql.cpp @@ -71,7 +71,7 @@ private slots: q.prepare(sql); q.exec(); - while( q.next() ) { + while( q.next().hasData ) { qDebug() << "Name: " << q.stringValue(1); qDebug() << "Address: " << q.stringValue(2); } @@ -83,7 +83,7 @@ private slots: q.prepare(sql); q.bindValue(1, 2); q.exec(); - if( q.next() ) { + if( q.next().hasData ) { qDebug() << "Name:" << q.stringValue(1); qDebug() << "Address:" << q.stringValue(2); } @@ -96,7 +96,7 @@ private slots: int rc = q.prepare(sql); qDebug() << "Pragma:" << rc; q.exec(); - if( q.next() ) { + if( q.next().hasData ) { qDebug() << "P:" << q.stringValue(1); } } @@ -118,7 +118,7 @@ private slots: SqlQuery q(_db); q.prepare(sql); - if(q.next()) { + if(q.next().hasData) { QString name = q.stringValue(1); QString address = q.stringValue(2); QVERIFY( name == QString::fromUtf8("пятницы") ); |