ext/adapter.cc in swift-0.6.1 vs ext/adapter.cc in swift-0.7.0
- old
+ new
@@ -1,11 +1,14 @@
#include "adapter.h"
static VALUE cSwiftAdapter;
static void adapter_free(dbi::Handle *handle) {
- if (handle) delete handle;
+ if (handle) {
+ handle->conn()->cleanup();
+ delete handle;
+ }
}
VALUE adapter_alloc(VALUE klass) {
dbi::Handle *handle = 0;
return Data_Wrap_Struct(klass, 0, adapter_free, handle);
@@ -81,19 +84,19 @@
try {
Query query;
query.sql = CSTRING(statement);
query.handle = handle;
- if (RARRAY_LEN(bind_values) > 0) query_bind_values(&query, bind_values);
+ if (RARRAY_LEN(bind_values) > 0) query_bind_values(&query, bind_values, handle->driver());
if (dbi::_trace) dbi::logMessage(dbi::_trace_fd, dbi::formatParams(query.sql, query.bind));
if ((rows = rb_thread_blocking_region(((VALUE (*)(void*))query_execute), &query, RUBY_UBF_IO, 0)) == Qfalse)
rb_raise(eSwiftRuntimeError, "%s", query.error);
if (rb_block_given_p()) {
- dbi::AbstractResultSet *result = handle->results();
- return result_each(Data_Wrap_Struct(cSwiftResult, 0, result_free, result));
+ dbi::AbstractResult *result = handle->results();
+ return result_each(result_wrap_handle(cSwiftResult, self, result, false));
}
else
return rows;
}
CATCH_DBI_EXCEPTIONS();
@@ -119,11 +122,12 @@
CSTRING(rb_hash_aref(options, ID2SYM(rb_intern("port"))))
);
}
CATCH_DBI_EXCEPTIONS();
- rb_iv_set(self, "@options", options);
+ rb_iv_set(self, "@timezone", rb_hash_aref(options, ID2SYM(rb_intern("timezone"))));
+ rb_iv_set(self, "@options", options);
return Qnil;
}
static VALUE adapter_prepare(int argc, VALUE *argv, VALUE self) {
VALUE sql, scheme, prepared;
@@ -137,11 +141,11 @@
dbi::Handle *handle = adapter_handle(self);
try {
// TODO: Move to statement_* constructor.
statement = handle->conn()->prepare(CSTRING(sql));
- prepared = Data_Wrap_Struct(cSwiftStatement, 0, statement_free, statement);
+ prepared = statement_wrap_handle(cSwiftStatement, self, statement);
rb_iv_set(prepared, "@scheme", scheme);
return prepared;
}
CATCH_DBI_EXCEPTIONS();
}
@@ -224,11 +228,11 @@
}
VALUE adapter_results(VALUE self) {
dbi::Handle *handle = adapter_handle(self);
try {
- dbi::AbstractResultSet *result = handle->results();
- return Data_Wrap_Struct(cSwiftResult, 0, result_free, result);
+ dbi::AbstractResult *result = handle->results();
+ return result_wrap_handle(cSwiftResult, self, result, false);
}
CATCH_DBI_EXCEPTIONS();
}
void init_swift_adapter() {