65 lines
1.4 KiB
Objective-C
65 lines
1.4 KiB
Objective-C
#import "YapAbstractDatabaseTransaction.h"
|
|
#import "YapAbstractDatabasePrivate.h"
|
|
|
|
#import "YapDatabaseLogging.h"
|
|
|
|
#if ! __has_feature(objc_arc)
|
|
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
|
|
#endif
|
|
|
|
/**
|
|
* Define log level for this file.
|
|
* See YapDatabaseLogging.h for more information.
|
|
**/
|
|
#if DEBUG
|
|
static const int ydbFileLogLevel = YDB_LOG_LEVEL_INFO;
|
|
#else
|
|
static const int ydbFileLogLevel = YDB_LOG_LEVEL_WARN;
|
|
#endif
|
|
|
|
|
|
@implementation YapAbstractDatabaseTransaction
|
|
|
|
- (id)initWithConnection:(YapAbstractDatabaseConnection *)aConnection
|
|
{
|
|
if ((self = [super init]))
|
|
{
|
|
abstractConnection = aConnection;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)beginTransaction
|
|
{
|
|
sqlite3_stmt *statement = [abstractConnection beginTransactionStatement];
|
|
if (statement == NULL) return;
|
|
|
|
// BEGIN TRANSACTION;
|
|
|
|
int status = sqlite3_step(statement);
|
|
if (status != SQLITE_DONE)
|
|
{
|
|
YDBLogError(@"Couldn't begin transaction: %d %s", status, sqlite3_errmsg(abstractConnection->db));
|
|
}
|
|
|
|
sqlite3_reset(statement);
|
|
}
|
|
|
|
- (void)commitTransaction
|
|
{
|
|
sqlite3_stmt *statement = [abstractConnection commitTransactionStatement];
|
|
if (statement == NULL) return;
|
|
|
|
// COMMIT TRANSACTION;
|
|
|
|
int status = sqlite3_step(statement);
|
|
if (status != SQLITE_DONE)
|
|
{
|
|
YDBLogError(@"Couldn't commit transaction: %d %s", status, sqlite3_errmsg(abstractConnection->db));
|
|
}
|
|
|
|
sqlite3_reset(statement);
|
|
}
|
|
|
|
@end
|