[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/akonadi-sqlite/server/src
From: Bertjan Broeksema <b.broeksema () home ! nl>
Date: 2009-08-19 13:02:43
Message-ID: 1250686963.926795.19738.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1013291 by bbroeksema:
Make sure that queries that alter the database are done as a transaction.
M +6 -1 handler/fetch.cpp
M +5 -0 storage/datastore.cpp
M +5 -0 storage/entities-source.xsl
M +5 -4 storage/transaction.cpp
--- branches/work/akonadi-sqlite/server/src/handler/fetch.cpp #1013290:1013291
@@ -29,6 +29,7 @@
#include "storage/itemqueryhelper.h"
#include "storage/itemretrievalmanager.h"
#include "storage/parthelper.h"
+#include "storage/transaction.h"
#include "akdebug.h"
#include "imapstreamparser.h"
#include "handlerhelper.h"
@@ -73,12 +74,16 @@
void Fetch::updateItemAccessTime()
{
+ Transaction transaction( connection()->storageBackend() );
QueryBuilder qb( QueryBuilder::Update );
qb.addTable( PimItem::tableName() );
qb.setColumnValue( PimItem::atimeColumn(), QDateTime::currentDateTime() );
ItemQueryHelper::scopeToQuery( mScope, connection(), qb );
- if ( !qb.exec() )
+ if ( !qb.exec() ) {
qWarning() << "Unable to update item access time";
+ } else {
+ transaction.commit();
+ }
}
void Fetch::triggerOnDemandFetch()
--- branches/work/akonadi-sqlite/server/src/storage/datastore.cpp #1013290:1013291
@@ -27,6 +27,7 @@
#include "notificationmanager.h"
#include "tracer.h"
#include "selectquerybuilder.h"
+#include "transaction.h"
#include "handlerhelper.h"
#include "countquerybuilder.h"
#include "xdgbasedirs_p.h"
@@ -275,8 +276,12 @@
qb.addTable( Collection::tableName() );
qb.addValueCondition( Collection::parentIdColumn(), Query::Equals, collection.id() \
); qb.setColumnValue( Collection::resourceIdColumn(), resourceId );
+ Transaction transaction( DataStore::self() );
if ( !qb.exec() )
return false;
+
+ transaction.commit();
+
foreach ( const Collection &col, collection.children() ) {
if ( !recursiveSetResourceId( col, resourceId ) )
return false;
--- branches/work/akonadi-sqlite/server/src/storage/entities-source.xsl \
#1013290:1013291 @@ -26,6 +26,8 @@
<xsl:variable name="tableName"><xsl:value-of select="@name"/>Table</xsl:variable>
<xsl:variable name="entityName"><xsl:value-of select="@name"/></xsl:variable>
+#include "storage/transaction.h"
+
// private class
class <xsl:value-of select="$className"/>::Private : public QSharedData
{
@@ -440,12 +442,15 @@
</xsl:if>
</xsl:for-each>
+ Transaction transaction( DataStore::self() );
if ( !qb.exec() ) {
qDebug() << "Error during insertion into table" << tableName()
<< qb.query().lastError().text();
return false;
}
+ transaction.commit();
+
setId( qb.insertId() );
if ( insertId )
*insertId = id();
--- branches/work/akonadi-sqlite/server/src/storage/transaction.cpp #1013290:1013291
@@ -21,6 +21,7 @@
#include "storage/datastore.h"
#include <QtCore/QDebug>
+#include <QtCore/QThread>
Akonadi::Transaction::Transaction(DataStore * db, bool beginTransaction ) :
mDb( db ), mCommitted( false )
@@ -34,22 +35,22 @@
Akonadi::Transaction::~Transaction()
{
if ( !mCommitted ) {
- qDebug() << "ROLLING BACK TRANSACTION";
+ qDebug() << '[' << QString::number(QThread::currentThreadId()) << "] ROLLING \
BACK TRANSACTION"; mDb->rollbackTransaction();
} else {
- qDebug() << "TRANSACTION SUCCESSFUL COMITTED";
+ qDebug() << '[' << QString::number(QThread::currentThreadId()) << "] TRANSACTION \
SUCCESSFUL COMITTED"; }
}
bool Akonadi::Transaction::commit()
{
- qDebug() << "COMMITTING TRANSACTION";
+ qDebug( )<< '[' << QString::number(QThread::currentThreadId()) << "] COMMITTING \
TRANSACTION"; mCommitted = true;
return mDb->commitTransaction();
}
void Akonadi::Transaction::begin()
{
- qDebug() << "BEGINNING TRANSACTION";
+ qDebug() << '[' << QString::number(QThread::currentThreadId()) << "] BEGINNING \
TRANSACTION"; mDb->beginTransaction();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic