/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to src/transaction.cc

  • Committer: edam
  • Date: 2010-02-07 15:28:23 UTC
  • Revision ID: edam@waxworlds.org-20100207152823-42k206h6gwy7vla4
- fixed .am files so the library gets built!

Show diffs side-by-side

added added

removed removed

24
24
#include <sqlite3cc/database.h>
25
25
#include <sqlite3cc/exception.h>
26
26
#include <boost/thread.hpp>
27
 
#include <boost/lexical_cast.hpp>
28
27
 
29
28
 
30
29
sqlite::basic_transaction::basic_transaction(
37
36
 
38
37
void sqlite::basic_transaction::begin()
39
38
{
40
 
        _database.exec( "BEGIN" );
 
39
        int error_code = _database.exec( "BEGIN" );
 
40
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
41
41
}
42
42
 
43
43
 
44
44
void sqlite::basic_transaction::commit()
45
45
{
46
 
        _database.exec( "COMMIT" );
 
46
        int error_code = _database.exec( "COMMIT" );
 
47
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
47
48
}
48
49
 
49
50
 
50
51
void sqlite::basic_transaction::rollback()
51
52
{
52
 
        _database.exec( "ROLLBACK" );
 
53
        int error_code = _database.exec( "ROLLBACK" );
 
54
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
53
55
}
54
56
 
55
57
 
63
65
 
64
66
void sqlite::exclusive_transaction::begin()
65
67
{
66
 
        _database.exec( "BEGIN EXCLUSIVE" );
 
68
        int error_code = _database.exec( "BEGIN EXCLUSIVE" );
 
69
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
67
70
}
68
71
 
69
72
 
85
88
 
86
89
void sqlite::recursive_transaction::begin()
87
90
{
88
 
        _database.exec( "SAVEPOINT " + _sp_name );
 
91
        int error_code = _database.exec( "SAVEPOINT " + _sp_name );
 
92
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
89
93
}
90
94
 
91
95
 
92
96
void sqlite::recursive_transaction::commit()
93
97
{
94
 
        _database.exec( "RELEASE " + _sp_name );
 
98
        int error_code = _database.exec( "RELEASE " + _sp_name );
 
99
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
95
100
}
96
101
 
97
102
 
98
103
void sqlite::recursive_transaction::rollback()
99
104
{
100
 
        _database.exec( "ROLLBACK TO " + _sp_name );
 
105
        int error_code = _database.exec( "ROLLBACK TO " + _sp_name );
 
106
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
101
107
 
102
108
        // we have rolled back this transaction's savepoint, but the savepoint will
103
109
        // remain on the transaction stack unless we also release it
104
 
        _database.exec( "RELEASE " + _sp_name );
 
110
        error_code = _database.exec( "RELEASE " + _sp_name );
 
111
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
105
112
}