/sqlite3cc

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

« back to all changes in this revision

Viewing changes to src/database.cc

  • Committer: edam
  • Date: 2010-07-27 15:46:42 UTC
  • Revision ID: edam@waxworlds.org-20100727154642-1uxrjkpxhp7xl6hq
- moved null_t, exec_t and set_index_t to detail namespace so only their extern instantiations are in the main namespace
- added immediate transation

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        :
30
30
        _handle( NULL )
31
31
{
32
 
        int code = open( filename );
33
 
        if( code != SQLITE_OK ) throw sqlite_error( *this, code );
 
32
        int error_code = open( filename );
 
33
        if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
34
34
}
35
35
 
36
36
 
69
69
        const std::string &sql )
70
70
{
71
71
        int code = sqlite3_exec( _handle, sql.c_str(), NULL, NULL, NULL );
72
 
        if( code ) throw sqlite_error( *this, code );
 
72
        if( code ) throw sqlite_error( code );
73
73
}
74
74
 
75
75
 
78
78
{
79
79
        return sqlite3_busy_timeout( _handle, duration );
80
80
}
81
 
 
82
 
 
83
 
sqlite::database::database_mutex_guard::database_mutex_guard(
84
 
        database &database )
85
 
        :
86
 
        _mutex( sqlite3_db_mutex( database._handle ) )
87
 
{
88
 
        if( _mutex ) sqlite3_mutex_enter( _mutex );
89
 
}
90
 
 
91
 
 
92
 
sqlite::database::database_mutex_guard::~database_mutex_guard()
93
 
{
94
 
        leave();
95
 
}
96
 
 
97
 
void sqlite::database::database_mutex_guard::leave()
98
 
{
99
 
        if( _mutex ) {
100
 
                sqlite3_mutex_leave( _mutex );
101
 
                _mutex = NULL;
102
 
        }
103
 
}