/sqlite3cc

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

« back to all changes in this revision

Viewing changes to src/query.cc

  • Committer: edam
  • Date: 2010-07-23 12:57:07 UTC
  • Revision ID: edam@waxworlds.org-20100723125707-qu9jk9vvg2uewx7t
- cleaned up test-main
- fixed comment type
- made sqlite::exec() throw instead of returning sqlite error code

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <sqlite3cc/query.h>
24
24
#include <sqlite3cc/row.h>
25
 
#include <sqlite3cc/database.h>
26
25
#include <assert.h>
27
26
 
28
27
 
50
49
        const std::string &sql )
51
50
{
52
51
        _next_row = 0;
53
 
        int code = basic_statement::prepare( sql );
54
 
        assert( code != SQLITE_OK || sqlite3_column_count( _handle ) > 0 );
55
 
        return code;
 
52
        int error_code = basic_statement::prepare( sql );
 
53
        assert( error_code != SQLITE_OK || sqlite3_column_count( _handle ) > 0 );
 
54
        return error_code;
56
55
}
57
56
 
58
57
 
59
58
sqlite::row sqlite::query::step()
60
59
{
61
 
        database::database_mutex_guard lock( _database );
62
 
 
63
 
        int code = basic_statement::step();
64
 
        if( code == SQLITE_DONE ) return row();
65
 
        if( code == SQLITE_ROW ) return row( _handle, _next_row++ );
66
 
 
67
 
        throw sqlite_error( _database, code );
 
60
//      sqlite3_mutex_enter( sqlite3_db_mutex( _database ) );
 
61
//      try {
 
62
                int error_code = basic_statement::step();
 
63
                if( error_code == SQLITE_ROW ) {
 
64
//                      sqlite3_mutex_leave( sqlite3_db_mutex( _database ) );
 
65
                        return row( _handle, _next_row++ );
 
66
                }
 
67
                if( error_code == SQLITE_DONE ) {
 
68
//                      sqlite3_mutex_leave( sqlite3_db_mutex( _database ) );
 
69
                        return row();
 
70
                }
 
71
                throw sqlite_error( error_code );
 
72
//      }
 
73
//      catch( ... ) {
 
74
//              sqlite3_mutex_leave( sqlite3_db_mutex( _database ) );
 
75
//              throw;
 
76
//      }
68
77
}
69
78
 
70
79
 
126
135
{
127
136
        return sqlite::query::iterator( *this, false );
128
137
}
129