/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-07-27 15:12:55 UTC
  • Revision ID: edam@waxworlds.org-20100727151255-goaqgdz4kj13q7gz
- update TODO
- added some missing includes for <string>
- changed usage of database::exec() to not require return code!
- prevented transaction_guard destructor from throwing an exception

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
}
48
48
 
49
49
 
50
 
void sqlite::basic_transaction::invalidate_queries()
51
 
{
52
 
        while( sqlite3_stmt *handle = sqlite3_next_stmt( _database._handle, NULL ) )
53
 
                if( int code = sqlite3_finalize( handle ) )
54
 
                        throw sqlite_error( _database, code );
55
 
}
56
 
 
57
 
 
58
50
void sqlite::basic_transaction::rollback()
59
51
{
60
 
        // we must invalidate any active queries when rolling back
61
 
        invalidate_queries();
62
52
        _database.exec( "ROLLBACK" );
63
53
}
64
54
 
65
55
 
66
 
sqlite::immediate_transaction::immediate_transaction(
67
 
        database &database )
68
 
        :
69
 
        basic_transaction( database )
70
 
{
71
 
}
72
 
 
73
 
 
74
 
void sqlite::immediate_transaction::begin()
75
 
{
76
 
        _database.exec( "BEGIN IMMEDIATE" );
77
 
}
78
 
 
79
 
 
80
56
sqlite::exclusive_transaction::exclusive_transaction(
81
57
        database &database )
82
58
        :
97
73
        basic_transaction( database )
98
74
{
99
75
        static unsigned long long i = 0;
 
76
        unsigned long long my_i;
100
77
        static boost::mutex mutex;
101
 
        unsigned long long my_i;
102
78
        {
103
79
                boost::lock_guard< boost::mutex > lock( mutex );
104
80
                my_i = i++;
121
97
 
122
98
void sqlite::recursive_transaction::rollback()
123
99
{
124
 
        // we must invalidate any active queries when rolling back
125
 
        invalidate_queries();
126
100
        _database.exec( "ROLLBACK TO " + _sp_name );
127
101
 
128
102
        // we have rolled back this transaction's savepoint, but the savepoint will