avoid releasing the connection multiple times

when the ResultSet is released, the connection is returned. The same happens with the statement.
This commit is contained in:
Brian J. Cardiff 2016-08-29 16:41:29 -03:00
parent c3fce779fe
commit 6b72e01c2f

View file

@ -13,9 +13,14 @@ class SQLite3::Statement < DB::Statement
end end
protected def perform_exec(args : Enumerable) : DB::ExecResult protected def perform_exec(args : Enumerable) : DB::ExecResult
rs = perform_query(args) LibSQLite3.reset(self.to_unsafe)
rs.move_next args.each_with_index(1) do |arg, index|
rs.close bind_arg(index, arg)
end
# exec
step = LibSQLite3::Code.new LibSQLite3.step(self)
raise Exception.new(sqlite3_connection) unless step == LibSQLite3::Code::DONE
rows_affected = LibSQLite3.changes(sqlite3_connection).to_i64 rows_affected = LibSQLite3.changes(sqlite3_connection).to_i64
last_id = LibSQLite3.last_insert_rowid(sqlite3_connection) last_id = LibSQLite3.last_insert_rowid(sqlite3_connection)