| Class | Amalgalite::SQLite3::Stat |
| In: |
lib/amalgalite/sqlite3/status.rb
ext/amalgalite3.c |
| Parent: | Object |
| code | [R] | |
| name | [R] |
# File lib/amalgalite/sqlite3/status.rb, line 16
16: def initialize( name )
17: @name = name
18: @code = ::Amalgalite::SQLite3::Constants::Status.value_from_name( name )
19: @current = nil
20: @highwater = nil
21: end
# File lib/amalgalite/sqlite3/status.rb, line 23
23: def current
24: update!
25: return @current
26: end
# File lib/amalgalite/sqlite3/status.rb, line 28
28: def highwater
29: update!
30: return @highwater
31: end
Populates the _@current_ and _@higwater_ instance variables of self object with the values from the sqlite3_status call. If reset it true then the highwater mark for the stat is reset
/*
* call-seq:
* Amalgalite::SQLite3::Stat.update!( reset = false ) -> nil
*
* Populates the _@current_ and _@higwater_ instance variables of self
* object with the values from the sqlite3_status call. If reset it true then
* the highwater mark for the stat is reset
*
*/
VALUE am_sqlite3_stat_update_bang( int argc, VALUE *argv, VALUE self )
{
int status_op = -1;
int current = -1;
int highwater = -1;
VALUE reset = Qfalse;
int reset_flag = 0;
int rc;
status_op = FIX2INT( rb_iv_get( self, "@code" ) );
if ( argc > 0 ) {
reset = argv[0];
reset_flag = ( Qtrue == reset ) ? 1 : 0 ;
}
rc = sqlite3_status( status_op, ¤t, &highwater, reset_flag );
if ( SQLITE_OK != rc ) {
VALUE n = rb_iv_get( self, "@name" ) ;
char* name = StringValuePtr( n );
rb_raise(eAS_Error, "Failure to retrieve status for %s : [SQLITE_ERROR %d] \n", name, rc);
}
rb_iv_set( self, "@current", INT2NUM( current ) );
rb_iv_set( self, "@highwater", INT2NUM( highwater) );
return Qnil;
}