From nobody at rubyforge.org Sat Aug 14 05:32:01 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 14 Aug 2010 05:32:01 -0400 (EDT) Subject: [ruby-oci8-commit] [402] branches/ruby-oci8-2.0/: branch for 2.0 release Message-ID: <20100814093201.679DE19782D9@rubyforge.org> Revision: 402 Author: kubo Date: 2010-08-14 05:32:00 -0400 (Sat, 14 Aug 2010) Log Message: ----------- branch for 2.0 release Added Paths: ----------- branches/ruby-oci8-2.0/ From nobody at rubyforge.org Sat Aug 14 08:37:21 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 14 Aug 2010 08:37:21 -0400 (EDT) Subject: [ruby-oci8-commit] [403] branches/ruby-oci8-2.0: * ext/oci8/bind.c: fix a bug that a string is bound to RAW. Message-ID: <20100814123721.668FB1858366@rubyforge.org> Revision: 403 Author: kubo Date: 2010-08-14 08:37:20 -0400 (Sat, 14 Aug 2010) Log Message: ----------- * ext/oci8/bind.c: fix a bug that a string is bound to RAW. Its encoding had been convertd to OCI.encoding incorrectly. (backport from the trunk) * ext/oci8/stmt.c: fix SEGV when an exception is raised while a bind value is deallocated. (backport from the trunk) Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog branches/ruby-oci8-2.0/ext/oci8/bind.c branches/ruby-oci8-2.0/ext/oci8/stmt.c Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-14 09:32:00 UTC (rev 402) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-14 12:37:20 UTC (rev 403) @@ -1,3 +1,11 @@ +2010-08-14 KUBO Takehiro + * ext/oci8/bind.c: fix a bug that a string is bound to RAW. + Its encoding had been convertd to OCI.encoding incorrectly. + (backport from the trunk) + * ext/oci8/stmt.c: fix SEGV when an exception is raised while + a bind value is deallocated. + (backport from the trunk) + 2010-04-23 KUBO Takehiro * ext/oci8/oranumber_util.c, test/test_oranumber.rb: add limitted support for OraNumber's positive and negative Modified: branches/ruby-oci8-2.0/ext/oci8/bind.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/bind.c 2010-08-14 09:32:00 UTC (rev 402) +++ branches/ruby-oci8-2.0/ext/oci8/bind.c 2010-08-14 12:37:20 UTC (rev 403) @@ -79,6 +79,18 @@ return rb_str_new(vstr->buf, vstr->size); } +static void bind_raw_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val) +{ + oci8_vstr_t *vstr = (oci8_vstr_t *)data; + + StringValue(val); + if (RSTRING_LEN(val) > obind->value_sz - sizeof(vstr->size)) { + rb_raise(rb_eArgError, "too long String to set. (%ld for %d)", RSTRING_LEN(val), obind->value_sz - (sb4)sizeof(vstr->size)); + } + memcpy(vstr->buf, RSTRING_PTR(val), RSTRING_LEN(val)); + vstr->size = RSTRING_LEN(val); +} + static const oci8_bind_class_t bind_raw_class = { { NULL, @@ -86,7 +98,7 @@ sizeof(oci8_bind_t) }, bind_raw_get, - bind_string_set, + bind_raw_set, bind_string_init, NULL, NULL, Modified: branches/ruby-oci8-2.0/ext/oci8/stmt.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/stmt.c 2010-08-14 09:32:00 UTC (rev 402) +++ branches/ruby-oci8-2.0/ext/oci8/stmt.c 2010-08-14 12:37:20 UTC (rev 403) @@ -3,7 +3,7 @@ * stmt.c - part of ruby-oci8 * implement the methods of OCIStmt. * - * Copyright (C) 2002-2007 KUBO Takehiro + * Copyright (C) 2002-2010 KUBO Takehiro * */ #include "oci8.h" @@ -117,6 +117,10 @@ oci8_raise(oci8_errhp, status, stmt->base.hp.ptr); } obind->base.type = OCI_HTYPE_DEFINE; + /* link to the parent as soon as possible to preserve deallocation order. */ + oci8_unlink_from_parent((oci8_base_t*)obind); + oci8_link_to_parent((oci8_base_t*)obind, (oci8_base_t*)stmt); + if (NIL_P(obind->tdo) && obind->maxar_sz > 0) { oci_lc(OCIDefineArrayOfStruct(obind->base.hp.dfn, oci8_errhp, obind->alloc_sz, sizeof(sb2), 0, 0)); } @@ -135,8 +139,6 @@ oci_lc(OCIAttrSet(obind->base.hp.ptr, OCI_HTYPE_DEFINE, (void*)&bind_class->csfrm, 0, OCI_ATTR_CHARSET_FORM, oci8_errhp)); } rb_ary_store(stmt->defns, position - 1, obind->base.self); - oci8_unlink_from_parent((oci8_base_t*)obind); - oci8_link_to_parent((oci8_base_t*)obind, (oci8_base_t*)stmt); return obind->base.self; } @@ -197,6 +199,10 @@ oci8_raise(oci8_errhp, status, stmt->base.hp.stmt); } obind->base.type = OCI_HTYPE_BIND; + /* link to the parent as soon as possible to preserve deallocation order. */ + oci8_unlink_from_parent((oci8_base_t*)obind); + oci8_link_to_parent((oci8_base_t*)obind, (oci8_base_t*)stmt); + if (NIL_P(obind->tdo) && obind->maxar_sz > 0) { oci_lc(OCIBindArrayOfStruct(obind->base.hp.bnd, oci8_errhp, obind->alloc_sz, sizeof(sb2), 0, 0)); } @@ -213,8 +219,6 @@ oci8_base_free((oci8_base_t*)oci8_get_bind(old_value)); } rb_hash_aset(stmt->binds, vplaceholder, obind->base.self); - oci8_unlink_from_parent((oci8_base_t*)obind); - oci8_link_to_parent((oci8_base_t*)obind, (oci8_base_t*)stmt); return obind->base.self; } From nobody at rubyforge.org Sun Aug 15 01:12:33 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 15 Aug 2010 01:12:33 -0400 (EDT) Subject: [ruby-oci8-commit] [404] trunk/ruby-oci8/ext/oci8: * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary Message-ID: <20100815051233.A5AE51858363@rubyforge.org> Revision: 404 Author: kubo Date: 2010-08-15 01:12:32 -0400 (Sun, 15 Aug 2010) Log Message: ----------- * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary lobs are used. Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml branches/ruby-oci8-2.0/ext/oci8/lob.c trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/apiwrap.yml trunk/ruby-oci8/ext/oci8/lob.c Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-14 12:37:20 UTC (rev 403) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-15 05:12:32 UTC (rev 404) @@ -1,3 +1,7 @@ +2010-08-15 KUBO Takehiro + * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary + lobs are used. + 2010-08-14 KUBO Takehiro * ext/oci8/bind.c: fix a bug that a string is bound to RAW. Its encoding had been convertd to OCI.encoding incorrectly. Modified: branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml 2010-08-14 12:37:20 UTC (rev 403) +++ branches/ruby-oci8-2.0/ext/oci8/apiwrap.yml 2010-08-15 05:12:32 UTC (rev 404) @@ -916,6 +916,13 @@ - OCIDuration duration # round trip: 1 +OCILobFreeTemporary_nb: + :version: 810 + :args: - OCISvcCtx *svchp + - OCIError *errhp + - OCILobLocator *locp + +# round trip: 1 OCILobGetChunkSize_nb: :version: 810 :args: - OCISvcCtx *svchp Modified: branches/ruby-oci8-2.0/ext/oci8/lob.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/lob.c 2010-08-14 12:37:20 UTC (rev 403) +++ branches/ruby-oci8-2.0/ext/oci8/lob.c 2010-08-15 05:12:32 UTC (rev 404) @@ -70,9 +70,27 @@ rb_gc_mark(lob->svc); } +static VALUE free_temp_lob(oci8_lob_t *lob) +{ + oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc); + + OCILobFreeTemporary_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob); + return Qnil; +} + static void oci8_lob_free(oci8_base_t *base) { oci8_lob_t *lob = (oci8_lob_t *)base; + boolean is_temporary; + + if (have_OCILobIsTemporary + && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS + && is_temporary) { + /* Exceptions in free_temp_lob() are ignored. + * oci8_lob_free() is called in GC. It must not raise an exception. + */ + rb_rescue(free_temp_lob, (VALUE)base, NULL, 0); + } lob->svc = Qnil; } Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2010-08-14 12:37:20 UTC (rev 403) +++ trunk/ruby-oci8/ChangeLog 2010-08-15 05:12:32 UTC (rev 404) @@ -1,3 +1,7 @@ +2010-08-15 KUBO Takehiro + * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary + lobs are used. + 2010-06-15 KUBO Takehiro * lib/oci8/metadata.rb: rename OCI8::Metadata::Column#type_string to #data_type_string and add an alias from the former to the Modified: trunk/ruby-oci8/ext/oci8/apiwrap.yml =================================================================== --- trunk/ruby-oci8/ext/oci8/apiwrap.yml 2010-08-14 12:37:20 UTC (rev 403) +++ trunk/ruby-oci8/ext/oci8/apiwrap.yml 2010-08-15 05:12:32 UTC (rev 404) @@ -916,6 +916,13 @@ - OCIDuration duration # round trip: 1 +OCILobFreeTemporary_nb: + :version: 810 + :args: - OCISvcCtx *svchp + - OCIError *errhp + - OCILobLocator *locp + +# round trip: 1 OCILobGetChunkSize_nb: :version: 810 :args: - OCISvcCtx *svchp Modified: trunk/ruby-oci8/ext/oci8/lob.c =================================================================== --- trunk/ruby-oci8/ext/oci8/lob.c 2010-08-14 12:37:20 UTC (rev 403) +++ trunk/ruby-oci8/ext/oci8/lob.c 2010-08-15 05:12:32 UTC (rev 404) @@ -70,9 +70,27 @@ rb_gc_mark(lob->svc); } +static VALUE free_temp_lob(oci8_lob_t *lob) +{ + oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc); + + OCILobFreeTemporary_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob); + return Qnil; +} + static void oci8_lob_free(oci8_base_t *base) { oci8_lob_t *lob = (oci8_lob_t *)base; + boolean is_temporary; + + if (have_OCILobIsTemporary + && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS + && is_temporary) { + /* Exceptions in free_temp_lob() are ignored. + * oci8_lob_free() is called in GC. It must not raise an exception. + */ + rb_rescue(free_temp_lob, (VALUE)base, NULL, 0); + } lob->svc = Qnil; } From nobody at rubyforge.org Sun Aug 15 08:33:14 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 15 Aug 2010 08:33:14 -0400 (EDT) Subject: [ruby-oci8-commit] [405] trunk/ruby-oci8: * ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h , Message-ID: <20100815123314.C705A197828C@rubyforge.org> Revision: 405 Author: kubo Date: 2010-08-15 08:33:14 -0400 (Sun, 15 Aug 2010) Log Message: ----------- * ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h, lib/oci8/object.rb: support LOB datatypes in Oracle objects. * ext/oci8/ocihandle.c: fix SEGV in finalizer when temporary LOBs are used. This bug was introduced by the previous commit. Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog branches/ruby-oci8-2.0/ext/oci8/lob.c branches/ruby-oci8-2.0/ext/oci8/object.c branches/ruby-oci8-2.0/ext/oci8/oci8.h branches/ruby-oci8-2.0/ext/oci8/ocihandle.c branches/ruby-oci8-2.0/lib/oci8/object.rb trunk/ruby-oci8/ChangeLog 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/ocihandle.c trunk/ruby-oci8/lib/oci8/object.rb Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-15 05:12:32 UTC (rev 404) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-15 12:33:14 UTC (rev 405) @@ -1,4 +1,10 @@ 2010-08-15 KUBO Takehiro + * ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h, + lib/oci8/object.rb: support LOB datatypes in Oracle objects. + * ext/oci8/ocihandle.c: fix SEGV in finalizer when temporary LOBs + are used. This bug was introduced by the previous commit. + +2010-08-15 KUBO Takehiro * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary lobs are used. Modified: branches/ruby-oci8-2.0/ext/oci8/lob.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/lob.c 2010-08-15 05:12:32 UTC (rev 404) +++ branches/ruby-oci8-2.0/ext/oci8/lob.c 2010-08-15 12:33:14 UTC (rev 405) @@ -64,6 +64,33 @@ return oci8_make_lob(cOCI8BFILE, svcctx, s); } +static void oci8_assign_lob(VALUE klass, oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_base_t *base; + Check_Handle(lob, klass, base); + oci_lc(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, base->hp.lob, dest)); +} + +void oci8_assign_clob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8CLOB, svcctx, lob, dest); +} + +void oci8_assign_nclob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8NCLOB, svcctx, lob, dest); +} + +void oci8_assign_blob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8BLOB, svcctx, lob, dest); +} + +void oci8_assign_bfile(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8BFILE, svcctx, lob, dest); +} + static void oci8_lob_mark(oci8_base_t *base) { oci8_lob_t *lob = (oci8_lob_t *)base; Modified: branches/ruby-oci8-2.0/ext/oci8/object.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/object.c 2010-08-15 05:12:32 UTC (rev 404) +++ branches/ruby-oci8-2.0/ext/oci8/object.c 2010-08-15 12:33:14 UTC (rev 405) @@ -42,6 +42,10 @@ ATTR_BINARY_FLOAT, ATTR_NAMED_TYPE, ATTR_NAMED_COLLECTION, + ATTR_CLOB, + ATTR_NCLOB, + ATTR_BLOB, + ATTR_BFILE, }; static VALUE get_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data, OCIInd *ind); @@ -198,6 +202,14 @@ rv = rb_funcall(tmp_obj, id_to_value, 0); oci8_unlink_from_parent(&obj->base); return rv; + case ATTR_CLOB: + return oci8_make_clob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); + case ATTR_NCLOB: + return oci8_make_nclob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); + case ATTR_BLOB: + return oci8_make_blob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); + case ATTR_BFILE: + return oci8_make_bfile(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); default: rb_raise(rb_eRuntimeError, "not supported datatype"); } @@ -335,6 +347,11 @@ oci_lc(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->hp.svc, OCI_TYPECODE_NAMEDCOLLECTION, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, &cb_data.data.ptr)); oci_lc(OCIObjectGetInd(oci8_envhp, oci8_errhp, cb_data.data.ptr, (dvoid**)&cb_data.indp)); break; + case ATTR_CLOB: + case ATTR_NCLOB: + case ATTR_BLOB: + case ATTR_BFILE: + rb_raise(rb_eRuntimeError, "Could not set LOB objects to collection types yet."); default: rb_raise(rb_eRuntimeError, "not supported datatype"); } @@ -482,6 +499,18 @@ rb_funcall(tmp_obj, id_set_attributes, 1, val); oci8_unlink_from_parent(&obj->base); break; + case ATTR_CLOB: + oci8_assign_clob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; + case ATTR_NCLOB: + oci8_assign_nclob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; + case ATTR_BLOB: + oci8_assign_blob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; + case ATTR_BFILE: + oci8_assign_bfile(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; default: rb_raise(rb_eRuntimeError, "not supported datatype"); } @@ -615,6 +644,10 @@ rb_define_const(cOCI8TDO, "ATTR_BINARY_FLOAT", INT2FIX(ATTR_BINARY_FLOAT)); rb_define_const(cOCI8TDO, "ATTR_NAMED_TYPE", INT2FIX(ATTR_NAMED_TYPE)); rb_define_const(cOCI8TDO, "ATTR_NAMED_COLLECTION", INT2FIX(ATTR_NAMED_COLLECTION)); + rb_define_const(cOCI8TDO, "ATTR_CLOB", INT2FIX(ATTR_CLOB)); + rb_define_const(cOCI8TDO, "ATTR_NCLOB", INT2FIX(ATTR_NCLOB)); + rb_define_const(cOCI8TDO, "ATTR_BLOB", INT2FIX(ATTR_BLOB)); + rb_define_const(cOCI8TDO, "ATTR_BFILE", INT2FIX(ATTR_BFILE)); #define ALIGNMENT_OF(type) (size_t)&(((struct {char c; type t;}*)0)->t) rb_define_const(cOCI8TDO, "SIZE_OF_POINTER", INT2FIX(sizeof(void *))); rb_define_const(cOCI8TDO, "ALIGNMENT_OF_POINTER", INT2FIX(ALIGNMENT_OF(void *))); Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.h =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/oci8.h 2010-08-15 05:12:32 UTC (rev 404) +++ branches/ruby-oci8-2.0/ext/oci8/oci8.h 2010-08-15 12:33:14 UTC (rev 405) @@ -460,6 +460,10 @@ VALUE oci8_make_nclob(oci8_svcctx_t *svcctx, OCILobLocator *s); VALUE oci8_make_blob(oci8_svcctx_t *svcctx, OCILobLocator *s); VALUE oci8_make_bfile(oci8_svcctx_t *svcctx, OCILobLocator *s); +void oci8_assign_clob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); +void oci8_assign_nclob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); +void oci8_assign_blob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); +void oci8_assign_bfile(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); /* oradate.c */ void Init_ora_date(void); Modified: branches/ruby-oci8-2.0/ext/oci8/ocihandle.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/ocihandle.c 2010-08-15 05:12:32 UTC (rev 404) +++ branches/ruby-oci8-2.0/ext/oci8/ocihandle.c 2010-08-15 12:33:14 UTC (rev 405) @@ -61,6 +61,14 @@ static void oci8_handle_cleanup(oci8_base_t *base) { + if (oci8_in_finalizer) { + /* Do nothing when the program exits. + * The first two words of memory addressed by VALUE datatype is + * changed in finalizer. If a ruby function which access it such + * as rb_obj_is_kind_of is called, it may cause SEGV. + */ + return; + } oci8_base_free(base); xfree(base); } Modified: branches/ruby-oci8-2.0/lib/oci8/object.rb =================================================================== --- branches/ruby-oci8-2.0/lib/oci8/object.rb 2010-08-15 05:12:32 UTC (rev 404) +++ branches/ruby-oci8-2.0/lib/oci8/object.rb 2010-08-15 12:33:14 UTC (rev 405) @@ -457,6 +457,16 @@ #[ATTR_NAMED_COLLECTION, [datatype, typeinfo], SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] tdo = con.get_tdo_by_metadata(metadata.type_metadata) [ATTR_NAMED_COLLECTION, tdo, tdo.val_size, tdo.ind_size, tdo.alignment] + when :clob + if metadata.charset_form != :nchar + [ATTR_CLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] + else + [ATTR_NCLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] + end + when :blob + [ATTR_BLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] + when :bfile + [ATTR_BFILE, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] else raise "unsupported typecode #{metadata.typecode}" end Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2010-08-15 05:12:32 UTC (rev 404) +++ trunk/ruby-oci8/ChangeLog 2010-08-15 12:33:14 UTC (rev 405) @@ -1,4 +1,10 @@ 2010-08-15 KUBO Takehiro + * ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h, + lib/oci8/object.rb: support LOB datatypes in Oracle objects. + * ext/oci8/ocihandle.c: fix SEGV in finalizer when temporary LOBs + are used. This bug was introduced by the previous commit. + +2010-08-15 KUBO Takehiro * ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix memory leak when temporary lobs are used. Modified: trunk/ruby-oci8/ext/oci8/lob.c =================================================================== --- trunk/ruby-oci8/ext/oci8/lob.c 2010-08-15 05:12:32 UTC (rev 404) +++ trunk/ruby-oci8/ext/oci8/lob.c 2010-08-15 12:33:14 UTC (rev 405) @@ -64,6 +64,33 @@ return oci8_make_lob(cOCI8BFILE, svcctx, s); } +static void oci8_assign_lob(VALUE klass, oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_base_t *base; + Check_Handle(lob, klass, base); + oci_lc(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, base->hp.lob, dest)); +} + +void oci8_assign_clob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8CLOB, svcctx, lob, dest); +} + +void oci8_assign_nclob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8NCLOB, svcctx, lob, dest); +} + +void oci8_assign_blob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8BLOB, svcctx, lob, dest); +} + +void oci8_assign_bfile(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest) +{ + oci8_assign_lob(cOCI8BFILE, svcctx, lob, dest); +} + static void oci8_lob_mark(oci8_base_t *base) { oci8_lob_t *lob = (oci8_lob_t *)base; Modified: trunk/ruby-oci8/ext/oci8/object.c =================================================================== --- trunk/ruby-oci8/ext/oci8/object.c 2010-08-15 05:12:32 UTC (rev 404) +++ trunk/ruby-oci8/ext/oci8/object.c 2010-08-15 12:33:14 UTC (rev 405) @@ -42,6 +42,10 @@ ATTR_BINARY_FLOAT, ATTR_NAMED_TYPE, ATTR_NAMED_COLLECTION, + ATTR_CLOB, + ATTR_NCLOB, + ATTR_BLOB, + ATTR_BFILE, }; static VALUE get_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data, OCIInd *ind); @@ -198,6 +202,14 @@ rv = rb_funcall(tmp_obj, id_to_value, 0); oci8_unlink_from_parent(&obj->base); return rv; + case ATTR_CLOB: + return oci8_make_clob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); + case ATTR_NCLOB: + return oci8_make_nclob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); + case ATTR_BLOB: + return oci8_make_blob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); + case ATTR_BFILE: + return oci8_make_bfile(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data); default: rb_raise(rb_eRuntimeError, "not supported datatype"); } @@ -335,6 +347,11 @@ oci_lc(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->hp.svc, OCI_TYPECODE_NAMEDCOLLECTION, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, &cb_data.data.ptr)); oci_lc(OCIObjectGetInd(oci8_envhp, oci8_errhp, cb_data.data.ptr, (dvoid**)&cb_data.indp)); break; + case ATTR_CLOB: + case ATTR_NCLOB: + case ATTR_BLOB: + case ATTR_BFILE: + rb_raise(rb_eRuntimeError, "Could not set LOB objects to collection types yet."); default: rb_raise(rb_eRuntimeError, "not supported datatype"); } @@ -482,6 +499,18 @@ rb_funcall(tmp_obj, id_set_attributes, 1, val); oci8_unlink_from_parent(&obj->base); break; + case ATTR_CLOB: + oci8_assign_clob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; + case ATTR_NCLOB: + oci8_assign_nclob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; + case ATTR_BLOB: + oci8_assign_blob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; + case ATTR_BFILE: + oci8_assign_bfile(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data); + break; default: rb_raise(rb_eRuntimeError, "not supported datatype"); } @@ -631,6 +660,10 @@ rb_define_const(cOCI8TDO, "ATTR_BINARY_FLOAT", INT2FIX(ATTR_BINARY_FLOAT)); rb_define_const(cOCI8TDO, "ATTR_NAMED_TYPE", INT2FIX(ATTR_NAMED_TYPE)); rb_define_const(cOCI8TDO, "ATTR_NAMED_COLLECTION", INT2FIX(ATTR_NAMED_COLLECTION)); + rb_define_const(cOCI8TDO, "ATTR_CLOB", INT2FIX(ATTR_CLOB)); + rb_define_const(cOCI8TDO, "ATTR_NCLOB", INT2FIX(ATTR_NCLOB)); + rb_define_const(cOCI8TDO, "ATTR_BLOB", INT2FIX(ATTR_BLOB)); + rb_define_const(cOCI8TDO, "ATTR_BFILE", INT2FIX(ATTR_BFILE)); #define ALIGNMENT_OF(type) (size_t)&(((struct {char c; type t;}*)0)->t) rb_define_const(cOCI8TDO, "SIZE_OF_POINTER", INT2FIX(sizeof(void *))); rb_define_const(cOCI8TDO, "ALIGNMENT_OF_POINTER", INT2FIX(ALIGNMENT_OF(void *))); Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2010-08-15 05:12:32 UTC (rev 404) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2010-08-15 12:33:14 UTC (rev 405) @@ -471,6 +471,10 @@ VALUE oci8_make_nclob(oci8_svcctx_t *svcctx, OCILobLocator *s); VALUE oci8_make_blob(oci8_svcctx_t *svcctx, OCILobLocator *s); VALUE oci8_make_bfile(oci8_svcctx_t *svcctx, OCILobLocator *s); +void oci8_assign_clob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); +void oci8_assign_nclob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); +void oci8_assign_blob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); +void oci8_assign_bfile(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest); /* oradate.c */ void Init_ora_date(void); Modified: trunk/ruby-oci8/ext/oci8/ocihandle.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocihandle.c 2010-08-15 05:12:32 UTC (rev 404) +++ trunk/ruby-oci8/ext/oci8/ocihandle.c 2010-08-15 12:33:14 UTC (rev 405) @@ -61,6 +61,14 @@ static void oci8_handle_cleanup(oci8_base_t *base) { + if (oci8_in_finalizer) { + /* Do nothing when the program exits. + * The first two words of memory addressed by VALUE datatype is + * changed in finalizer. If a ruby function which access it such + * as rb_obj_is_kind_of is called, it may cause SEGV. + */ + return; + } oci8_base_free(base); xfree(base); } Modified: trunk/ruby-oci8/lib/oci8/object.rb =================================================================== --- trunk/ruby-oci8/lib/oci8/object.rb 2010-08-15 05:12:32 UTC (rev 404) +++ trunk/ruby-oci8/lib/oci8/object.rb 2010-08-15 12:33:14 UTC (rev 405) @@ -457,6 +457,16 @@ #[ATTR_NAMED_COLLECTION, [datatype, typeinfo], SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] tdo = con.get_tdo_by_metadata(metadata.type_metadata) [ATTR_NAMED_COLLECTION, tdo, tdo.val_size, tdo.ind_size, tdo.alignment] + when :clob + if metadata.charset_form != :nchar + [ATTR_CLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] + else + [ATTR_NCLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] + end + when :blob + [ATTR_BLOB, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] + when :bfile + [ATTR_BFILE, con, SIZE_OF_POINTER, 2, ALIGNMENT_OF_POINTER] else raise "unsupported typecode #{metadata.typecode}" end From nobody at rubyforge.org Mon Aug 23 11:33:20 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 23 Aug 2010 11:33:20 -0400 (EDT) Subject: [ruby-oci8-commit] [406] branches/ruby-oci8-2.0: * ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used Message-ID: <20100823153321.15B1D1858368@rubyforge.org> Revision: 406 Author: kubo Date: 2010-08-23 11:33:20 -0400 (Mon, 23 Aug 2010) Log Message: ----------- * ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used and $VERBOSE is set. * ruby-oci8/test/test_oranumber.rb: change a testcase for ruby 1.9.2. Math::atan2(0, 0) behaviour was changed in 1.9.2. Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog branches/ruby-oci8-2.0/lib/oci8/object.rb branches/ruby-oci8-2.0/test/test_oranumber.rb Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-15 12:33:14 UTC (rev 405) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-23 15:33:20 UTC (rev 406) @@ -1,3 +1,9 @@ +2010-08-24 KUBO Takehiro + * ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used + and $VERBOSE is set. + * ruby-oci8/test/test_oranumber.rb: change a testcase for ruby 1.9.2. + Math::atan2(0, 0) behaviour was changed in 1.9.2. + 2010-08-15 KUBO Takehiro * ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h, lib/oci8/object.rb: support LOB datatypes in Oracle objects. Modified: branches/ruby-oci8-2.0/lib/oci8/object.rb =================================================================== --- branches/ruby-oci8-2.0/lib/oci8/object.rb 2010-08-15 12:33:14 UTC (rev 405) +++ branches/ruby-oci8-2.0/lib/oci8/object.rb 2010-08-23 15:33:20 UTC (rev 406) @@ -394,7 +394,7 @@ @class_methods[type_method.name.downcase.intern] = result_type end else - warn "unsupported return type (#{schema_name}.#{name}.#{type_method.name})" if $VERBOSE + warn "unsupported return type (#{metadata.schema_name}.#{metadata.name}.#{type_method.name})" if $VERBOSE end end end Modified: branches/ruby-oci8-2.0/test/test_oranumber.rb =================================================================== --- branches/ruby-oci8-2.0/test/test_oranumber.rb 2010-08-15 12:33:14 UTC (rev 405) +++ branches/ruby-oci8-2.0/test/test_oranumber.rb 2010-08-23 15:33:20 UTC (rev 406) @@ -238,11 +238,28 @@ # OCI8::Math.atan2(y, x) -> ocinumber def test_math_atan2 + # Prior to ruby 1.9.2: + # Following method calls' return values depend on the underneath C library + # implementation. + # + # Math::atan2(+0.0, +0.0) + # Math::atan2(-0.0, +0.0) + # Math::atan2(+0.0, -0.0) + # Math::atan2(-0.0, -0.0) + # + # They are +0.0, -0.0, +PI and -PI respectively as far as I checked them on + # Windows and Linux. + # + # After ruby 1.9.2: + # They all raise a Math::DomainError exception. + # + # In contrast to Math::atan2, OCI8::Math::atan2(0, 0) allways returns 0 because + # OraNumber doesn't have the difference between +0 and -0. compare_with_float2(SMALL_RANGE_VALUES, SMALL_RANGE_VALUES, - Proc.new {|x, y| Math::atan2(x, y.to_f)}, + Proc.new {|x, y| (x.to_f == 0 && y.to_f == 0) ? 0 : Math::atan2(x, y.to_f)}, Proc.new {|x, y| OCI8::Math::atan2(x, y.to_f)}) compare_with_float2(SMALL_RANGE_VALUES, SMALL_RANGE_VALUES, - Proc.new {|x, y| Math::atan2(y.to_f, x)}, + Proc.new {|x, y| (x.to_f == 0 && y.to_f == 0) ? 0 : Math::atan2(y.to_f, x)}, Proc.new {|x, y| OCI8::Math::atan2(y.to_f, x)}) end From nobody at rubyforge.org Mon Aug 23 11:38:14 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 23 Aug 2010 11:38:14 -0400 (EDT) Subject: [ruby-oci8-commit] [407] trunk/ruby-oci8: * lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used Message-ID: <20100823153814.5472C1779943@rubyforge.org> Revision: 407 Author: kubo Date: 2010-08-23 11:38:13 -0400 (Mon, 23 Aug 2010) Log Message: ----------- * lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used and $VERBOSE is set. * test/test_metadata.rb: (1) fix errors caused by String + Symbol. They worked on ruby 1.9.2 but not on 1.8.7 and 1.9.2. (2) replace "assert_equal(class, object.class)" with "assert_instance_of(class, object)." * test/test_oranumber.rb: change a testcase for ruby 1.9.2. Math::atan2(0, 0) behaviour was changed in 1.9.2. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/lib/oci8/object.rb trunk/ruby-oci8/test/test_metadata.rb trunk/ruby-oci8/test/test_oranumber.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2010-08-23 15:33:20 UTC (rev 406) +++ trunk/ruby-oci8/ChangeLog 2010-08-23 15:38:13 UTC (rev 407) @@ -1,3 +1,13 @@ +2010-08-23 KUBO Takehiro + * lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used + and $VERBOSE is set. + * test/test_metadata.rb: (1) fix errors caused by String + Symbol. + They worked on ruby 1.9.2 but not on 1.8.7 and 1.9.2. + (2) replace "assert_equal(class, object.class)" with + "assert_instance_of(class, object)." + * test/test_oranumber.rb: change a testcase for ruby 1.9.2. + Math::atan2(0, 0) behaviour was changed in 1.9.2. + 2010-08-15 KUBO Takehiro * ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h, lib/oci8/object.rb: support LOB datatypes in Oracle objects. Modified: trunk/ruby-oci8/lib/oci8/object.rb =================================================================== --- trunk/ruby-oci8/lib/oci8/object.rb 2010-08-23 15:33:20 UTC (rev 406) +++ trunk/ruby-oci8/lib/oci8/object.rb 2010-08-23 15:38:13 UTC (rev 407) @@ -394,7 +394,7 @@ @class_methods[type_method.name.downcase.intern] = result_type end else - warn "unsupported return type (#{schema_name}.#{name}.#{type_method.name})" if $VERBOSE + warn "unsupported return type (#{metadata.schema_name}.#{metadata.name}.#{type_method.name})" if $VERBOSE end end end Modified: trunk/ruby-oci8/test/test_metadata.rb =================================================================== --- trunk/ruby-oci8/test/test_metadata.rb 2010-08-23 15:33:20 UTC (rev 406) +++ trunk/ruby-oci8/test/test_metadata.rb 2010-08-23 15:38:13 UTC (rev 407) @@ -648,8 +648,8 @@ assert_equal(false, desc.clustered?) assert_equal(false, desc.partitioned?) assert_equal(false, desc.index_only?) - assert_equal(Array, desc.columns.class) - assert_equal(OCI8::Metadata::Column, desc.columns[0].class) + assert_instance_of(Array, desc.columns) + assert_instance_of(OCI8::Metadata::Column, desc.columns[0]) end drop_table('test_table') @@ -677,8 +677,8 @@ assert_equal(false, desc.clustered?) assert_equal(false, desc.partitioned?) assert_equal(false, desc.index_only?) - assert_equal(Array, desc.columns.class) - assert_equal(OCI8::Metadata::Column, desc.columns[0].class) + assert_instance_of(Array, desc.columns) + assert_instance_of(OCI8::Metadata::Column, desc.columns[0]) end drop_table('test_table') @@ -707,8 +707,8 @@ assert_equal(false, desc.clustered?) assert_equal(false, desc.partitioned?) assert_equal(false, desc.index_only?) - assert_equal(Array, desc.columns.class) - assert_equal(OCI8::Metadata::Column, desc.columns[0].class) + assert_instance_of(Array, desc.columns) + assert_instance_of(OCI8::Metadata::Column, desc.columns[0]) end drop_table('test_table') @@ -730,7 +730,7 @@ assert_equal('TEST_TABLE', desc.obj_name) assert_equal(@conn.username, desc.obj_schema) assert_equal(2, desc.num_cols) - assert_equal(OCI8::Metadata::Type, desc.type_metadata.class) + assert_instance_of(OCI8::Metadata::Type, desc.type_metadata) assert_equal(false, desc.is_temporary?) assert_equal(true, desc.is_typed?) assert_equal(nil, desc.duration) @@ -739,8 +739,8 @@ assert_equal(false, desc.clustered?) assert_equal(false, desc.partitioned?) assert_equal(false, desc.index_only?) - assert_equal(Array, desc.columns.class) - assert_equal(OCI8::Metadata::Column, desc.columns[0].class) + assert_instance_of(Array, desc.columns) + assert_instance_of(OCI8::Metadata::Column, desc.columns[0]) end drop_table('test_table') @conn.exec('DROP TYPE TEST_TYPE') @@ -770,8 +770,8 @@ assert_equal(false, desc.clustered?) assert_equal(false, desc.partitioned?) assert_equal(true, desc.index_only?) - assert_equal(Array, desc.columns.class) - assert_equal(OCI8::Metadata::Column, desc.columns[0].class) + assert_instance_of(Array, desc.columns) + assert_instance_of(OCI8::Metadata::Column, desc.columns[0]) end drop_table('test_table') end # test_table_metadata @@ -790,8 +790,8 @@ assert_equal('TEST_VIEW', desc.obj_name) assert_equal(@conn.username, desc.obj_schema) assert_equal(3, desc.num_cols) - assert_equal(Array, desc.columns.class) - assert_equal(OCI8::Metadata::Column, desc.columns[0].class) + assert_instance_of(Array, desc.columns) + assert_instance_of(OCI8::Metadata::Column, desc.columns[0]) end @conn.exec('DROP VIEW test_view') end # test_view_metadata @@ -810,16 +810,16 @@ obj.obj_name == 'TEST_PROC' end ].each do |desc| - assert_equal(OCI8::Metadata::Procedure, desc.class) + assert_instance_of(OCI8::Metadata::Procedure, desc) assert_object_id('TEST_PROC', desc.obj_id) assert_equal('TEST_PROC', desc.obj_name) assert_equal('TEST_PROC', desc.name) assert_equal(@conn.username, desc.obj_schema) assert_equal(false, desc.is_invoker_rights?) assert_equal(nil, desc.overload_id) - assert_equal(Array, desc.arguments.class) + assert_instance_of(Array, desc.arguments) assert_equal(2, desc.arguments.length) - assert_equal(OCI8::Metadata::Argument, desc.arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc.arguments[0]) end @conn.exec(<<-EOS) @@ -837,15 +837,15 @@ obj.obj_name == 'TEST_PROC' end ].each do |desc| - assert_equal(OCI8::Metadata::Procedure, desc.class) + assert_instance_of(OCI8::Metadata::Procedure, desc) assert_object_id('TEST_PROC', desc.obj_id) assert_equal('TEST_PROC', desc.obj_name) assert_equal(@conn.username, desc.obj_schema) assert_equal(true, desc.is_invoker_rights?) assert_equal(nil, desc.overload_id) - assert_equal(Array, desc.arguments.class) + assert_instance_of(Array, desc.arguments) assert_equal(2, desc.arguments.length) - assert_equal(OCI8::Metadata::Argument, desc.arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc.arguments[0]) end @conn.exec('DROP PROCEDURE test_proc'); @@ -856,15 +856,15 @@ END; EOS desc = @conn.describe_package('test_pkg').subprograms[0] - assert_equal(OCI8::Metadata::Procedure, desc.class) + assert_instance_of(OCI8::Metadata::Procedure, desc) assert_equal(nil, desc.obj_id) assert_equal('TEST_PROC', desc.obj_name) assert_equal(nil, desc.obj_schema) assert_equal(false, desc.is_invoker_rights?) assert_equal(0, desc.overload_id) - assert_equal(Array, desc.arguments.class) + assert_instance_of(Array, desc.arguments) assert_equal(2, desc.arguments.length) - assert_equal(OCI8::Metadata::Argument, desc.arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc.arguments[0]) @conn.exec(<<-EOS) CREATE OR REPLACE PACKAGE TEST_PKG AUTHID CURRENT_USER @@ -874,26 +874,26 @@ END; EOS desc = @conn.describe_package('test_pkg').subprograms - assert_equal(OCI8::Metadata::Procedure, desc[0].class) + assert_instance_of(OCI8::Metadata::Procedure, desc[0]) assert_equal(nil, desc[0].obj_id) assert_equal('TEST_PROC', desc[0].obj_name) assert_equal(nil, desc[0].obj_schema) assert_equal(true, desc[0].is_invoker_rights?) assert_equal(2, desc[0].overload_id) - assert_equal(Array, desc[0].arguments.class) + assert_instance_of(Array, desc[0].arguments) assert_equal(2, desc[0].arguments.length) - assert_equal(OCI8::Metadata::Argument, desc[0].arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc[0].arguments[0]) descs = @conn.describe_package('test_pkg').subprograms - assert_equal(OCI8::Metadata::Procedure, desc[1].class) + assert_instance_of(OCI8::Metadata::Procedure, desc[1]) assert_equal(nil, desc[1].obj_id) assert_equal('TEST_PROC', desc[1].obj_name) assert_equal(nil, desc[1].obj_schema) assert_equal(true, desc[1].is_invoker_rights?) assert_equal(1, desc[1].overload_id) - assert_equal(Array, desc[1].arguments.class) + assert_instance_of(Array, desc[1].arguments) assert_equal(1, desc[1].arguments.length) - assert_equal(OCI8::Metadata::Argument, desc[1].arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc[1].arguments[0]) end # test_procedure_metadata def test_function_metadata @@ -910,16 +910,16 @@ obj.obj_name == 'TEST_FUNC' end ].each do |desc| - assert_equal(OCI8::Metadata::Function, desc.class) + assert_instance_of(OCI8::Metadata::Function, desc) assert_object_id('TEST_FUNC', desc.obj_id) assert_equal('TEST_FUNC', desc.obj_name) assert_equal('TEST_FUNC', desc.name) assert_equal(@conn.username, desc.obj_schema) assert_equal(false, desc.is_invoker_rights?) assert_equal(nil, desc.overload_id) - assert_equal(Array, desc.arguments.class) + assert_instance_of(Array, desc.arguments) assert_equal(3, desc.arguments.length) - assert_equal(OCI8::Metadata::Argument, desc.arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc.arguments[0]) end @conn.exec(<<-EOS) @@ -937,15 +937,15 @@ obj.obj_name == 'TEST_FUNC' end ].each do |desc| - assert_equal(OCI8::Metadata::Function, desc.class) + assert_instance_of(OCI8::Metadata::Function, desc) assert_object_id('TEST_FUNC', desc.obj_id) assert_equal('TEST_FUNC', desc.obj_name) assert_equal(@conn.username, desc.obj_schema) assert_equal(true, desc.is_invoker_rights?) assert_equal(nil, desc.overload_id) - assert_equal(Array, desc.arguments.class) + assert_instance_of(Array, desc.arguments) assert_equal(3, desc.arguments.length) - assert_equal(OCI8::Metadata::Argument, desc.arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc.arguments[0]) end @conn.exec('DROP FUNCTION test_func'); @@ -956,15 +956,15 @@ END; EOS desc = @conn.describe_package('test_pkg').subprograms[0] - assert_equal(OCI8::Metadata::Function, desc.class) + assert_instance_of(OCI8::Metadata::Function, desc) assert_equal(nil, desc.obj_id) assert_equal('TEST_FUNC', desc.obj_name) assert_equal(nil, desc.obj_schema) assert_equal(false, desc.is_invoker_rights?) assert_equal(0, desc.overload_id) - assert_equal(Array, desc.arguments.class) + assert_instance_of(Array, desc.arguments) assert_equal(3, desc.arguments.length) - assert_equal(OCI8::Metadata::Argument, desc.arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc.arguments[0]) @conn.exec(<<-EOS) CREATE OR REPLACE PACKAGE TEST_PKG AUTHID CURRENT_USER @@ -974,26 +974,26 @@ END; EOS desc = @conn.describe_package('test_pkg').subprograms - assert_equal(OCI8::Metadata::Function, desc[0].class) + assert_instance_of(OCI8::Metadata::Function, desc[0]) assert_equal(nil, desc[0].obj_id) assert_equal('TEST_FUNC', desc[0].obj_name) assert_equal(nil, desc[0].obj_schema) assert_equal(true, desc[0].is_invoker_rights?) assert_equal(2, desc[0].overload_id) - assert_equal(Array, desc[0].arguments.class) + assert_instance_of(Array, desc[0].arguments) assert_equal(3, desc[0].arguments.length) - assert_equal(OCI8::Metadata::Argument, desc[0].arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc[0].arguments[0]) descs = @conn.describe_package('test_pkg').subprograms - assert_equal(OCI8::Metadata::Function, desc[1].class) + assert_instance_of(OCI8::Metadata::Function, desc[1]) assert_equal(nil, desc[1].obj_id) assert_equal('TEST_FUNC', desc[1].obj_name) assert_equal(nil, desc[1].obj_schema) assert_equal(true, desc[1].is_invoker_rights?) assert_equal(1, desc[1].overload_id) - assert_equal(Array, desc[1].arguments.class) + assert_instance_of(Array, desc[1].arguments) assert_equal(2, desc[1].arguments.length) - assert_equal(OCI8::Metadata::Argument, desc[1].arguments[0].class) + assert_instance_of(OCI8::Metadata::Argument, desc[1].arguments[0]) end # test_function_metadata def test_package_metadata @@ -1009,14 +1009,14 @@ obj.obj_name == 'TEST_PKG' end ].each do |desc| - assert_equal(OCI8::Metadata::Package, desc.class) + assert_instance_of(OCI8::Metadata::Package, desc) assert_object_id('TEST_PKG', desc.obj_id) assert_equal('TEST_PKG', desc.obj_name) assert_equal(@conn.username, desc.obj_schema) assert_equal(false, desc.is_invoker_rights?) - assert_equal(Array, desc.subprograms.class) + assert_instance_of(Array, desc.subprograms) assert_equal(1, desc.subprograms.length) - assert_equal(OCI8::Metadata::Function, desc.subprograms[0].class) + assert_instance_of(OCI8::Metadata::Function, desc.subprograms[0]) end @conn.exec(<<-EOS) @@ -1031,14 +1031,14 @@ obj.obj_name == 'TEST_PKG' end ].each do |desc| - assert_equal(OCI8::Metadata::Package, desc.class) + assert_instance_of(OCI8::Metadata::Package, desc) assert_object_id('TEST_PKG', desc.obj_id) assert_equal('TEST_PKG', desc.obj_name) assert_equal(@conn.username, desc.obj_schema) assert_equal(true, desc.is_invoker_rights?) - assert_equal(Array, desc.subprograms.class) + assert_instance_of(Array, desc.subprograms) assert_equal(1, desc.subprograms.length) - assert_equal(OCI8::Metadata::Procedure, desc.subprograms[0].class) + assert_instance_of(OCI8::Metadata::Procedure, desc.subprograms[0]) end end # test_package_metadata @@ -1314,19 +1314,20 @@ assert_equal(@conn.username, desc.schema_name) elem.each do |key, val| + msg = elem[:obj_name] + '.' + key.to_s if val.is_a? Array case val[0] when :array - assert_equal(Array, desc.send(key).class, elem[:obj_name] + '.' + key) + assert_instance_of(Array, desc.send(key), msg) assert_equal(val[1], desc.send(key).length) - assert_equal(val[2], desc.send(key)[0].class) if val[1] > 0 + assert_instance_of(val[2], desc.send(key)[0]) if val[1] > 0 when :type - assert_equal(val[1], desc.send(key).class, elem[:obj_name] + '.' + key) + assert_instance_of(val[1], desc.send(key), msg) else raise "Invalid test case: #{elem[:obj_name]}.#{key} : #{val[0]}" end else - assert_equal(val, desc.send(key), elem[:obj_name] + '.' + key) + assert_equal(val, desc.send(key), msg) end end end Modified: trunk/ruby-oci8/test/test_oranumber.rb =================================================================== --- trunk/ruby-oci8/test/test_oranumber.rb 2010-08-23 15:33:20 UTC (rev 406) +++ trunk/ruby-oci8/test/test_oranumber.rb 2010-08-23 15:38:13 UTC (rev 407) @@ -238,11 +238,28 @@ # OCI8::Math.atan2(y, x) -> ocinumber def test_math_atan2 + # Prior to ruby 1.9.2: + # Following method calls' return values depend on the underneath C library + # implementation. + # + # Math::atan2(+0.0, +0.0) + # Math::atan2(-0.0, +0.0) + # Math::atan2(+0.0, -0.0) + # Math::atan2(-0.0, -0.0) + # + # They are +0.0, -0.0, +PI and -PI respectively as far as I checked them on + # Windows and Linux. + # + # After ruby 1.9.2: + # They all raise a Math::DomainError exception. + # + # In contrast to Math::atan2, OCI8::Math::atan2(0, 0) allways returns 0 because + # OraNumber doesn't have the difference between +0 and -0. compare_with_float2(SMALL_RANGE_VALUES, SMALL_RANGE_VALUES, - Proc.new {|x, y| Math::atan2(x, y.to_f)}, + Proc.new {|x, y| (x.to_f == 0 && y.to_f == 0) ? 0 : Math::atan2(x, y.to_f)}, Proc.new {|x, y| OCI8::Math::atan2(x, y.to_f)}) compare_with_float2(SMALL_RANGE_VALUES, SMALL_RANGE_VALUES, - Proc.new {|x, y| Math::atan2(y.to_f, x)}, + Proc.new {|x, y| (x.to_f == 0 && y.to_f == 0) ? 0 : Math::atan2(y.to_f, x)}, Proc.new {|x, y| OCI8::Math::atan2(y.to_f, x)}) end From nobody at rubyforge.org Mon Aug 23 11:39:13 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 23 Aug 2010 11:39:13 -0400 (EDT) Subject: [ruby-oci8-commit] [408] branches/ruby-oci8-2.0/ChangeLog: fix typo. Message-ID: <20100823153913.72FCA1858363@rubyforge.org> Revision: 408 Author: kubo Date: 2010-08-23 11:39:13 -0400 (Mon, 23 Aug 2010) Log Message: ----------- fix typo. Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-23 15:38:13 UTC (rev 407) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-23 15:39:13 UTC (rev 408) @@ -1,7 +1,7 @@ -2010-08-24 KUBO Takehiro - * ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used +2010-08-23 KUBO Takehiro + * lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used and $VERBOSE is set. - * ruby-oci8/test/test_oranumber.rb: change a testcase for ruby 1.9.2. + * test/test_oranumber.rb: change a testcase for ruby 1.9.2. Math::atan2(0, 0) behaviour was changed in 1.9.2. 2010-08-15 KUBO Takehiro From nobody at rubyforge.org Sat Aug 28 05:02:01 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 28 Aug 2010 05:02:01 -0400 (EDT) Subject: [ruby-oci8-commit] [409] trunk/ruby-oci8/ext/oci8: * ext/oci8/env.c, ext/oci8/error.c, ext/ oci8/extconf.rb, ext/oci8/oci8.c, Message-ID: <20100828090202.02C471858383@rubyforge.org> Revision: 409 Author: kubo Date: 2010-08-28 05:02:01 -0400 (Sat, 28 Aug 2010) Log Message: ----------- * ext/oci8/env.c, ext/oci8/error.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h, oci8/oci8lib.c, ext/oci8/ocinumber.c: fix for rubinius. Note that this is not enough to compile ruby-oci8 on it. Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog branches/ruby-oci8-2.0/ext/oci8/env.c branches/ruby-oci8-2.0/ext/oci8/error.c branches/ruby-oci8-2.0/ext/oci8/extconf.rb branches/ruby-oci8-2.0/ext/oci8/oci8.c branches/ruby-oci8-2.0/ext/oci8/oci8.h branches/ruby-oci8-2.0/ext/oci8/oci8lib.c branches/ruby-oci8-2.0/ext/oci8/ocinumber.c trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/env.c trunk/ruby-oci8/ext/oci8/error.c trunk/ruby-oci8/ext/oci8/extconf.rb trunk/ruby-oci8/ext/oci8/oci8.c trunk/ruby-oci8/ext/oci8/oci8.h trunk/ruby-oci8/ext/oci8/oci8lib.c trunk/ruby-oci8/ext/oci8/ocinumber.c Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-28 09:02:01 UTC (rev 409) @@ -1,3 +1,8 @@ +2010-08-28 KUBO Takehiro + * ext/oci8/env.c, ext/oci8/error.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, + ext/oci8/oci8.h, oci8/oci8lib.c, ext/oci8/ocinumber.c: fix for rubinius. + Note that this is not enough to compile ruby-oci8 on it. + 2010-08-23 KUBO Takehiro * lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used and $VERBOSE is set. Modified: branches/ruby-oci8-2.0/ext/oci8/env.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/env.c 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/env.c 2010-08-28 09:02:01 UTC (rev 409) @@ -6,7 +6,7 @@ */ #include "oci8.h" -#if !defined(RUBY_VM) +#if defined(HAVE_UTIL_H) /* ruby_setenv for workaround ruby 1.8.4 */ #include #endif Modified: branches/ruby-oci8-2.0/ext/oci8/error.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/error.c 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/error.c 2010-08-28 09:02:01 UTC (rev 409) @@ -10,6 +10,10 @@ */ #include "oci8.h" +#ifndef DLEXT +#define DLEXT ".so" +#endif + /* Exception */ VALUE eOCIException; VALUE eOCIBreak; Modified: branches/ruby-oci8-2.0/ext/oci8/extconf.rb =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/extconf.rb 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/extconf.rb 2010-08-28 09:02:01 UTC (rev 409) @@ -111,6 +111,8 @@ have_var("ruby_errinfo", "ruby.h") # ruby 1.8 have_func("rb_errinfo", "ruby.h") # ruby 1.9 +have_type("rb_blocking_function_t", "ruby.h") + # replace files replace = { 'OCI8_CLIENT_VERSION' => oraconf.version, Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/oci8.c 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/oci8.c 2010-08-28 09:02:01 UTC (rev 409) @@ -313,7 +313,7 @@ } svcctx->pid = getpid(); svcctx->is_autocommit = 0; -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T svcctx->non_blocking = 1; #endif svcctx->long_read_len = INT2FIX(65535); @@ -417,7 +417,7 @@ static VALUE oci8_non_blocking_p(VALUE self) { oci8_svcctx_t *svcctx = DATA_PTR(self); -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T return svcctx->non_blocking ? Qtrue : Qfalse; #else sb1 non_blocking; @@ -470,7 +470,7 @@ static VALUE oci8_set_non_blocking(VALUE self, VALUE val) { oci8_svcctx_t *svcctx = DATA_PTR(self); -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T svcctx->non_blocking = RTEST(val); #else sb1 non_blocking; @@ -560,14 +560,14 @@ static VALUE oci8_break(VALUE self) { oci8_svcctx_t *svcctx = DATA_PTR(self); -#ifndef RUBY_VM +#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T sword rv; #endif if (NIL_P(svcctx->executing_thread)) { return Qfalse; } -#ifndef RUBY_VM +#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T rv = OCIBreak(svcctx->base.hp.ptr, oci8_errhp); if (rv != OCI_SUCCESS) oci8_raise(oci8_errhp, rv, NULL); Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.h =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/oci8.h 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/oci8.h 2010-08-28 09:02:01 UTC (rev 409) @@ -135,7 +135,7 @@ #if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO) #define rb_errinfo() ruby_errinfo #endif -#ifndef RUBY_VM +#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T typedef VALUE rb_blocking_function_t(void *); #endif @@ -185,7 +185,7 @@ * set a value to the key. * */ -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T /* ruby 1.9 */ #if defined(_WIN32) #include @@ -195,16 +195,14 @@ (*(key_p) == 0xFFFFFFFF) ? GetLastError() : 0) #define oci8_tls_get(key) TlsGetValue(key) #define oci8_tls_set(key, val) TlsSetValue((key), (val)) -#elif defined(HAVE_PTHREAD_H) +#else #include #define oci8_tls_key_t pthread_key_t #define oci8_tls_key_init(key_p) pthread_key_create((key_p), NULL) #define oci8_tls_get(key) pthread_getspecific(key) #define oci8_tls_set(key, val) pthread_setspecific((key), (val)) -#else -#error unsupported thread API #endif -#endif /* RUBY_VM */ +#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */ /* utility macros */ @@ -310,7 +308,7 @@ OCIServer *srvhp; rb_pid_t pid; char is_autocommit; -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T char non_blocking; #endif VALUE long_read_len; @@ -364,7 +362,7 @@ * extern OCIError *oci8_errhp; */ #define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp()) -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T #define oci8_errhp oci8_get_errhp() #else #define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp()) @@ -374,7 +372,7 @@ extern ub4 oci8_env_mode; extern OCIEnv *oci8_global_envhp; OCIEnv *oci8_make_envhp(void); -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T extern oci8_tls_key_t oci8_tls_key; /* native thread key */ OCIError *oci8_make_errhp(void); Modified: branches/ruby-oci8-2.0/ext/oci8/oci8lib.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/oci8lib.c 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/oci8lib.c 2010-08-28 09:02:01 UTC (rev 409) @@ -196,7 +196,7 @@ base->parent = NULL; } -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T #if 0 typedef struct { @@ -251,7 +251,7 @@ return (sword)func(data); } } -#else /* RUBY_VM */ +#else /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */ /* ruby 1.8 */ sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data) @@ -281,7 +281,7 @@ svcctx->executing_thread = Qnil; return rv; } -#endif /* RUBY_VM */ +#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */ typedef struct { oci8_svcctx_t *svcctx; Modified: branches/ruby-oci8-2.0/ext/oci8/ocinumber.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/ocinumber.c 2010-08-23 15:39:13 UTC (rev 408) +++ branches/ruby-oci8-2.0/ext/oci8/ocinumber.c 2010-08-28 09:02:01 UTC (rev 409) @@ -10,7 +10,7 @@ #include #include "oranumber_util.h" -#ifndef RUBY_VM +#ifndef RB_NUM_COERCE_FUNCS_NEED_OPID /* ruby 1.8 */ #define rb_num_coerce_cmp(x, y, id) rb_num_coerce_cmp((x), (y)) #define rb_num_coerce_bin(x, y, id) rb_num_coerce_bin((x), (y)) @@ -39,6 +39,9 @@ #define _NUMBER(val) ((OCINumber *)DATA_PTR(val)) /* dangerous macro */ +#ifndef T_MASK +#define T_MASK 0x100 /* TODO: rboci8_type() should be changed to be more portable. */ +#endif #define RBOCI8_T_ORANUMBER (T_MASK + 1) #define RBOCI8_T_BIGDECIMAL (T_MASK + 2) #ifdef T_RATIONAL Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ChangeLog 2010-08-28 09:02:01 UTC (rev 409) @@ -1,3 +1,8 @@ +2010-08-28 KUBO Takehiro + * ext/oci8/env.c, ext/oci8/error.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, + ext/oci8/oci8.h, oci8/oci8lib.c, ext/oci8/ocinumber.c: fix for rubinius. + Note that this is not enough to compile ruby-oci8 on it. + 2010-08-23 KUBO Takehiro * lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used and $VERBOSE is set. Modified: trunk/ruby-oci8/ext/oci8/env.c =================================================================== --- trunk/ruby-oci8/ext/oci8/env.c 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/env.c 2010-08-28 09:02:01 UTC (rev 409) @@ -6,7 +6,7 @@ */ #include "oci8.h" -#if !defined(RUBY_VM) +#if defined(HAVE_UTIL_H) /* ruby_setenv for workaround ruby 1.8.4 */ #include #endif Modified: trunk/ruby-oci8/ext/oci8/error.c =================================================================== --- trunk/ruby-oci8/ext/oci8/error.c 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/error.c 2010-08-28 09:02:01 UTC (rev 409) @@ -10,6 +10,10 @@ */ #include "oci8.h" +#ifndef DLEXT +#define DLEXT ".so" +#endif + /* Exception */ VALUE eOCIException; VALUE eOCIBreak; Modified: trunk/ruby-oci8/ext/oci8/extconf.rb =================================================================== --- trunk/ruby-oci8/ext/oci8/extconf.rb 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/extconf.rb 2010-08-28 09:02:01 UTC (rev 409) @@ -113,6 +113,8 @@ have_var("ruby_errinfo", "ruby.h") # ruby 1.8 have_func("rb_errinfo", "ruby.h") # ruby 1.9 +have_type("rb_blocking_function_t", "ruby.h") + # replace files replace = { 'OCI8_CLIENT_VERSION' => oraconf.version, Modified: trunk/ruby-oci8/ext/oci8/oci8.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.c 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/oci8.c 2010-08-28 09:02:01 UTC (rev 409) @@ -70,7 +70,7 @@ svcctx->server = DATA_PTR(rb_obj_alloc(oci8_cOCIHandle)); svcctx->pid = getpid(); svcctx->is_autocommit = 0; -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T svcctx->non_blocking = 1; #endif svcctx->long_read_len = INT2FIX(65535); @@ -448,7 +448,7 @@ static VALUE oci8_non_blocking_p(VALUE self) { oci8_svcctx_t *svcctx = DATA_PTR(self); -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T return svcctx->non_blocking ? Qtrue : Qfalse; #else sb1 non_blocking; @@ -501,7 +501,7 @@ static VALUE oci8_set_non_blocking(VALUE self, VALUE val) { oci8_svcctx_t *svcctx = DATA_PTR(self); -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T svcctx->non_blocking = RTEST(val); #else sb1 non_blocking; @@ -591,14 +591,14 @@ static VALUE oci8_break(VALUE self) { oci8_svcctx_t *svcctx = DATA_PTR(self); -#ifndef RUBY_VM +#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T sword rv; #endif if (NIL_P(svcctx->executing_thread)) { return Qfalse; } -#ifndef RUBY_VM +#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T rv = OCIBreak(svcctx->base.hp.ptr, oci8_errhp); if (rv != OCI_SUCCESS) oci8_raise(oci8_errhp, rv, NULL); Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2010-08-28 09:02:01 UTC (rev 409) @@ -138,7 +138,7 @@ #if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO) #define rb_errinfo() ruby_errinfo #endif -#ifndef RUBY_VM +#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T typedef VALUE rb_blocking_function_t(void *); #endif @@ -188,7 +188,7 @@ * set a value to the key. * */ -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T /* ruby 1.9 */ #if defined(_WIN32) #include @@ -198,16 +198,14 @@ (*(key_p) == 0xFFFFFFFF) ? GetLastError() : 0) #define oci8_tls_get(key) TlsGetValue(key) #define oci8_tls_set(key, val) TlsSetValue((key), (val)) -#elif defined(HAVE_PTHREAD_H) +#else #include #define oci8_tls_key_t pthread_key_t #define oci8_tls_key_init(key_p) pthread_key_create((key_p), NULL) #define oci8_tls_get(key) pthread_getspecific(key) #define oci8_tls_set(key, val) pthread_setspecific((key), (val)) -#else -#error unsupported thread API #endif -#endif /* RUBY_VM */ +#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */ /* utility macros */ @@ -317,7 +315,7 @@ rb_pid_t pid; unsigned char state; char is_autocommit; -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T char non_blocking; #endif VALUE long_read_len; @@ -371,7 +369,7 @@ * extern OCIError *oci8_errhp; */ #define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp()) -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T #define oci8_errhp oci8_get_errhp() #else #define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp()) @@ -381,7 +379,7 @@ extern ub4 oci8_env_mode; extern OCIEnv *oci8_global_envhp; OCIEnv *oci8_make_envhp(void); -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T extern oci8_tls_key_t oci8_tls_key; /* native thread key */ OCIError *oci8_make_errhp(void); Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8lib.c 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/oci8lib.c 2010-08-28 09:02:01 UTC (rev 409) @@ -200,7 +200,7 @@ base->parent = NULL; } -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T #if 0 typedef struct { @@ -255,7 +255,7 @@ return (sword)func(data); } } -#else /* RUBY_VM */ +#else /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */ /* ruby 1.8 */ sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data) @@ -285,7 +285,7 @@ svcctx->executing_thread = Qnil; return rv; } -#endif /* RUBY_VM */ +#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */ typedef struct { oci8_svcctx_t *svcctx; Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocinumber.c 2010-08-23 15:39:13 UTC (rev 408) +++ trunk/ruby-oci8/ext/oci8/ocinumber.c 2010-08-28 09:02:01 UTC (rev 409) @@ -10,7 +10,7 @@ #include #include "oranumber_util.h" -#ifndef RUBY_VM +#ifndef RB_NUM_COERCE_FUNCS_NEED_OPID /* ruby 1.8 */ #define rb_num_coerce_cmp(x, y, id) rb_num_coerce_cmp((x), (y)) #define rb_num_coerce_bin(x, y, id) rb_num_coerce_bin((x), (y)) @@ -39,6 +39,9 @@ #define _NUMBER(val) ((OCINumber *)DATA_PTR(val)) /* dangerous macro */ +#ifndef T_MASK +#define T_MASK 0x100 /* TODO: rboci8_type() should be changed to be more portable. */ +#endif #define RBOCI8_T_ORANUMBER (T_MASK + 1) #define RBOCI8_T_BIGDECIMAL (T_MASK + 2) #ifdef T_RATIONAL From nobody at rubyforge.org Sat Aug 28 05:26:45 2010 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 28 Aug 2010 05:26:45 -0400 (EDT) Subject: [ruby-oci8-commit] [410] trunk/ruby-oci8/ext/oci8: * ext/oci8/env.c: fix for rubinius. Message-ID: <20100828092646.24EA419783B9@rubyforge.org> Revision: 410 Author: kubo Date: 2010-08-28 05:26:45 -0400 (Sat, 28 Aug 2010) Log Message: ----------- * ext/oci8/env.c: fix for rubinius. Modified Paths: -------------- branches/ruby-oci8-2.0/ChangeLog branches/ruby-oci8-2.0/ext/oci8/env.c trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/env.c Modified: branches/ruby-oci8-2.0/ChangeLog =================================================================== --- branches/ruby-oci8-2.0/ChangeLog 2010-08-28 09:02:01 UTC (rev 409) +++ branches/ruby-oci8-2.0/ChangeLog 2010-08-28 09:26:45 UTC (rev 410) @@ -1,4 +1,7 @@ 2010-08-28 KUBO Takehiro + * ext/oci8/env.c: fix for rubinius. + +2010-08-28 KUBO Takehiro * ext/oci8/env.c, ext/oci8/error.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h, oci8/oci8lib.c, ext/oci8/ocinumber.c: fix for rubinius. Note that this is not enough to compile ruby-oci8 on it. Modified: branches/ruby-oci8-2.0/ext/oci8/env.c =================================================================== --- branches/ruby-oci8-2.0/ext/oci8/env.c 2010-08-28 09:02:01 UTC (rev 409) +++ branches/ruby-oci8-2.0/ext/oci8/env.c 2010-08-28 09:26:45 UTC (rev 410) @@ -23,7 +23,7 @@ #include #endif -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T ub4 oci8_env_mode = OCI_OBJECT | OCI_THREADED; #else ub4 oci8_env_mode = OCI_OBJECT; @@ -42,7 +42,7 @@ return oci8_global_envhp; } -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T /* * oci8_errhp is a thread local object in ruby 1.9. */ @@ -97,11 +97,11 @@ void Init_oci8_env(void) { -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T int error; #endif -#if !defined(RUBY_VM) && !defined(_WIN32) +#if !defined(HAVE_TYPE_RB_BLOCKING_FUNCTION_T) && !defined(_WIN32) /* workaround code. * * Some instant clients set the environment variables @@ -147,7 +147,7 @@ } } -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T id_thread_key = rb_intern("__oci8_errhp__"); error = oci8_tls_key_init(&oci8_tls_key); if (error != 0) { Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2010-08-28 09:02:01 UTC (rev 409) +++ trunk/ruby-oci8/ChangeLog 2010-08-28 09:26:45 UTC (rev 410) @@ -1,4 +1,7 @@ 2010-08-28 KUBO Takehiro + * ext/oci8/env.c: fix for rubinius. + +2010-08-28 KUBO Takehiro * ext/oci8/env.c, ext/oci8/error.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h, oci8/oci8lib.c, ext/oci8/ocinumber.c: fix for rubinius. Note that this is not enough to compile ruby-oci8 on it. Modified: trunk/ruby-oci8/ext/oci8/env.c =================================================================== --- trunk/ruby-oci8/ext/oci8/env.c 2010-08-28 09:02:01 UTC (rev 409) +++ trunk/ruby-oci8/ext/oci8/env.c 2010-08-28 09:26:45 UTC (rev 410) @@ -23,7 +23,7 @@ #include #endif -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T ub4 oci8_env_mode = OCI_OBJECT | OCI_THREADED; #else ub4 oci8_env_mode = OCI_OBJECT; @@ -42,7 +42,7 @@ return oci8_global_envhp; } -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T /* * oci8_errhp is a thread local object in ruby 1.9. */ @@ -97,11 +97,11 @@ void Init_oci8_env(void) { -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T int error; #endif -#if !defined(RUBY_VM) && !defined(_WIN32) +#if !defined(HAVE_TYPE_RB_BLOCKING_FUNCTION_T) && !defined(_WIN32) /* workaround code. * * Some instant clients set the environment variables @@ -147,7 +147,7 @@ } } -#ifdef RUBY_VM +#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T id_thread_key = rb_intern("__oci8_errhp__"); error = oci8_tls_key_init(&oci8_tls_key); if (error != 0) {