Skip to content

Commit

Permalink
Fix invalid optimization. This probably breaks specs, I don't have an…
Browse files Browse the repository at this point in the history
… oracle dev environment to test.
  • Loading branch information
xaviershay committed May 5, 2010
1 parent c3fb421 commit b7b2a44
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions do_oracle/ext/do_oracle/do_oracle.c
Expand Up @@ -212,7 +212,7 @@ static VALUE parse_date(VALUE r_value) {
} else if (rb_obj_class(r_value) == rb_cDateTime) {
rational = rb_iv_get(r_value, "@ajd");
return rb_funcall(rb_cDate, ID_NEW_DATE, 3, rational, INT2NUM(0), INT2NUM(2299161));

} else {
// Something went terribly wrong
rb_raise(eDataError, "Couldn't parse date from class %s object", rb_obj_classname(r_value));
Expand Down Expand Up @@ -299,7 +299,7 @@ static VALUE parse_time(VALUE r_value) {
} else {
// Something went terribly wrong
rb_raise(eDataError, "Couldn't parse time from class %s object", rb_obj_classname(r_value));
}
}
}

static VALUE parse_boolean(VALUE r_value) {
Expand All @@ -318,16 +318,16 @@ static VALUE parse_boolean(VALUE r_value) {

static VALUE infer_ruby_type(VALUE type, VALUE precision, VALUE scale) {
ID type_id = SYM2ID(type);

if (type_id == ID_NUMBER)
return scale != Qnil && NUM2INT(scale) == 0 ?
(NUM2INT(precision) == 1 ? rb_cTrueClass : rb_cInteger) : rb_cBigDecimal;
else if (type_id == ID_VARCHAR2 || type_id == ID_CHAR || type_id == ID_CLOB || type_id == ID_LONG)
return rb_cString;
else if (type_id == ID_DATE)
// return rb_cDateTime;
// by default map DATE type to Time class as it is much faster than DateTime class
return rb_cTime;
// used to map DATE type to Time class as it is much faster than DateTime class, but
// that's incorrect behaviour and exploded when inferring types (repository.adapter.select)
return rb_cDateTime;
else if (type_id == ID_TIMESTAMP || type_id == ID_TIMESTAMP_TZ || type_id == ID_TIMESTAMP_LTZ)
// return rb_cDateTime;
// by default map TIMESTAMP type to Time class as it is much faster than DateTime class
Expand All @@ -342,7 +342,7 @@ static VALUE infer_ruby_type(VALUE type, VALUE precision, VALUE scale) {

static VALUE typecast(VALUE r_value, const VALUE type) {
VALUE r_data;

if (type == rb_cInteger) {
return TYPE(r_value) == T_FIXNUM || TYPE(r_value) == T_BIGNUM ? r_value : rb_funcall(r_value, ID_TO_I, 0);

Expand Down Expand Up @@ -496,7 +496,7 @@ static VALUE cCommand_execute_internal(VALUE self, VALUE oci8_conn, VALUE sql, V
arg.cursor = rb_funcall(oci8_conn, ID_PARSE, 1, sql);
arg.statement_type = rb_funcall(arg.cursor, ID_TYPE, 0);
arg.args = args;

return rb_ensure(cCommand_execute_try, (VALUE)&arg, cCommand_execute_ensure, (VALUE)&arg);
}

Expand All @@ -508,7 +508,7 @@ static VALUE execute_sql(VALUE oci8_conn, VALUE sql) {
static VALUE cCommand_execute_try(cCommand_execute_try_t *arg) {
VALUE result = Qnil;
int insert_id_present;

// no arguments given
if NIL_P(arg->args) {
result = rb_funcall(arg->cursor, ID_EXEC, 0);
Expand Down Expand Up @@ -558,7 +558,7 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
char *non_blocking = NULL;
char *time_zone = NULL;
char set_time_zone_command[80];

char *host = "localhost", *port = "1521", *path = NULL;
char *connect_string;
int connect_string_length;
Expand All @@ -571,13 +571,13 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
if ( Qnil != r_host && RSTRING_LEN(r_host) > 0) {
host = StringValuePtr(r_host);
}

r_port = rb_funcall(uri, rb_intern("port"), 0);
if ( Qnil != r_port ) {
r_port = rb_funcall(r_port, ID_TO_S, 0);
port = StringValuePtr(r_port);
}

r_path = rb_funcall(uri, rb_intern("path"), 0);
path = StringValuePtr(r_path);

Expand Down Expand Up @@ -623,7 +623,7 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
snprintf(set_time_zone_command, 80, "alter session set time_zone = '%s'", time_zone);
execute_sql(oci8_conn, RUBY_STRING(set_time_zone_command));
}

execute_sql(oci8_conn, RUBY_STRING("alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'"));
execute_sql(oci8_conn, RUBY_STRING("alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'"));
execute_sql(oci8_conn, RUBY_STRING("alter session set nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'"));
Expand All @@ -648,7 +648,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
VALUE reader, query;
VALUE field_names, field_types;
VALUE column_metadata, column, column_name;

int i;
int field_count;
int infer_types = 0;
Expand All @@ -659,7 +659,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
rb_raise(eArgumentError, "\"%s\" is invalid SELECT query", StringValuePtr(query));
}

column_metadata = rb_funcall(cursor, ID_COLUMN_METADATA, 0);
column_metadata = rb_funcall(cursor, ID_COLUMN_METADATA, 0);
field_count = RARRAY_LEN(column_metadata);
// reduce field_count by 1 if RAW_RNUM_ is present as last column
// (generated by DataMapper to simulate LIMIT and OFFSET)
Expand Down Expand Up @@ -733,7 +733,7 @@ static VALUE cReader_next(VALUE self) {
VALUE value;

VALUE fetch_result = rb_funcall(cursor, ID_FETCH, 0);

if (Qnil == fetch_result) {
rb_iv_set(self, "@values", Qnil);
rb_iv_set(self, "@last_row", Qtrue);
Expand Down Expand Up @@ -825,27 +825,27 @@ void Init_do_oracle() {
ID_TO_I = rb_intern("to_i");
ID_TO_S = rb_intern("to_s");
ID_TO_F = rb_intern("to_f");

ID_UTC_OFFSET = rb_intern("utc_offset");
ID_FULL_CONST_GET = rb_intern("full_const_get");

ID_PARSE = rb_intern("parse");
ID_FETCH = rb_intern("fetch");
ID_TYPE = rb_intern("type");
ID_EXECUTE = rb_intern("execute");
ID_EXEC = rb_intern("exec");

ID_SELECT_STMT = rb_intern("select_stmt");
ID_COLUMN_METADATA = rb_intern("column_metadata");
ID_PRECISION = rb_intern("precision");
ID_SCALE = rb_intern("scale");
ID_BIND_PARAM = rb_intern("bind_param");
ID_ELEM = rb_intern("[]");
ID_READ = rb_intern("read");

ID_CLOSE = rb_intern("close");
ID_LOGOFF = rb_intern("logoff");

// Get references to the Extlib module
mExtlib = CONST_GET(rb_mKernel, "Extlib");
rb_cByteArray = CONST_GET(mExtlib, "ByteArray");
Expand Down

0 comments on commit b7b2a44

Please sign in to comment.