From nobody at rubyforge.org Thu Jan 3 10:10:51 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Thu, 3 Jan 2008 10:10:51 -0500 (EST) Subject: [ruby-oci8-commit] [234] trunk/ruby-oci8: * ext/oci8/error.c: fix a SEGV bug when an error is raised in GC. Message-ID: <20080103151051.76BF518585C8@rubyforge.org> Revision: 234 Author: kubo Date: 2008-01-03 10:10:51 -0500 (Thu, 03 Jan 2008) Log Message: ----------- * ext/oci8/error.c: fix a SEGV bug when an error is raised in GC. make a custom backtrace entry only when 'caller' returns an Array. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/error.c Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2007-12-29 13:38:23 UTC (rev 233) +++ trunk/ruby-oci8/ChangeLog 2008-01-03 15:10:51 UTC (rev 234) @@ -1,3 +1,7 @@ +2008-01-03 KUBO Takehiro + * ext/oci8/error.c: fix a SEGV bug when an error is raised in GC. + make a custom backtrace entry only when 'caller' returns an Array. + 2007-12-29 KUBO Takehiro * lib/oci8/metadata.rb, lib/oci8/oci8.rb: support cursors in a result set. For example: Modified: trunk/ruby-oci8/ext/oci8/error.c =================================================================== --- trunk/ruby-oci8/ext/oci8/error.c 2007-12-29 13:38:23 UTC (rev 233) +++ trunk/ruby-oci8/ext/oci8/error.c 2008-01-03 15:10:51 UTC (rev 234) @@ -156,10 +156,12 @@ file = p + 1; #endif backtrace = rb_funcall(rb_cObject, oci8_id_caller, 0); - snprintf(errmsg, sizeof(errmsg), "%s:%d:in oci8lib.so", file, line); - errmsg[sizeof(errmsg) - 1] = '\0'; - rb_ary_unshift(backtrace, rb_str_new2(errmsg)); - rb_funcall(exc, oci8_id_set_backtrace, 1, backtrace); + if (TYPE(backtrace) == T_ARRAY) { + snprintf(errmsg, sizeof(errmsg), "%s:%d:in oci8lib.so", file, line); + errmsg[sizeof(errmsg) - 1] = '\0'; + rb_ary_unshift(backtrace, rb_str_new2(errmsg)); + rb_funcall(exc, oci8_id_set_backtrace, 1, backtrace); + } rb_exc_raise(exc); } From nobody at rubyforge.org Fri Jan 4 05:52:44 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 4 Jan 2008 05:52:44 -0500 (EST) Subject: [ruby-oci8-commit] [235] branches/ruby-oci8-1.0: * ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result Message-ID: <20080104105244.D6ED118585DD@rubyforge.org> Revision: 235 Author: kubo Date: 2008-01-04 05:52:44 -0500 (Fri, 04 Jan 2008) Log Message: ----------- * ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result set without re-defining the define handle. * test/test_oci8.rb: delete re-defining in a test case for cursors in a result set. Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/ext/oci8/define.c branches/ruby-oci8-1.0/lib/oci8.rb.in branches/ruby-oci8-1.0/test/test_oci8.rb Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-01-03 15:10:51 UTC (rev 234) +++ branches/ruby-oci8-1.0/ChangeLog 2008-01-04 10:52:44 UTC (rev 235) @@ -1,3 +1,9 @@ +2008-01-04 KUBO Takehiro + * ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result + set without re-defining the define handle. + * test/test_oci8.rb: delete re-defining in a test case for cursors + in a result set. + 2007-12-29 KUBO Takehiro * lib/oci8.rb.in: support cursors in a result set. For example: SELECT column1 A, column2 B, CURSOR(SELECT * FROM table2) C Modified: branches/ruby-oci8-1.0/ext/oci8/define.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/define.c 2008-01-03 15:10:51 UTC (rev 234) +++ branches/ruby-oci8-1.0/ext/oci8/define.c 2008-01-04 10:52:44 UTC (rev 235) @@ -37,7 +37,17 @@ return obj; } +static VALUE oci8_set_data(VALUE self, VALUE val) +{ + oci8_bind_handle_t *hp; + + Data_Get_Struct(self, oci8_bind_handle_t, hp); + oci8_set_value(hp, val); + return self; +} + void Init_oci8_define(void) { rb_define_method(cOCIDefine, "get", oci8_get_data, 0); + rb_define_method(cOCIDefine, "set", oci8_set_data, 1); } Modified: branches/ruby-oci8-1.0/lib/oci8.rb.in =================================================================== --- branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-01-03 15:10:51 UTC (rev 234) +++ branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-01-04 10:52:44 UTC (rev 235) @@ -643,12 +643,12 @@ [OCI8::SQLT_RSET, nil, val] end def decorate(b) - def b.set(val) - raise NotImplementedError - end def b.get() (val = super()) && OCI8::Cursor.new(@env, @svc, @ctx, val) end + def b.pre_fetch_hook() + set(@env.alloc(OCIStmt)) + end end end @@ -918,6 +918,9 @@ end # bind_params def fetch_a_row + @defns.each do |d| + d.pre_fetch_hook if d.respond_to? :pre_fetch_hook + end res = do_ocicall(@ctx) { @stmt.fetch() } return nil if res.nil? res.collect do |r| r.get() end Modified: branches/ruby-oci8-1.0/test/test_oci8.rb =================================================================== --- branches/ruby-oci8-1.0/test/test_oci8.rb 2008-01-03 15:10:51 UTC (rev 234) +++ branches/ruby-oci8-1.0/test/test_oci8.rb 2008-01-04 10:52:44 UTC (rev 235) @@ -192,7 +192,6 @@ end assert_nil(cursor_in_result_set.fetch) # check end of row data cursor_in_result_set.close - cursor.define(2, OCI8::Cursor) # bad hack. fix later. end assert_nil(cursor.fetch) # check end of row data drop_table('test_table') From nobody at rubyforge.org Fri Jan 4 07:53:00 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 4 Jan 2008 07:53:00 -0500 (EST) Subject: [ruby-oci8-commit] [236] trunk/ruby-oci8: * ext/oci8/oci8.h, ext/oci8/stmt.c: 1. Message-ID: <20080104125300.6C68418585D7@rubyforge.org> Revision: 236 Author: kubo Date: 2008-01-04 07:52:59 -0500 (Fri, 04 Jan 2008) Log Message: ----------- * ext/oci8/oci8.h, ext/oci8/stmt.c: 1. add a 'pre_fetch_hook' callback function to oci8_bind_class_t. This function is called before OCIStmtFetch in OCI8::Cursor#fetch. 2. allocate OCIStmt handle by pre_fetch_hook when a result set has cursors. 3. change 'init' callback function's prototype in oci8_bind_class_t. * ext/oci8/bind.c, ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/ocidatetime.c, ext/oci8/ocinumber.c, ext/oci8/oradate.c, ext/oci8/rowid.c: changes causes by above 1 and 3. * test/test_oci8.rb: delete re-defining in a test case for cursors in a result set. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/bind.c trunk/ruby-oci8/ext/oci8/lob.c trunk/ruby-oci8/ext/oci8/object.c trunk/ruby-oci8/ext/oci8/oci8.h trunk/ruby-oci8/ext/oci8/ocidatetime.c trunk/ruby-oci8/ext/oci8/ocinumber.c trunk/ruby-oci8/ext/oci8/oradate.c trunk/ruby-oci8/ext/oci8/rowid.c trunk/ruby-oci8/ext/oci8/stmt.c trunk/ruby-oci8/test/test_oci8.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ChangeLog 2008-01-04 12:52:59 UTC (rev 236) @@ -1,3 +1,18 @@ +2008-01-04 KUBO Takehiro + * ext/oci8/oci8.h, ext/oci8/stmt.c: 1. add a 'pre_fetch_hook' + callback function to oci8_bind_class_t. This function is + called before OCIStmtFetch in OCI8::Cursor#fetch. + 2. allocate OCIStmt handle by pre_fetch_hook when a result set + has cursors. + 3. change 'init' callback function's prototype in + oci8_bind_class_t. + * ext/oci8/bind.c, ext/oci8/lob.c, ext/oci8/object.c, + ext/oci8/ocidatetime.c, ext/oci8/ocinumber.c, + ext/oci8/oradate.c, ext/oci8/rowid.c: changes causes by above 1 + and 3. + * test/test_oci8.rb: delete re-defining in a test case for cursors + in a result set. + 2008-01-03 KUBO Takehiro * ext/oci8/error.c: fix a SEGV bug when an error is raised in GC. make a custom backtrace entry only when 'caller' returns an Array. Modified: trunk/ruby-oci8/ext/oci8/bind.c =================================================================== --- trunk/ruby-oci8/ext/oci8/bind.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/bind.c 2008-01-04 12:52:59 UTC (rev 236) @@ -35,15 +35,15 @@ vstr->size = RSTRING_LEN(val); } -static void bind_string_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_string_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { sb4 sz; if (NIL_P(length)) { - if (NIL_P(*val)) { + if (NIL_P(val)) { rb_raise(rb_eArgError, "value and length are both null."); } - StringValue(*val); - sz = RSTRING_LEN(*val); + StringValue(val); + sz = RSTRING_LEN(val); } else { sz = NUM2INT(length); } @@ -67,6 +67,7 @@ NULL, NULL, NULL, + NULL, SQLT_LVC }; @@ -85,6 +86,7 @@ NULL, NULL, NULL, + NULL, SQLT_LVB }; @@ -123,7 +125,7 @@ bl->obj = rb_str_dup(val); } -static void bind_long_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_long_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { sb4 sz = 0; @@ -198,6 +200,7 @@ bind_long_init_elem, bind_long_in, bind_long_out, + NULL, SQLT_CHR }; @@ -216,6 +219,7 @@ bind_long_init_elem, bind_long_in, bind_long_out, + NULL, SQLT_BIN }; @@ -233,7 +237,7 @@ *(long*)data = FIX2LONG(val); } -static void bind_fixnum_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_fixnum_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(long); obind->alloc_sz = sizeof(long); @@ -251,6 +255,7 @@ NULL, NULL, NULL, + NULL, SQLT_INT }; @@ -268,7 +273,7 @@ *(double*)data = RFLOAT_VALUE(val); } -static void bind_float_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_float_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(double); obind->alloc_sz = sizeof(double); @@ -286,6 +291,7 @@ NULL, NULL, NULL, + NULL, SQLT_FLT }; @@ -302,6 +308,7 @@ NULL, NULL, NULL, + NULL, SQLT_BDOUBLE }; #endif @@ -396,7 +403,7 @@ obind->curar_sz = 0; if (obind->maxar_sz > 0) cnt = obind->maxar_sz; - bind_class->init(obind, svc, &val, length); + bind_class->init(obind, svc, val, length); if (obind->alloc_sz > 0) { obind->valuep = xmalloc(obind->alloc_sz * cnt); memset(obind->valuep, 0, obind->alloc_sz * cnt); Modified: trunk/ruby-oci8/ext/oci8/lob.c =================================================================== --- trunk/ruby-oci8/ext/oci8/lob.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/lob.c 2008-01-04 12:52:59 UTC (rev 236) @@ -576,7 +576,7 @@ oho->obj = val; } -static void bind_lob_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_lob_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(void *); obind->alloc_sz = sizeof(oci8_hp_obj_t); @@ -609,6 +609,7 @@ bind_lob_init_elem, NULL, NULL, + NULL, SQLT_CLOB }, &cOCI8CLOB @@ -627,6 +628,7 @@ bind_lob_init_elem, NULL, NULL, + NULL, SQLT_CLOB, SQLCS_NCHAR, }, @@ -646,6 +648,7 @@ bind_lob_init_elem, NULL, NULL, + NULL, SQLT_BLOB }, &cOCI8BLOB @@ -664,6 +667,7 @@ bind_lob_init_elem, NULL, NULL, + NULL, SQLT_BFILE }, &cOCI8BFILE Modified: trunk/ruby-oci8/ext/oci8/object.c =================================================================== --- trunk/ruby-oci8/ext/oci8/object.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/object.c 2008-01-04 12:52:59 UTC (rev 236) @@ -509,7 +509,7 @@ rb_raise(rb_eRuntimeError, "not supported"); } -static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { VALUE tdo_obj = length; @@ -564,6 +564,7 @@ bind_named_type_init_elem, NULL, NULL, + NULL, SQLT_NTY }; Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2008-01-04 12:52:59 UTC (rev 236) @@ -124,10 +124,11 @@ oci8_base_class_t base; VALUE (*get)(oci8_bind_t *obind, void *data, void *null_struct); void (*set)(oci8_bind_t *obind, void *data, void **null_structp, VALUE val); - void (*init)(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length); + void (*init)(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length); void (*init_elem)(oci8_bind_t *obind, VALUE svc); ub1 (*in)(oci8_bind_t *obind, ub4 idx, ub1 piece, void **valuepp, ub4 **alenpp, void **indpp); void (*out)(oci8_bind_t *obind, ub4 idx, ub1 piece, void **valuepp, ub4 **alenpp, void **indpp); + void (*pre_fetch_hook)(oci8_bind_t *obind, VALUE svc); ub2 dty; ub1 csfrm; }; Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocidatetime.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/ocidatetime.c 2008-01-04 12:52:59 UTC (rev 236) @@ -392,7 +392,7 @@ strlen(tz_str))); } -static void bind_datetime_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_datetime_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind; @@ -481,7 +481,7 @@ *intvlpp)); } -static void bind_interval_ym_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_interval_ym_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind; @@ -625,7 +625,7 @@ day, hour, minute, sec, fsec, *intvlpp)); } -static void bind_interval_ds_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_interval_ds_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind; @@ -658,6 +658,7 @@ bind_datetime_init_elem, NULL, NULL, + NULL, SQLT_TIMESTAMP_TZ }; @@ -673,6 +674,7 @@ bind_interval_ym_init_elem, NULL, NULL, + NULL, SQLT_INTERVAL_YM }; @@ -688,6 +690,7 @@ bind_interval_ds_init_elem, NULL, NULL, + NULL, SQLT_INTERVAL_DS }; Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-01-04 12:52:59 UTC (rev 236) @@ -1033,7 +1033,7 @@ oci_lc(OCINumberTrunc(oci8_errhp, &num, 0, (OCINumber*)data)); } -static void bind_ocinumber_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_ocinumber_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(OCINumber); obind->alloc_sz = sizeof(OCINumber); @@ -1060,6 +1060,7 @@ bind_ocinumber_init_elem, NULL, NULL, + NULL, SQLT_VNU, }; @@ -1075,6 +1076,7 @@ bind_ocinumber_init_elem, NULL, NULL, + NULL, SQLT_VNU, }; Modified: trunk/ruby-oci8/ext/oci8/oradate.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oradate.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/oradate.c 2008-01-04 12:52:59 UTC (rev 236) @@ -384,7 +384,7 @@ memcpy(data, od, sizeof(ora_date_t)); } -static void bind_oradate_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_oradate_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(ora_date_t); obind->alloc_sz = sizeof(ora_date_t); @@ -411,6 +411,7 @@ bind_oradate_init_elem, NULL, NULL, + NULL, SQLT_DAT, }; Modified: trunk/ruby-oci8/ext/oci8/rowid.c =================================================================== --- trunk/ruby-oci8/ext/oci8/rowid.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/rowid.c 2008-01-04 12:52:59 UTC (rev 236) @@ -97,7 +97,7 @@ vstr->size = strlen(rowid->id); } -static void bind_rowid1_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_rowid1_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = BIND_ROWID1_SIZE; obind->alloc_sz = BIND_ROWID1_SIZE; @@ -115,6 +115,7 @@ NULL, NULL, NULL, + NULL, SQLT_LVC }; @@ -260,7 +261,7 @@ oho->obj = val; } -static void bind_rowid2_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_rowid2_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(void *); obind->alloc_sz = sizeof(oci8_hp_obj_t); Modified: trunk/ruby-oci8/ext/oci8/stmt.c =================================================================== --- trunk/ruby-oci8/ext/oci8/stmt.c 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/ext/oci8/stmt.c 2008-01-04 12:52:59 UTC (rev 236) @@ -21,6 +21,7 @@ static ID id_at_column_metadata; static ID id_at_names; static ID id_at_con; +static ID id_set; VALUE cOCIStmt; @@ -333,6 +334,16 @@ oci8_bind_t *obind; oci8_bind_class_t *bind_class; + obind = (oci8_bind_t *)stmt->base.children; + do { + if (obind->base.type == OCI_HTYPE_DEFINE) { + bind_class = (oci8_bind_class_t *)obind->base.klass; + if (bind_class->pre_fetch_hook != NULL) { + bind_class->pre_fetch_hook(obind, stmt->svc); + } + } + obind = (oci8_bind_t *)obind->base.next; + } while (obind != (oci8_bind_t*)stmt->base.children); rv = OCIStmtFetch_nb(svcctx, stmt->base.hp.stmt, oci8_errhp, 1, OCI_FETCH_NEXT, OCI_DEFAULT); while (rv == OCI_NEED_DATA) { /* get piece info. */ @@ -647,13 +658,10 @@ oho->obj = val; } -static void bind_stmt_init(oci8_bind_t *obind, VALUE svc, VALUE *val, VALUE length) +static void bind_stmt_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length) { obind->value_sz = sizeof(void *); obind->alloc_sz = sizeof(oci8_hp_obj_t); - if (NIL_P(*val)) { - *val = rb_funcall(cOCIStmt, oci8_id_new, 1, svc); - } } static void bind_stmt_init_elem(oci8_bind_t *obind, VALUE svc) @@ -681,6 +689,7 @@ bind_stmt_init_elem, NULL, NULL, + bind_stmt_init_elem, SQLT_RSET }; @@ -701,6 +710,7 @@ id_at_column_metadata = rb_intern("@column_metadata"); id_at_names = rb_intern("@names"); id_at_con = rb_intern("@con"); + id_set = rb_intern("set"); rb_define_private_method(cOCIStmt, "initialize", oci8_stmt_initialize, -1); rb_define_private_method(cOCIStmt, "__define", oci8_define_by_pos, 2); Modified: trunk/ruby-oci8/test/test_oci8.rb =================================================================== --- trunk/ruby-oci8/test/test_oci8.rb 2008-01-04 10:52:44 UTC (rev 235) +++ trunk/ruby-oci8/test/test_oci8.rb 2008-01-04 12:52:59 UTC (rev 236) @@ -153,7 +153,7 @@ end cursor.close plsql = @conn.parse("BEGIN OPEN :cursor FOR SELECT * FROM test_table ORDER BY c; END;") - plsql.bind_param(':cursor', OCI8::Cursor) + plsql.bind_param(':cursor', nil, OCI8::Cursor) plsql.exec cursor = plsql[':cursor'] cursor.define(5, Time) # define 5th column as Time @@ -220,7 +220,6 @@ end assert_nil(cursor_in_result_set.fetch) # check end of row data cursor_in_result_set.close - cursor.define(2, OCI8::Cursor) # bad hack. fix later. end assert_nil(cursor.fetch) # check end of row data drop_table('test_table') From nobody at rubyforge.org Tue Jan 8 09:33:02 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 8 Jan 2008 09:33:02 -0500 (EST) Subject: [ruby-oci8-commit] [237] trunk/ruby-oci8: * test/config.rb, test/test_bind_raw.rb, test/ test_bind_time.rb, Message-ID: <20080108143302.AC09D18585C7@rubyforge.org> Revision: 237 Author: kubo Date: 2008-01-08 09:33:01 -0500 (Tue, 08 Jan 2008) Log Message: ----------- * test/config.rb, test/test_bind_raw.rb, test/test_bind_time.rb, test/test_break.rb, test/test_clob.rb, test/test_datetime.rb, test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb, test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb, test_oranumber.rb: use one OCI8 session for all OCI8 test cases and use one DBI session for all DBI test cases. Before this changes, connection/disconnection were called for each tests. If they are done too frequently and the Oracle server is on a remote server, the following error is raised. OCIError: ORA-12516: TNS:listener could not find available handler with matching protocol stack Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/test/config.rb trunk/ruby-oci8/test/test_bind_raw.rb trunk/ruby-oci8/test/test_bind_time.rb trunk/ruby-oci8/test/test_break.rb trunk/ruby-oci8/test/test_clob.rb trunk/ruby-oci8/test/test_datetime.rb trunk/ruby-oci8/test/test_dbi.rb trunk/ruby-oci8/test/test_dbi_clob.rb trunk/ruby-oci8/test/test_metadata.rb trunk/ruby-oci8/test/test_object.rb trunk/ruby-oci8/test/test_oci8.rb trunk/ruby-oci8/test/test_oradate.rb trunk/ruby-oci8/test/test_oranumber.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/ChangeLog 2008-01-08 14:33:01 UTC (rev 237) @@ -1,3 +1,16 @@ +2008-01-08 KUBO Takehiro + * test/config.rb, test/test_bind_raw.rb, test/test_bind_time.rb, + test/test_break.rb, test/test_clob.rb, test/test_datetime.rb, + test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb, + test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb, + test_oranumber.rb: use one OCI8 session for all OCI8 test cases + and use one DBI session for all DBI test cases. + Before this changes, connection/disconnection were called + for each tests. If they are done too frequently and the Oracle + server is on a remote server, the following error is raised. + OCIError: ORA-12516: TNS:listener could not find available + handler with matching protocol stack + 2008-01-04 KUBO Takehiro * ext/oci8/oci8.h, ext/oci8/stmt.c: 1. add a 'pre_fetch_hook' callback function to oci8_bind_class_t. This function is Modified: trunk/ruby-oci8/test/config.rb =================================================================== --- trunk/ruby-oci8/test/config.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/config.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -20,15 +20,22 @@ # don't modify below. +$dbconn = OCI8.new($dbuser, $dbpass, $dbname) +begin + require 'dbi' + $dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) +rescue LoadError +end + + # $oracle_server_version: database compatible level of the Oracle server. # $oracle_client_version: Oracle client library version for which oci8 is compiled. # $oracle_version: lower value of $oracle_server_version and $oracle_client_version. -conn = OCI8.new($dbuser, $dbpass, $dbname) -conn.exec('select value from database_compatible_level') do |row| +$dbconn.exec('select value from database_compatible_level') do |row| ver = row[0].split('.') $oracle_server_version = (ver[0] + ver[1] + ver[2]).to_i end -conn.logoff + $oracle_client_version = OCI8::CLIENT_VERSION.to_i if $oracle_server_version < $oracle_client_version $oracle_version = $oracle_server_version Modified: trunk/ruby-oci8/test/test_bind_raw.rb =================================================================== --- trunk/ruby-oci8/test/test_bind_raw.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_bind_raw.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -13,7 +13,7 @@ ] def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def test_set_raw @@ -41,6 +41,6 @@ end def teardown - @conn.logoff + @conn.rollback end end Modified: trunk/ruby-oci8/test/test_bind_time.rb =================================================================== --- trunk/ruby-oci8/test/test_bind_time.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_bind_time.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -12,7 +12,7 @@ SEC_CHECK_TARGET = [0, 15, 30, 45, 59] def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def test_set_year @@ -173,6 +173,6 @@ end def teardown - @conn.logoff + @conn.rollback end end Modified: trunk/ruby-oci8/test/test_break.rb =================================================================== --- trunk/ruby-oci8/test/test_break.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_break.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -5,6 +5,15 @@ class TestBreak < Test::Unit::TestCase + def setup + @conn = $dbconn + end + + def teardown + @conn.non_blocking = false + @conn.rollback + end + def report(str) printf "%d: %s\n", (Time.now - $start_time), str end @@ -37,21 +46,18 @@ end def test_blocking_mode - conn = OCI8.new($dbuser, $dbpass, $dbname) - conn.non_blocking = false - assert_equal(false, conn.non_blocking?) + @conn.non_blocking = false + assert_equal(false, @conn.non_blocking?) expect = [] expect[PLSQL_DONE] = TIME_IN_PLSQL expect[OCIBREAK] = "Invalid status" expect[SEND_BREAK] = TIME_IN_PLSQL + TIME_TO_BREAK - do_test_ocibreak(conn, expect) - conn.logoff() + do_test_ocibreak(@conn, expect) end def test_non_blocking_mode - conn = OCI8.new($dbuser, $dbpass, $dbname) - conn.non_blocking = true - assert_equal(true, conn.non_blocking?) + @conn.non_blocking = true + assert_equal(true, @conn.non_blocking?) expect = [] expect[PLSQL_DONE] = "Invalid status" if RUBY_PLATFORM =~ /mswin32|cygwin|mingw32|bccwin32/ @@ -62,7 +68,6 @@ expect[OCIBREAK] = TIME_TO_BREAK end expect[SEND_BREAK] = TIME_TO_BREAK - do_test_ocibreak(conn, expect) - conn.logoff() + do_test_ocibreak(@conn, expect) end end Modified: trunk/ruby-oci8/test/test_clob.rb =================================================================== --- trunk/ruby-oci8/test/test_clob.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_clob.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -6,7 +6,7 @@ class TestCLob < Test::Unit::TestCase def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def test_insert @@ -58,6 +58,6 @@ end def teardown - @conn.logoff + @conn.rollback end end Modified: trunk/ruby-oci8/test/test_datetime.rb =================================================================== --- trunk/ruby-oci8/test/test_datetime.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_datetime.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -13,12 +13,12 @@ end def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn @local_timezone = timezone_string(*((::Time.now.utc_offset / 60).divmod 60)) end def teardown - @conn.logoff + @conn.rollback end def test_date_select Modified: trunk/ruby-oci8/test/test_dbi.rb =================================================================== --- trunk/ruby-oci8/test/test_dbi.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_dbi.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -6,11 +6,11 @@ class TestDBI < Test::Unit::TestCase def setup - @dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) + @dbh = $dbh end def teardown - @dbh.disconnect + @dbh.rollback end def test_select Modified: trunk/ruby-oci8/test/test_dbi_clob.rb =================================================================== --- trunk/ruby-oci8/test/test_dbi_clob.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_dbi_clob.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -5,7 +5,7 @@ class TestDbiCLob < Test::Unit::TestCase def setup - @dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) + @dbh = $dbh end def test_insert @@ -45,6 +45,6 @@ end def teardown - @dbh.disconnect() + @dbh.rollback end end Modified: trunk/ruby-oci8/test/test_metadata.rb =================================================================== --- trunk/ruby-oci8/test/test_metadata.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_metadata.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -5,11 +5,11 @@ class TestMetadata < Test::Unit::TestCase def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def teardown - @conn.logoff + @conn.rollback end def test_metadata Modified: trunk/ruby-oci8/test/test_object.rb =================================================================== --- trunk/ruby-oci8/test/test_object.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_object.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -9,12 +9,12 @@ Delta = 0.00001 def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn RbTestObj.default_connection = @conn end def teardown - @conn.logoff + @conn.rollback end class ExpectedValObjElem Modified: trunk/ruby-oci8/test/test_oci8.rb =================================================================== --- trunk/ruby-oci8/test/test_oci8.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_oci8.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -5,11 +5,11 @@ class TestOCI8 < Test::Unit::TestCase def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def teardown - @conn.logoff + @conn.rollback end def test_rename Modified: trunk/ruby-oci8/test/test_oradate.rb =================================================================== --- trunk/ruby-oci8/test/test_oradate.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_oradate.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -13,7 +13,7 @@ SECOND_CHECK_TARGET = [0, 15, 30, 45, 59] def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def check_oradate(target, year, month, day, hour, minute, second) @@ -251,6 +251,6 @@ end def teardown - @conn.logoff + @conn.rollback end end Modified: trunk/ruby-oci8/test/test_oranumber.rb =================================================================== --- trunk/ruby-oci8/test/test_oranumber.rb 2008-01-04 12:52:59 UTC (rev 236) +++ trunk/ruby-oci8/test/test_oranumber.rb 2008-01-08 14:33:01 UTC (rev 237) @@ -53,7 +53,7 @@ ] def setup - @conn = OCI8.new($dbuser, $dbpass, $dbname) + @conn = $dbconn end def test_to_s @@ -137,6 +137,6 @@ end def teardown - @conn.logoff + @conn.rollback end end From nobody at rubyforge.org Sat Jan 12 01:51:43 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 12 Jan 2008 01:51:43 -0500 (EST) Subject: [ruby-oci8-commit] [238] branches/ruby-oci8-1.0: * ext/oci8/oradate.c, ext/oci8/oranumber.c: fix SEGV bugs. Message-ID: <20080112065143.C489218585D4@rubyforge.org> Revision: 238 Author: kubo Date: 2008-01-12 01:51:43 -0500 (Sat, 12 Jan 2008) Log Message: ----------- * ext/oci8/oradate.c, ext/oci8/oranumber.c: fix SEGV bugs. OraDate.new made a core dump on x86_64 linux. (This problem is reported by Alun Eyre.) Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/ext/oci8/oradate.c branches/ruby-oci8-1.0/ext/oci8/oranumber.c Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-01-08 14:33:01 UTC (rev 237) +++ branches/ruby-oci8-1.0/ChangeLog 2008-01-12 06:51:43 UTC (rev 238) @@ -1,3 +1,8 @@ +2008-01-12 KUBO Takehiro + * ext/oci8/oradate.c, ext/oci8/oranumber.c: fix SEGV bugs. + OraDate.new made a core dump on x86_64 linux. + (This problem is reported by Alun Eyre.) + 2008-01-04 KUBO Takehiro * ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result set without re-defining the define handle. Modified: branches/ruby-oci8-1.0/ext/oci8/oradate.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/oradate.c 2008-01-08 14:33:01 UTC (rev 237) +++ branches/ruby-oci8-1.0/ext/oci8/oradate.c 2008-01-12 06:51:43 UTC (rev 238) @@ -45,7 +45,7 @@ rb_raise(rb_eRangeError, "Out of range for second %d (expect 0 .. 59)", sec) -static VALUE ora_date_s_allocate(klass) +static VALUE ora_date_s_allocate(VALUE klass) { ora_date_t *od; return Data_Make_Struct(klass, ora_date_t, NULL, xfree, od); Modified: branches/ruby-oci8-1.0/ext/oci8/oranumber.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/oranumber.c 2008-01-08 14:33:01 UTC (rev 237) +++ branches/ruby-oci8-1.0/ext/oci8/oranumber.c 2008-01-12 06:51:43 UTC (rev 238) @@ -30,7 +30,7 @@ return ovn; } -static VALUE ora_number_s_allocate(klass) +static VALUE ora_number_s_allocate(VALUE klass) { ora_vnumber_t *ovn; return Data_Make_Struct(klass, ora_vnumber_t, NULL, xfree, ovn); From nobody at rubyforge.org Sat Jan 12 02:12:45 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 12 Jan 2008 02:12:45 -0500 (EST) Subject: [ruby-oci8-commit] [239] branches/ruby-oci8-1.0: * lib/oci8.rb.in: fix OCI8#non_blocking = false problem. Message-ID: <20080112071245.7A4F418585DA@rubyforge.org> Revision: 239 Author: kubo Date: 2008-01-12 02:12:45 -0500 (Sat, 12 Jan 2008) Log Message: ----------- * lib/oci8.rb.in: fix OCI8#non_blocking = false problem. Once the connection became non-bocking mode, it could not be reset to blocking mode. (This problem is reported by Cagdas Gerede.) * test/test_break.rb: add a testcase to test the above problem. Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/lib/oci8.rb.in branches/ruby-oci8-1.0/test/test_break.rb Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-01-12 06:51:43 UTC (rev 238) +++ branches/ruby-oci8-1.0/ChangeLog 2008-01-12 07:12:45 UTC (rev 239) @@ -1,4 +1,11 @@ 2008-01-12 KUBO Takehiro + * lib/oci8.rb.in: fix OCI8#non_blocking = false problem. + Once the connection became non-bocking mode, it could + not be reset to blocking mode. + (This problem is reported by Cagdas Gerede.) + * test/test_break.rb: add a testcase to test the above problem. + +2008-01-12 KUBO Takehiro * ext/oci8/oradate.c, ext/oci8/oranumber.c: fix SEGV bugs. OraDate.new made a core dump on x86_64 linux. (This problem is reported by Alun Eyre.) Modified: branches/ruby-oci8-1.0/lib/oci8.rb.in =================================================================== --- branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-01-12 06:51:43 UTC (rev 238) +++ branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-01-12 07:12:45 UTC (rev 239) @@ -315,7 +315,7 @@ end # non_blocking? def non_blocking=(nb) - if nb && ! non_blocking? + if (nb ? true : false) != non_blocking? # If the argument and the current status are different, # toggle blocking / non-blocking. @srv = @svc.attrGet(OCI_ATTR_SERVER) unless @srv Modified: branches/ruby-oci8-1.0/test/test_break.rb =================================================================== --- branches/ruby-oci8-1.0/test/test_break.rb 2008-01-12 06:51:43 UTC (rev 238) +++ branches/ruby-oci8-1.0/test/test_break.rb 2008-01-12 07:12:45 UTC (rev 239) @@ -36,6 +36,17 @@ th.join end + def test_set_blocking_mode + conn = OCI8.new($dbuser, $dbpass, $dbname) + conn.non_blocking = true + assert_equal(true, conn.non_blocking?) + conn.non_blocking = false + assert_equal(false, conn.non_blocking?) + conn.non_blocking = true + assert_equal(true, conn.non_blocking?) + conn.logoff() + end + def test_blocking_mode conn = OCI8.new($dbuser, $dbpass, $dbname) conn.non_blocking = false From nobody at rubyforge.org Mon Jan 14 00:38:50 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 Jan 2008 00:38:50 -0500 (EST) Subject: [ruby-oci8-commit] [240] trunk/ruby-oci8: * ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check. Message-ID: <20080114053850.5FA7918585BA@rubyforge.org> Revision: 240 Author: kubo Date: 2008-01-14 00:38:49 -0500 (Mon, 14 Jan 2008) Log Message: ----------- * ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check. * ext/oci8/ocidatetime.c, test/test_datetime.rb: use DateTime.parse('0001-01-01 00:00:00.1') instead of DateTime.parse('00:00:00.1'). The latter doesn't work on ruby 1.8.5 or earlier. * test/config.rb: revert the previous commit and add get_oci8_connection() and get_dbi_connection() to the base class of test cases. When an attempt to connect fails by ORA-12516 or ORA-12520, their methods sleep one seconds and try again more once. delete unused method setup_lowapi(). * test/test_bind_raw.rb, test/test_bind_time.rb, test/test_break.rb, test/test_clob.rb, test/test_datetime.rb, test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb, test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb, test_oranumber.rb: revert the previous commit and use get_oci8_connection() or get_dbi_connection() to make a connection. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl trunk/ruby-oci8/ext/oci8/ocidatetime.c trunk/ruby-oci8/test/config.rb trunk/ruby-oci8/test/test_bind_raw.rb trunk/ruby-oci8/test/test_bind_time.rb trunk/ruby-oci8/test/test_break.rb trunk/ruby-oci8/test/test_clob.rb trunk/ruby-oci8/test/test_datetime.rb trunk/ruby-oci8/test/test_dbi.rb trunk/ruby-oci8/test/test_dbi_clob.rb trunk/ruby-oci8/test/test_metadata.rb trunk/ruby-oci8/test/test_object.rb trunk/ruby-oci8/test/test_oci8.rb trunk/ruby-oci8/test/test_oradate.rb trunk/ruby-oci8/test/test_oranumber.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/ChangeLog 2008-01-14 05:38:49 UTC (rev 240) @@ -1,3 +1,23 @@ +2008-01-14 KUBO Takehiro + * ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check. + * ext/oci8/ocidatetime.c, test/test_datetime.rb: use + DateTime.parse('0001-01-01 00:00:00.1') instead of + DateTime.parse('00:00:00.1'). The latter doesn't work + on ruby 1.8.5 or earlier. + * test/config.rb: revert the previous commit and add + get_oci8_connection() and get_dbi_connection() to the + base class of test cases. When an attempt to connect fails + by ORA-12516 or ORA-12520, their methods sleep one seconds + and try again more once. + delete unused method setup_lowapi(). + * test/test_bind_raw.rb, test/test_bind_time.rb, + test/test_break.rb, test/test_clob.rb, test/test_datetime.rb, + test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb, + test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb, + test_oranumber.rb: revert the previous commit and use + get_oci8_connection() or get_dbi_connection() to make a + connection. + 2008-01-08 KUBO Takehiro * test/config.rb, test/test_bind_raw.rb, test/test_bind_time.rb, test/test_break.rb, test/test_clob.rb, test/test_datetime.rb, Modified: trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl =================================================================== --- trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl 2008-01-14 05:38:49 UTC (rev 240) @@ -174,7 +174,7 @@ end have_vars << 'have_' + f.name + (f.remote ? '_nb' : '') %> <%=f.name%>_func = (<%=f.name%>_func_t)oci8_find_symbol("<%=f.name%>"); - if (<%=f.name%>_func != NULL) + if (<%=f.name%>_func == NULL) return; <% end Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocidatetime.c 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/ext/oci8/ocidatetime.c 2008-01-14 05:38:49 UTC (rev 240) @@ -730,7 +730,7 @@ minute_base = rb_funcall(hour_base, id_mul, 1, INT2FIX(60)); sec_base = rb_funcall(minute_base, id_mul, 1, INT2FIX(60)); fsec_base = rb_funcall(sec_base, id_mul, 1, INT2FIX(1000000000)); - fsec_mul = rb_eval_string("(100_000_000 / DateTime.parse('00:00:00.1').sec_fraction).to_i"); + fsec_mul = rb_eval_string("(100_000_000 / DateTime.parse('0001-01-01 00:00:00.1').sec_fraction).to_i"); rb_global_variable(&hour_base); rb_global_variable(&minute_base); rb_global_variable(&sec_base); Modified: trunk/ruby-oci8/test/config.rb =================================================================== --- trunk/ruby-oci8/test/config.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/config.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -20,21 +20,15 @@ # don't modify below. -$dbconn = OCI8.new($dbuser, $dbpass, $dbname) -begin - require 'dbi' - $dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) -rescue LoadError -end - - # $oracle_server_version: database compatible level of the Oracle server. # $oracle_client_version: Oracle client library version for which oci8 is compiled. # $oracle_version: lower value of $oracle_server_version and $oracle_client_version. -$dbconn.exec('select value from database_compatible_level') do |row| +conn = OCI8.new($dbuser, $dbpass, $dbname) +conn.exec('select value from database_compatible_level') do |row| ver = row[0].split('.') $oracle_server_version = (ver[0] + ver[1] + ver[2]).to_i end +conn.logoff $oracle_client_version = OCI8::CLIENT_VERSION.to_i if $oracle_server_version < $oracle_client_version @@ -54,25 +48,40 @@ $test_clob = true end -$env_is_initialized = false -def setup_lowapi() - if ! $env_is_initialized - if $describe_need_object_mode - OCIEnv.initialise(OCI_OBJECT) - else - OCIEnv.initialise(OCI_DEFAULT) - end - $env_is_initialized = true - end - env = OCIEnv.init() - svc = env.logon($dbuser, $dbpass, $dbname) - stmt = env.alloc(OCIStmt) - return env, svc, stmt -end - module Test module Unit class TestCase + + def get_oci8_connection() + OCI8.new($dbuser, $dbpass, $dbname) + rescue OCIError + raise if $!.code != 12516 && $!.code != 12520 + # sleep one second and try again if + # the error code is ORA-12516 or ORA-12520. + # + # ORA-12516 - TNS:listener could not find available handler with + # matching protocol stack + # ORA-12520 - TNS:listener could not find available handler for + # requested type of server + # + # Thanks to Christopher Jones. + # + # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4) + # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf + # + sleep(1) + OCI8.new($dbuser, $dbpass, $dbname) + end + + def get_dbi_connection() + DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) + rescue DBI::DatabaseError + raise if $!.err != 12516 && $!.err != 12520 + # same as get_oci8_connection() + sleep(1) + DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) + end + def drop_table(table_name) if $oracle_server_version < 1000 # Oracle 8 - 9i Modified: trunk/ruby-oci8/test/test_bind_raw.rb =================================================================== --- trunk/ruby-oci8/test/test_bind_raw.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_bind_raw.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -13,7 +13,7 @@ ] def setup - @conn = $dbconn + @conn = get_oci8_connection() end def test_set_raw @@ -41,6 +41,6 @@ end def teardown - @conn.rollback + @conn.logoff end end Modified: trunk/ruby-oci8/test/test_bind_time.rb =================================================================== --- trunk/ruby-oci8/test/test_bind_time.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_bind_time.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -12,7 +12,7 @@ SEC_CHECK_TARGET = [0, 15, 30, 45, 59] def setup - @conn = $dbconn + @conn = get_oci8_connection end def test_set_year @@ -173,6 +173,6 @@ end def teardown - @conn.rollback + @conn.logoff end end Modified: trunk/ruby-oci8/test/test_break.rb =================================================================== --- trunk/ruby-oci8/test/test_break.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_break.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -6,12 +6,11 @@ class TestBreak < Test::Unit::TestCase def setup - @conn = $dbconn + @conn = get_oci8_connection end def teardown - @conn.non_blocking = false - @conn.rollback + @conn.logoff end def report(str) Modified: trunk/ruby-oci8/test/test_clob.rb =================================================================== --- trunk/ruby-oci8/test/test_clob.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_clob.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -6,7 +6,7 @@ class TestCLob < Test::Unit::TestCase def setup - @conn = $dbconn + @conn = get_oci8_connection end def test_insert @@ -58,6 +58,6 @@ end def teardown - @conn.rollback + @conn.logoff end end Modified: trunk/ruby-oci8/test/test_datetime.rb =================================================================== --- trunk/ruby-oci8/test/test_datetime.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_datetime.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -13,12 +13,12 @@ end def setup - @conn = $dbconn + @conn = get_oci8_connection @local_timezone = timezone_string(*((::Time.now.utc_offset / 60).divmod 60)) end def teardown - @conn.rollback + @conn.logoff end def test_date_select @@ -187,7 +187,7 @@ cursor.exec assert_equal(DateTime.parse('2006-12-31 23:59:59'), cursor[:out]) # test sec_fraction - def obj.sec_fraction; DateTime.parse('00:00:00.000001').sec_fraction * 999999 ; end + def obj.sec_fraction; DateTime.parse('0001-01-01 00:00:00.000001').sec_fraction * 999999 ; end cursor[:in] = obj cursor.exec assert_equal(DateTime.parse('2006-12-31 23:59:59.999999'), cursor[:out]) Modified: trunk/ruby-oci8/test/test_dbi.rb =================================================================== --- trunk/ruby-oci8/test/test_dbi.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_dbi.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -6,11 +6,11 @@ class TestDBI < Test::Unit::TestCase def setup - @dbh = $dbh + @dbh = get_dbi_connection() end def teardown - @dbh.rollback + @dbh.disconnect end def test_select Modified: trunk/ruby-oci8/test/test_dbi_clob.rb =================================================================== --- trunk/ruby-oci8/test/test_dbi_clob.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_dbi_clob.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -5,7 +5,7 @@ class TestDbiCLob < Test::Unit::TestCase def setup - @dbh = $dbh + @dbh = get_dbi_connection() end def test_insert @@ -45,6 +45,6 @@ end def teardown - @dbh.rollback + @dbh.disconnect end end Modified: trunk/ruby-oci8/test/test_metadata.rb =================================================================== --- trunk/ruby-oci8/test/test_metadata.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_metadata.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -5,11 +5,11 @@ class TestMetadata < Test::Unit::TestCase def setup - @conn = $dbconn + @conn = get_oci8_connection end def teardown - @conn.rollback + @conn.logoff end def test_metadata Modified: trunk/ruby-oci8/test/test_object.rb =================================================================== --- trunk/ruby-oci8/test/test_object.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_object.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -9,12 +9,12 @@ Delta = 0.00001 def setup - @conn = $dbconn + @conn = get_oci8_connection RbTestObj.default_connection = @conn end def teardown - @conn.rollback + @conn.logoff end class ExpectedValObjElem Modified: trunk/ruby-oci8/test/test_oci8.rb =================================================================== --- trunk/ruby-oci8/test/test_oci8.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_oci8.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -5,11 +5,11 @@ class TestOCI8 < Test::Unit::TestCase def setup - @conn = $dbconn + @conn = get_oci8_connection end def teardown - @conn.rollback + @conn.logoff end def test_rename Modified: trunk/ruby-oci8/test/test_oradate.rb =================================================================== --- trunk/ruby-oci8/test/test_oradate.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_oradate.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -13,7 +13,7 @@ SECOND_CHECK_TARGET = [0, 15, 30, 45, 59] def setup - @conn = $dbconn + @conn = get_oci8_connection end def check_oradate(target, year, month, day, hour, minute, second) @@ -251,6 +251,6 @@ end def teardown - @conn.rollback + @conn.logoff end end Modified: trunk/ruby-oci8/test/test_oranumber.rb =================================================================== --- trunk/ruby-oci8/test/test_oranumber.rb 2008-01-12 07:12:45 UTC (rev 239) +++ trunk/ruby-oci8/test/test_oranumber.rb 2008-01-14 05:38:49 UTC (rev 240) @@ -53,7 +53,7 @@ ] def setup - @conn = $dbconn + @conn = get_oci8_connection end def test_to_s @@ -137,6 +137,6 @@ end def teardown - @conn.rollback + @conn.logoff end end From nobody at rubyforge.org Mon Jan 14 10:44:44 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 14 Jan 2008 10:44:44 -0500 (EST) Subject: [ruby-oci8-commit] [241] trunk/ruby-oci8: * ext/oci8/oci8.h ext/oci8/oci8lib.c: rename variable name Message-ID: <20080114154445.04A9418585F7@rubyforge.org> Revision: 241 Author: kubo Date: 2008-01-14 10:44:44 -0500 (Mon, 14 Jan 2008) Log Message: ----------- * ext/oci8/oci8.h ext/oci8/oci8lib.c: rename variable name cOCIHandle to oci8_cOCIHandle to use outside of oci8lib.c. * ext/oci8/metadata.c: use oci8_cOCIHandle instead of rb_cObject to hold a descrbe handle. check parent object's handle type in oci8_metadata_create(). Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/metadata.c trunk/ruby-oci8/ext/oci8/oci8.h trunk/ruby-oci8/ext/oci8/oci8lib.c Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-01-14 05:38:49 UTC (rev 240) +++ trunk/ruby-oci8/ChangeLog 2008-01-14 15:44:44 UTC (rev 241) @@ -1,4 +1,11 @@ 2008-01-14 KUBO Takehiro + * ext/oci8/oci8.h ext/oci8/oci8lib.c: rename variable name + cOCIHandle to oci8_cOCIHandle to use outside of oci8lib.c. + * ext/oci8/metadata.c: use oci8_cOCIHandle instead of rb_cObject + to hold a descrbe handle. check parent object's handle type + in oci8_metadata_create(). + +2008-01-14 KUBO Takehiro * ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check. * ext/oci8/ocidatetime.c, test/test_datetime.rb: use DateTime.parse('0001-01-01 00:00:00.1') instead of Modified: trunk/ruby-oci8/ext/oci8/metadata.c =================================================================== --- trunk/ruby-oci8/ext/oci8/metadata.c 2008-01-14 05:38:49 UTC (rev 240) +++ trunk/ruby-oci8/ext/oci8/metadata.c 2008-01-14 15:44:44 UTC (rev 241) @@ -38,6 +38,8 @@ VALUE klass; VALUE obj; + Check_Handle(parent, oci8_cOCIHandle, p); + oci_lc(OCIAttrGet(parmhp, OCI_DTYPE_PARAM, &ptype, &size, OCI_ATTR_PTYPE, oci8_errhp)); klass = rb_hash_aref(ptype_to_class, INT2FIX(ptype)); if (NIL_P(klass)) @@ -51,7 +53,6 @@ md->base.hp.prm = parmhp; md->svc = svc; - p = DATA_PTR(parent); if (p->type == OCI_HTYPE_STMT) { md->is_implicit = 1; } else { @@ -261,39 +262,30 @@ return md->is_implicit ? Qtrue : Qfalse; } -static void oci8_desc_free(OCIDescribe *dschp) -{ - if (dschp != NULL) - OCIHandleFree(dschp, OCI_HTYPE_DESCRIBE); -} - static VALUE oci8_do_describe(VALUE self, void *objptr, ub4 objlen, ub1 objtype, VALUE klass, VALUE check_public) { oci8_svcctx_t *svcctx = DATA_PTR(self); - OCIDescribe *dschp; OCIParam *parmhp; VALUE type; - sword rv; - VALUE desc; + VALUE obj; + oci8_base_t *desc; + /* make a describe handle object */ + obj = rb_obj_alloc(oci8_cOCIHandle); + desc = DATA_PTR(obj); + oci_lc(OCIHandleAlloc(oci8_envhp, (dvoid *)&desc->hp.dschp, OCI_HTYPE_DESCRIBE, 0, 0)); + desc->type = OCI_HTYPE_DESCRIBE; + type = rb_hash_aref(class_to_ptype, klass); - oci_lc(OCIHandleAlloc(oci8_envhp, (dvoid *)&dschp, OCI_HTYPE_DESCRIBE, 0, 0)); - /* dschp is freed when GC runs. */ - desc = Data_Wrap_Struct(rb_cObject, NULL, oci8_desc_free, dschp); if (RTEST(check_public)) { sb4 val = -1; /* size of OCI_ATTR_DESC_PUBLIC is undocumented. */ - oci_lc(OCIAttrSet(dschp, OCI_HTYPE_DESCRIBE, &val, 0, OCI_ATTR_DESC_PUBLIC, oci8_errhp)); + oci_lc(OCIAttrSet(desc->hp.dschp, OCI_HTYPE_DESCRIBE, &val, 0, OCI_ATTR_DESC_PUBLIC, oci8_errhp)); } - rv = OCIDescribeAny_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, objptr, objlen, - objtype, OCI_DEFAULT, FIX2INT(type), dschp); - if (rv != OCI_SUCCESS) { - OCIHandleFree(dschp, OCI_HTYPE_DESCRIBE); - DATA_PTR(desc) = NULL; - oci8_raise(oci8_errhp, rv, NULL); - } - oci_lc(OCIAttrGet(dschp, OCI_HTYPE_DESCRIBE, &parmhp, 0, OCI_ATTR_PARAM, oci8_errhp)); - return oci8_metadata_create(parmhp, self, desc); + oci_lc(OCIDescribeAny_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, objptr, objlen, + objtype, OCI_DEFAULT, FIX2INT(type), desc->hp.dschp)); + oci_lc(OCIAttrGet(desc->hp.dschp, OCI_HTYPE_DESCRIBE, &parmhp, 0, OCI_ATTR_PARAM, oci8_errhp)); + return oci8_metadata_create(parmhp, self, obj); } static VALUE oci8_describe(VALUE self, VALUE name, VALUE klass, VALUE check_public) Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2008-01-14 05:38:49 UTC (rev 240) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2008-01-14 15:44:44 UTC (rev 241) @@ -144,6 +144,7 @@ OCIParam *prm; OCILobLocator *lob; OCIType *tdo; + OCIDescribe *dschp; } hp; VALUE self; oci8_base_class_t *klass; @@ -234,6 +235,7 @@ extern ID oci8_id_set; extern ID oci8_id_keys; extern int oci8_in_finalizer; +extern VALUE oci8_cOCIHandle; void oci8_base_free(oci8_base_t *base); VALUE oci8_define_class(const char *name, oci8_base_class_t *klass); VALUE oci8_define_class_under(VALUE outer, const char *name, oci8_base_class_t *klass); Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8lib.c 2008-01-14 05:38:49 UTC (rev 240) +++ trunk/ruby-oci8/ext/oci8/oci8lib.c 2008-01-14 15:44:44 UTC (rev 241) @@ -26,9 +26,10 @@ ID oci8_id_set; ID oci8_id_keys; int oci8_in_finalizer = 0; +VALUE oci8_cOCIHandle; + static ID id_oci8_class; -static VALUE cOCIHandle; static VALUE mOCI8BindType; static VALUE cOCI8BindTypeBase; @@ -111,6 +112,7 @@ Init_oci8lib() { VALUE cOCI8; + VALUE obj; #ifdef RUNTIME_API_CHECK Init_oci8_apiwrap(); @@ -127,17 +129,19 @@ Init_oci8_env(); /* OCIHandle class */ - cOCIHandle = rb_define_class("OCIHandle", rb_cObject); - rb_define_alloc_func(cOCIHandle, oci8_s_allocate); - rb_define_method(cOCIHandle, "initialize", oci8_handle_initialize, 0); - rb_define_method(cOCIHandle, "free", oci8_handle_free, 0); + oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject); + rb_define_alloc_func(oci8_cOCIHandle, oci8_s_allocate); + rb_define_method(oci8_cOCIHandle, "initialize", oci8_handle_initialize, 0); + rb_define_method(oci8_cOCIHandle, "free", oci8_handle_free, 0); + obj = Data_Wrap_Struct(rb_cObject, 0, 0, &oci8_base_class); + rb_ivar_set(oci8_cOCIHandle, id_oci8_class, obj); /* OCI8 class */ cOCI8 = Init_oci8(); /* OCI8::BindType module */ mOCI8BindType = rb_define_module_under(cOCI8, "BindType"); /* OCI8::BindType::Base class */ - cOCI8BindTypeBase = rb_define_class_under(mOCI8BindType, "Base", cOCIHandle); + cOCI8BindTypeBase = rb_define_class_under(mOCI8BindType, "Base", oci8_cOCIHandle); /* Handle */ Init_oci8_bind(cOCI8BindTypeBase); @@ -161,7 +165,7 @@ VALUE oci8_define_class(const char *name, oci8_base_class_t *base_class) { - VALUE klass = rb_define_class(name, cOCIHandle); + VALUE klass = rb_define_class(name, oci8_cOCIHandle); VALUE obj = Data_Wrap_Struct(rb_cObject, 0, 0, base_class); rb_ivar_set(klass, id_oci8_class, obj); return klass; @@ -169,7 +173,7 @@ VALUE oci8_define_class_under(VALUE outer, const char *name, oci8_base_class_t *base_class) { - VALUE klass = rb_define_class_under(outer, name, cOCIHandle); + VALUE klass = rb_define_class_under(outer, name, oci8_cOCIHandle); VALUE obj = Data_Wrap_Struct(rb_cObject, 0, 0, base_class); rb_ivar_set(klass, id_oci8_class, obj); return klass; From nobody at rubyforge.org Tue Jan 15 10:52:14 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 15 Jan 2008 10:52:14 -0500 (EST) Subject: [ruby-oci8-commit] [242] trunk/ruby-oci8: * ext/oci8/extconf.rb: add checking code for intern. h, util.h, Message-ID: <20080115155214.84813185864A@rubyforge.org> Revision: 242 Author: kubo Date: 2008-01-15 10:52:14 -0500 (Tue, 15 Jan 2008) Log Message: ----------- * ext/oci8/extconf.rb: add checking code for intern.h, util.h, ruby/util.h, ruby_errinfo and rb_errinfo. * ext/oci8/env.c: define a header file to be included by HAVE_RUBY_UTIL_H and HAVE_UTIL_H, not by RUBY_VM. * ext/oci8/oci8.h: define a header file to be included by HAVE_INTERN_H, not by RUBY_VM. use HAVE_RB_ERRINFO and HAVE_RUBY_ERRINFO to define rb_errinfo() as a macro. * ext/oci8/oci8.c: use rb_eval_string() instead of rb_reg_new() for not to use RUBY_VM. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/env.c trunk/ruby-oci8/ext/oci8/extconf.rb trunk/ruby-oci8/ext/oci8/oci8.c trunk/ruby-oci8/ext/oci8/oci8.h Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-01-14 15:44:44 UTC (rev 241) +++ trunk/ruby-oci8/ChangeLog 2008-01-15 15:52:14 UTC (rev 242) @@ -1,4 +1,15 @@ 2008-01-14 KUBO Takehiro + * ext/oci8/extconf.rb: add checking code for intern.h, util.h, + ruby/util.h, ruby_errinfo and rb_errinfo. + * ext/oci8/env.c: define a header file to be included by + HAVE_RUBY_UTIL_H and HAVE_UTIL_H, not by RUBY_VM. + * ext/oci8/oci8.h: define a header file to be included by + HAVE_INTERN_H, not by RUBY_VM. use HAVE_RB_ERRINFO and + HAVE_RUBY_ERRINFO to define rb_errinfo() as a macro. + * ext/oci8/oci8.c: use rb_eval_string() instead of rb_reg_new() + for not to use RUBY_VM. + +2008-01-14 KUBO Takehiro * ext/oci8/oci8.h ext/oci8/oci8lib.c: rename variable name cOCIHandle to oci8_cOCIHandle to use outside of oci8lib.c. * ext/oci8/metadata.c: use oci8_cOCIHandle instead of rb_cObject Modified: trunk/ruby-oci8/ext/oci8/env.c =================================================================== --- trunk/ruby-oci8/ext/oci8/env.c 2008-01-14 15:44:44 UTC (rev 241) +++ trunk/ruby-oci8/ext/oci8/env.c 2008-01-15 15:52:14 UTC (rev 242) @@ -8,9 +8,10 @@ #include "oci8.h" /* ruby_setenv */ -#ifdef RUBY_VM +#ifdef HAVE_RUBY_UTIL_H #include -#else +#endif +#ifdef HAVE_UTIL_H #include #endif Modified: trunk/ruby-oci8/ext/oci8/extconf.rb =================================================================== --- trunk/ruby-oci8/ext/oci8/extconf.rb 2008-01-14 15:44:44 UTC (rev 241) +++ trunk/ruby-oci8/ext/oci8/extconf.rb 2008-01-15 15:52:14 UTC (rev 242) @@ -69,6 +69,16 @@ have_func("localtime_r") +# ruby 1.8 headers +have_header("intern.h") +have_header("util.h") +# ruby 1.9 headers +have_header("ruby/util.h") + +# $! in C API +have_var("ruby_errinfo", "ruby.h") # ruby 1.8 +have_func("rb_errinfo", "ruby.h") # ruby 1.9 + # replace files replace = { 'OCI8_CLIENT_VERSION' => oraconf.version, Modified: trunk/ruby-oci8/ext/oci8/oci8.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.c 2008-01-14 15:44:44 UTC (rev 241) +++ trunk/ruby-oci8/ext/oci8/oci8.c 2008-01-15 15:52:14 UTC (rev 242) @@ -61,16 +61,12 @@ static ID id_at_username; static ID id_set_prefetch_rows; -#define CONN_STR_REGEX "^([^(\\s|\\@)]*)\\/([^(\\s|\\@)]*)(?:\\@(\\S+))?(?:\\s+as\\s+(\\S*)\\s*)?$" +#define CONN_STR_REGEX "/^([^(\\s|\\@)]*)\\/([^(\\s|\\@)]*)(?:\\@(\\S+))?(?:\\s+as\\s+(\\S*)\\s*)?$/i" static void oci8_do_parse_connect_string(VALUE conn_str, VALUE *user, VALUE *pass, VALUE *dbname, VALUE *mode) { static VALUE re = Qnil; if (NIL_P(re)) { -#ifdef RUBY_VM - re = rb_reg_new(rb_str_new2(CONN_STR_REGEX), FIX2INT(rb_eval_string("Regexp::IGNORECASE"))); -#else - re = rb_reg_new(CONN_STR_REGEX, strlen(CONN_STR_REGEX), FIX2INT(rb_eval_string("Regexp::IGNORECASE"))); -#endif + re = rb_eval_string(CONN_STR_REGEX); rb_global_variable(&re); } StringValue(conn_str); Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2008-01-14 15:44:44 UTC (rev 241) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2008-01-15 15:52:14 UTC (rev 242) @@ -9,7 +9,7 @@ #include "ruby.h" #include "rubyio.h" -#ifndef RUBY_VM +#ifdef HAVE_INTERN_H #include "intern.h" #endif @@ -58,7 +58,7 @@ #define RFLOAT_VALUE(obj) RFLOAT(obj)->value #endif -#ifndef RUBY_VM +#if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO) #define rb_errinfo() ruby_errinfo #endif