Methods
- api_delegate
- bind_text
- busy_handler
- column_decltype
- column_name
- column_text
- complete?
- create_function
- errmsg
- new
- open
- prepare
- result_error
- result_text
- set_authorizer
- trace
- value_text
Public Class methods
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 161 161: def self.api_delegate( name ) 162: eval "def #{name} (*args) API.sqlite3_#{name}( *args ) ; end" 163: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 7 7: def initialize 8: @callback_data = Hash.new 9: @authorizer = Hash.new 10: @busy_handler = Hash.new 11: @trace = Hash.new 12: end
Public Instance methods
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 80 80: def bind_text( stmt, index, value, utf16=false ) 81: API.send( ( utf16 ? :sqlite3_bind_text16 : :sqlite3_bind_text ), 82: stmt, index, value.to_s ) 83: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 18 18: def busy_handler( db, data=nil, &block ) 19: if block 20: cb = API::CallbackData.new 21: cb.proc = block 22: cb.data = data 23: result = API.sqlite3_busy_handler( db, API::Sqlite3_ruby_busy_handler, cb ) 24: # Reference the Callback object so that 25: # it is not deleted by the GC 26: @busy_handler[db] = cb 27: else 28: # Unreference the callback *after* having removed it 29: # from sqlite 30: result = API.sqlite3_busy_handler( db, nil, nil ) 31: @busy_handler.delete(db) 32: end 33: 34: result 35: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 90 90: def column_decltype( stmt, index, utf16=false ) 91: API.send( 92: ( utf16 ? :sqlite3_column_decltype16 : :sqlite3_column_decltype ), 93: stmt, index ) 94: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 85 85: def column_name( stmt, index, utf16=false ) 86: API.send( ( utf16 ? :sqlite3_column_name16 : :sqlite3_column_name ), 87: stmt, index ) 88: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 96 96: def column_text( stmt, index, utf16=false ) 97: API.send( ( utf16 ? :sqlite3_column_text16 : :sqlite3_column_text ), 98: stmt, index ) 99: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 14 14: def complete?( sql, utf16=false ) 15: API.send( utf16 ? :sqlite3_complete16 : :sqlite3_complete, sql ) != 0 16: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 101 101: def create_function( db, name, args, text, cookie, func, step, final ) 102: if func || ( step && final ) 103: cb = API::CallbackData.new 104: cb.proc = cb.proc2 = nil 105: cb.data = cookie 106: end 107: 108: if func 109: cb.proc = func 110: 111: func = API::Sqlite3_ruby_function_step 112: step = final = nil 113: elsif step && final 114: cb.proc = step 115: cb.proc2 = final 116: 117: func = nil 118: step = API::Sqlite3_ruby_function_step 119: final = API::Sqlite3_ruby_function_final 120: end 121: 122: result = API.sqlite3_create_function( db, name, args, text, cb, func, step, final ) 123: 124: # see comments in busy_handler 125: if cb 126: @callback_data[ name ] = cb 127: else 128: @callback_data.delete( name ) 129: end 130: 131: return result 132: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 71 71: def errmsg( db, utf16=false ) 72: API.send( utf16 ? :sqlite3_errmsg16 : :sqlite3_errmsg, db ) 73: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 67 67: def open( filename, utf16=false ) 68: API.send( utf16 ? :sqlite3_open16 : :sqlite3_open, filename ) 69: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 75 75: def prepare( db, sql, utf16=false ) 76: API.send( ( utf16 ? :sqlite3_prepare16 : :sqlite3_prepare ), 77: db, sql ) 78: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 156 156: def result_error( context, value, utf16=false ) 157: API.send( ( utf16 ? :sqlite3_result_error16 : :sqlite3_result_error ), 158: context, value ) 159: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 145 145: def result_text( context, result, utf16=false ) 146: method = case utf16 147: when nil, false then :sqlite3_result_text 148: when :le then :sqlite3_result_text16le 149: when :be then :sqlite3_result_text16be 150: else :sqlite3_result_text16 151: end 152: 153: API.send( method, context, result.to_s ) 154: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 37 37: def set_authorizer( db, data=nil, &block ) 38: if block 39: cb = API::CallbackData.new 40: cb.proc = block 41: cb.data = data 42: result = API.sqlite3_set_authorizer( db, API::Sqlite3_ruby_authorizer, cb ) 43: @authorizer[db] = cb # see comments in busy_handler 44: else 45: result = API.sqlite3_set_authorizer( db, nil, nil ) 46: @authorizer.delete(db) # see comments in busy_handler 47: end 48: 49: result 50: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 52 52: def trace( db, data=nil, &block ) 53: if block 54: cb = API::CallbackData.new 55: cb.proc = block 56: cb.data = data 57: result = API.sqlite3_trace( db, API::Sqlite3_ruby_trace, cb ) 58: @trace[db] = cb # see comments in busy_handler 59: else 60: result = API.sqlite3_trace( db, nil, nil ) 61: @trace.delete(db) # see comments in busy_handler 62: end 63: 64: result 65: end
[ show source ]
# File lib/sqlite3/driver/native/driver.rb, line 134 134: def value_text( value, utf16=false ) 135: method = case utf16 136: when nil, false then :sqlite3_value_text 137: when :le then :sqlite3_value_text16le 138: when :be then :sqlite3_value_text16be 139: else :sqlite3_value_text16 140: end 141: 142: API.send( method, value ) 143: end