[ruby-oci8-commit] [275] trunk/ruby-oci8: * ext/oci8/attr.c: If ORA-01000 ( maximum open cursors exceeded) when

nobody at rubyforge.org nobody at rubyforge.org
Mon Aug 4 10:13:57 EDT 2008


Revision: 275
Author:   kubo
Date:     2008-08-04 10:13:56 -0400 (Mon, 04 Aug 2008)

Log Message:
-----------
* ext/oci8/attr.c: If ORA-01000 (maximum open cursors exceeded) when
    converting a rowid descriptor to string representation, run
    GC to cleanup unreferenced statement handles and try again.
* ext/oci8/oci8.h, ext/oci8/oci8lib.c: add a utility function
    oci8_exec_sql() to execute a SQL statement in C.
* ext/oci8/encoding.c: use oci8_exec_sql() to run anonymous PL/SQL
    blocks in oci8_charset_id2name() and oci8_charset_name2id().
* ext/oci8/bind.c, ext/oci8/metadata.c, ext/oci8/ocidatetime.c,
  ext/oci8/ocinumber.c: suppress compiler warnings.
* ext/oci8/oci8.c: avoid "[BUG] object allocation during garbage
    collection phase" when using ruby 1.9. In GC, just free a
    session handle without rollback.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/attr.c
    trunk/ruby-oci8/ext/oci8/bind.c
    trunk/ruby-oci8/ext/oci8/encoding.c
    trunk/ruby-oci8/ext/oci8/metadata.c
    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/ocidatetime.c
    trunk/ruby-oci8/ext/oci8/ocinumber.c

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ChangeLog	2008-08-04 14:13:56 UTC (rev 275)
@@ -1,3 +1,17 @@
+2008-08-04  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/attr.c: If ORA-01000 (maximum open cursors exceeded) when
+	    converting a rowid descriptor to string representation, run
+	    GC to cleanup unreferenced statement handles and try again.
+	* ext/oci8/oci8.h, ext/oci8/oci8lib.c: add a utility function
+	    oci8_exec_sql() to execute a SQL statement in C.
+	* ext/oci8/encoding.c: use oci8_exec_sql() to run anonymous PL/SQL
+	    blocks in oci8_charset_id2name() and oci8_charset_name2id().
+	* ext/oci8/bind.c, ext/oci8/metadata.c, ext/oci8/ocidatetime.c,
+	  ext/oci8/ocinumber.c: suppress compiler warnings.
+	* ext/oci8/oci8.c: avoid "[BUG] object allocation during garbage
+	    collection phase" when using ruby 1.9. In GC, just free a
+	    session handle without rollback.
+
 2008-08-02  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/oci8.h, ext/oci8/ocidatetime.c, lib/oci8.rb.in,
 	  lib/oci8/datetime.rb: change binding code for timestamps

Modified: trunk/ruby-oci8/ext/oci8/attr.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/attr.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/attr.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -136,7 +136,17 @@
         oci_lc(OCIStmtPrepare(arg->stmtp, oci8_errhp, (text*)ROWIDTOCHAR_SQL, strlen(ROWIDTOCHAR_SQL), OCI_NTV_SYNTAX, OCI_DEFAULT));
         oci_lc(OCIBindByPos(arg->stmtp, &bind1, oci8_errhp, 1, buf, MAX_ROWID_LEN, SQLT_STR, NULL, &buflen, 0, 0, 0, OCI_DEFAULT));
         oci_lc(OCIBindByPos(arg->stmtp, &bind2, oci8_errhp, 2, (dvoid*)&arg->ridp, sizeof(void*), SQLT_RDD, NULL, NULL, 0, 0, 0, OCI_DEFAULT));
-        oci_lc(OCIStmtExecute_nb((oci8_svcctx_t*)svc, svc->hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT));
+        rv = OCIStmtExecute_nb((oci8_svcctx_t*)svc, svc->hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT);
+        if (rv == OCI_ERROR) {
+            if (oci8_get_error_code(oci8_errhp) == 1000) {
+                /* run GC to close unreferred cursors
+                 * when ORA-01000 (maximum open cursors exceeded).
+                 */
+                rb_gc();
+                rv = OCIStmtExecute_nb((oci8_svcctx_t*)svc, svc->hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT);
+            }
+        }
+        oci_lc(rv);
     }
     return rb_str_new(buf, buflen);
 }

Modified: trunk/ruby-oci8/ext/oci8/bind.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/bind.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/bind.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -29,7 +29,7 @@
 
     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 - 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);

Modified: trunk/ruby-oci8/ext/oci8/encoding.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/encoding.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/encoding.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -24,15 +24,12 @@
 /* Oracle charset id -> Oracle charset name */
 static VALUE csid2name;
 VALUE oci8_charset_id2name(VALUE svc, VALUE csid);
-static VALUE charset_id2name_func(cb_arg_t *arg);
-static VALUE ensure_func(cb_arg_t *arg);
 
 #ifdef HAVE_TYPE_RB_ENCODING
 /* Oracle charset name -> Oracle charset id */
 static ID id_upcase;
 static VALUE csname2id;
 static VALUE oci8_charset_name2id(VALUE svc, VALUE name);
-static VALUE charset_name2id_func(cb_arg_t *arg);
 #endif /* HAVE_TYPE_RB_ENCODING */
 
 VALUE oci8_charset_id2name(VALUE svc, VALUE csid)
@@ -55,14 +52,30 @@
         name = rb_str_new2(buf);
     } else {
         /* Oracle 9iR1 or lower */
-        cb_arg_t arg;
-        arg.svcctx = oci8_get_svcctx(svc);
-        arg.stmtp = NULL;
-        arg.u.csid = FIX2INT(csid);
-        name = rb_ensure(charset_id2name_func, (VALUE)&arg, ensure_func, (VALUE)&arg);
-        if (NIL_P(name)) {
+        oci8_exec_sql_var_t bind_vars[2];
+        char buf[OCI_NLS_MAXBUFSZ];
+        ub2 buflen = 0;
+        int ival = FIX2INT(csid);
+
+        /* :name */
+        bind_vars[0].valuep = buf;
+        bind_vars[0].value_sz = OCI_NLS_MAXBUFSZ;
+        bind_vars[0].dty = SQLT_CHR;
+        bind_vars[0].indp = NULL;
+        bind_vars[0].alenp = &buflen;
+        /* :csid */
+        bind_vars[1].valuep = &ival;
+        bind_vars[1].value_sz = sizeof(int);
+        bind_vars[1].dty = SQLT_INT;
+        bind_vars[1].indp = NULL;
+        bind_vars[1].alenp = NULL;
+
+        /* convert chaset id to charset name by querying Oracle server. */
+        oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :name := nls_charset_name(:csid); END;", 0, NULL, 2, bind_vars, 1);
+        if (buflen == 0) {
             return Qnil;
         }
+        name = rb_str_new(buf, buflen);
     }
     OBJ_FREEZE(name);
     rb_hash_aset(csid2name, csid, name);
@@ -72,38 +85,6 @@
     return name;
 }
 
-/* convert chaset id to charset name by querying Oracle server.
- * This routine is used only when the Oracle client version is 9iR1 or lower.
- */
-static VALUE charset_id2name_func(cb_arg_t *arg)
-{
-    char buf[OCI_NLS_MAXBUFSZ];
-    ub2 buflen;
-    OCIBind *bind1 = NULL;
-    OCIBind *bind2 = NULL;
-    sword rv;
-    const char *sql = "BEGIN :name := nls_charset_name(:csid); END;";
-
-    buflen = 0;
-    rv = OCIHandleAlloc(oci8_envhp, (dvoid*)&arg->stmtp, OCI_HTYPE_STMT, 0, NULL);
-    if (rv != OCI_SUCCESS) {
-        oci8_env_raise(oci8_envhp, rv);
-    }
-    oci_lc(OCIStmtPrepare(arg->stmtp, oci8_errhp, (text*)sql, strlen(sql), OCI_NTV_SYNTAX, OCI_DEFAULT));
-    oci_lc(OCIBindByPos(arg->stmtp, &bind1, oci8_errhp, 1, buf, OCI_NLS_MAXBUFSZ, SQLT_CHR, NULL, &buflen, 0, 0, 0, OCI_DEFAULT));
-    oci_lc(OCIBindByPos(arg->stmtp, &bind2, oci8_errhp, 2, (dvoid*)&arg->u.csid, sizeof(int), SQLT_INT, NULL, NULL, 0, 0, 0, OCI_DEFAULT));
-    oci_lc(OCIStmtExecute_nb(arg->svcctx, arg->svcctx->base.hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT));
-    return rb_str_new(buf, buflen);
-}
-
-static VALUE ensure_func(cb_arg_t *arg)
-{
-    if (arg->stmtp != NULL) {
-        OCIHandleFree(arg->stmtp, OCI_HTYPE_STMT);
-    }
-    return Qnil;
-}
-
 #ifdef HAVE_TYPE_RB_ENCODING
 
 static VALUE oci8_charset_name2id(VALUE svc, VALUE name)
@@ -125,43 +106,35 @@
         csid = INT2FIX(rv);
     } else {
         /* Oracle 9iR1 or lower */
-        cb_arg_t arg;
-        arg.svcctx = oci8_get_svcctx(svc);
-        arg.stmtp = NULL;
-        arg.u.name = name;
-        csid = rb_ensure(charset_name2id_func, (VALUE)&arg, ensure_func, (VALUE)&arg);
-        if (NIL_P(csid)) {
+        oci8_exec_sql_var_t bind_vars[2];
+        int ival;
+        sb2 ind = 0; /* null indicator */
+
+        /* :csid */
+        bind_vars[0].valuep = &ival;
+        bind_vars[0].value_sz = sizeof(int);
+        bind_vars[0].dty = SQLT_INT;
+        bind_vars[0].indp = &ind;
+        bind_vars[0].alenp = NULL;
+        /* :name */
+        bind_vars[1].valuep = RSTRING_PTR(name);
+        bind_vars[1].value_sz = RSTRING_LEN(name);
+        bind_vars[1].dty = SQLT_CHR;
+        bind_vars[1].indp = NULL;
+        bind_vars[1].alenp = NULL;
+
+        /* convert chaset name to charset id by querying Oracle server. */
+        oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :csid := nls_charset_id(:name); END;", 0, NULL, 2, bind_vars);
+        if (ind) {
             return Qnil;
         }
+        csid = INT2FIX(id);
     }
     rb_hash_aset(csid2name, csid, name);
     rb_hash_aset(csname2id, name, csid);
     return csid;
 }
 
-/* convert chaset name to charset id by querying Oracle server.
- * This routine is used only when the Oracle client version is 9iR1 or lower.
- */
-static VALUE charset_name2id_func(cb_arg_t *arg)
-{
-    int csid;
-    sb2 ind = 0; /* null indicator */
-    OCIBind *bind1 = NULL;
-    OCIBind *bind2 = NULL;
-    sword rv;
-    const char *sql = "BEGIN :csid := nls_charset_id(:name); END;";
-
-    rv = OCIHandleAlloc(oci8_envhp, (dvoid*)&arg->stmtp, OCI_HTYPE_STMT, 0, NULL);
-    if (rv != OCI_SUCCESS) {
-        oci8_env_raise(oci8_envhp, rv);
-    }
-    oci_lc(OCIStmtPrepare(arg->stmtp, oci8_errhp, (text*)sql, strlen(sql), OCI_NTV_SYNTAX, OCI_DEFAULT));
-    oci_lc(OCIBindByPos(arg->stmtp, &bind1, oci8_errhp, 1, (dvoid*)&csid, sizeof(int), SQLT_INT, &ind, NULL, 0, 0, 0, OCI_DEFAULT));
-    oci_lc(OCIBindByPos(arg->stmtp, &bind2, oci8_errhp, 2, RSTRING_PTR(arg->u.name), RSTRING_LEN(arg->u.name), SQLT_CHR, NULL, 0, 0, 0, 0, OCI_DEFAULT));
-    oci_lc(OCIStmtExecute_nb(arg->svcctx, arg->svcctx->base.hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT));
-    return ind ? Qnil : INT2FIX(csid);
-}
-
 #endif /* HAVE_TYPE_RB_ENCODING */
 
 void Init_oci8_encoding(VALUE cOCI8)

Modified: trunk/ruby-oci8/ext/oci8/metadata.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/metadata.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/metadata.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -223,7 +223,7 @@
     /* remote call? */
     oci_lc(OCIAttrGet_nb(svcctx, md->base.hp.ptr, OCI_DTYPE_PARAM, &value, &size, FIX2INT(idx), oci8_errhp));
     if (size != sizeof(OCIParam *)) {
-        rb_raise(rb_eRuntimeError, "Invalid attribute size. expect %d, but %d", sizeof(OCIParam *), size);
+        rb_raise(rb_eRuntimeError, "Invalid attribute size. expect %d, but %d", (sb4)sizeof(OCIParam *), size);
     }
     return oci8_metadata_create(value, md->svc, self);
 }

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -27,18 +27,10 @@
  */
 static VALUE cOCI8;
 
-static VALUE oci8_svcctx_logoff(VALUE self);
-static VALUE dummy(VALUE self)
-{
-    return Qnil;
-}
-
 static void oci8_svcctx_free(oci8_base_t *base)
 {
     oci8_svcctx_t *svcctx = (oci8_svcctx_t *)base;
 
-    /* ignore exceptions when logoff. */
-    rb_rescue(oci8_svcctx_logoff, base->self, dummy, Qnil);
     if (svcctx->authhp) {
         OCIHandleFree(svcctx->authhp, OCI_HTYPE_SESSION);
         svcctx->authhp = NULL;

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2008-08-04 14:13:56 UTC (rev 275)
@@ -230,6 +230,15 @@
     VALUE long_read_len;
 } oci8_svcctx_t;
 
+typedef struct {
+    dvoid *hp; /* OCIBind* or OCIDefine* */
+    dvoid *valuep;
+    sb4 value_sz;
+    ub2 dty;
+    sb2 *indp;
+    ub2 *alenp;
+} oci8_exec_sql_var_t;
+
 #define Check_Handle(obj, klass, hp) do { \
     if (!rb_obj_is_kind_of(obj, klass)) { \
         rb_raise(rb_eTypeError, "invalid argument %s (expect %s)", rb_class2name(CLASS_OF(obj)), rb_class2name(klass)); \
@@ -296,6 +305,7 @@
 void oci8_link_to_parent(oci8_base_t *base, oci8_base_t *parent);
 void oci8_unlink_from_parent(oci8_base_t *base);
 sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data);
+sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_vars, oci8_exec_sql_var_t *define_vars, ub4 num_bind_vars, oci8_exec_sql_var_t *bind_vars, int raise_on_error);
 #if defined RUNTIME_API_CHECK
 void *oci8_find_symbol(const char *symbol_name);
 #endif

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -297,6 +297,88 @@
 }
 #endif /* RUBY_VM */
 
+typedef struct {
+    oci8_svcctx_t *svcctx;
+    const char *sql_text;
+    ub4 num_define_vars;
+    oci8_exec_sql_var_t *define_vars;
+    ub4 num_bind_vars;
+    oci8_exec_sql_var_t *bind_vars;
+    int raise_on_error;
+    OCIStmt *stmtp;
+} cb_arg_t;
+
+static VALUE exec_sql(cb_arg_t *arg);
+static VALUE ensure_func(cb_arg_t *arg);
+
+/*
+ * utility function to execute a single SQL statement
+ */
+sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_vars, oci8_exec_sql_var_t *define_vars, ub4 num_bind_vars, oci8_exec_sql_var_t *bind_vars, int raise_on_error)
+{
+    cb_arg_t arg;
+    arg.svcctx = svcctx;
+    arg.sql_text = sql_text;
+    arg.num_define_vars = num_define_vars;
+    arg.define_vars = define_vars;
+    arg.num_bind_vars = num_bind_vars;
+    arg.bind_vars = bind_vars;
+    arg.raise_on_error = raise_on_error;
+    arg.stmtp = NULL;
+    return (sword)rb_ensure(exec_sql, (VALUE)&arg, ensure_func, (VALUE)&arg);
+}
+
+static VALUE exec_sql(cb_arg_t *arg)
+{
+    ub4 pos;
+    sword rv;
+
+    rv = OCIHandleAlloc(oci8_envhp, (dvoid*)&arg->stmtp, OCI_HTYPE_STMT, 0, NULL);
+    if (rv != OCI_SUCCESS) {
+        oci8_env_raise(oci8_envhp, rv);
+    }
+    oci_lc(OCIStmtPrepare(arg->stmtp, oci8_errhp, (text*)arg->sql_text,
+                          strlen(arg->sql_text), OCI_NTV_SYNTAX, OCI_DEFAULT));
+    for (pos = 0; pos < arg->num_define_vars; pos++) {
+        arg->define_vars[pos].hp = NULL;
+        oci_lc(OCIDefineByPos(arg->stmtp, (OCIDefine**)&arg->define_vars[pos].hp,
+                              oci8_errhp, pos + 1, arg->define_vars[pos].valuep,
+                              arg->define_vars[pos].value_sz,
+                              arg->define_vars[pos].dty, arg->define_vars[pos].indp,
+                              arg->define_vars[pos].alenp, NULL, OCI_DEFAULT));
+    }
+    for (pos = 0; pos < arg->num_bind_vars; pos++) {
+        arg->bind_vars[pos].hp = NULL;
+        oci_lc(OCIBindByPos(arg->stmtp, (OCIBind**)&arg->bind_vars[pos].hp,
+                            oci8_errhp, pos + 1, arg->bind_vars[pos].valuep,
+                            arg->bind_vars[pos].value_sz, arg->bind_vars[pos].dty,
+                            arg->bind_vars[pos].indp, arg->bind_vars[pos].alenp,
+                            NULL, 0, NULL, OCI_DEFAULT));
+    }
+    rv = OCIStmtExecute_nb(arg->svcctx, arg->svcctx->base.hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT);
+    if (rv == OCI_ERROR) {
+        if (oci8_get_error_code(oci8_errhp) == 1000) {
+            /* run GC to close unreferred cursors
+             * when ORA-01000 (maximum open cursors exceeded).
+             */
+            rb_gc();
+            rv = OCIStmtExecute_nb(arg->svcctx, arg->svcctx->base.hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT);
+        }
+    }
+    if (arg->raise_on_error) {
+        oci_lc(rv);
+    }
+    return (VALUE)rv;
+}
+
+static VALUE ensure_func(cb_arg_t *arg)
+{
+    if (arg->stmtp != NULL) {
+        OCIHandleFree(arg->stmtp, OCI_HTYPE_STMT);
+    }
+    return Qnil;
+}
+
 #if defined RUNTIME_API_CHECK
 
 #ifndef _WIN32

Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocidatetime.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/ocidatetime.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -27,7 +27,7 @@
 
     Check_Type(val, T_ARRAY);
     if (RARRAY_LEN(val) != 6) {
-        rb_raise(rb_eRuntimeError, "invalid array size %d", RARRAY_LEN(val));
+        rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
     }
     /* year */
     year = NUM2LONG(RARRAY_PTR(val)[0]);
@@ -145,7 +145,7 @@
 
     Check_Type(val, T_ARRAY);
     if (RARRAY_LEN(val) != 9) {
-        rb_raise(rb_eRuntimeError, "invalid array size %d", RARRAY_LEN(val));
+        rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
     }
     /* year */
     year = NUM2LONG(RARRAY_PTR(val)[0]);
@@ -291,7 +291,7 @@
 
     Check_Type(val, T_ARRAY);
     if (RARRAY_LEN(val) != 2) {
-        rb_raise(rb_eRuntimeError, "invalid array size %d", RARRAY_LEN(val));
+        rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
     }
     year = NUM2INT(RARRAY_PTR(val)[0]);
     month = NUM2INT(RARRAY_PTR(val)[1]);
@@ -325,7 +325,7 @@
 
     Check_Type(val, T_ARRAY);
     if (RARRAY_LEN(val) != 5) {
-        rb_raise(rb_eRuntimeError, "invalid array size %d", RARRAY_LEN(val));
+        rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
     }
     day = NUM2INT(RARRAY_PTR(val)[0]);
     hour = NUM2INT(RARRAY_PTR(val)[1]);

Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocinumber.c	2008-08-02 14:21:56 UTC (rev 274)
+++ trunk/ruby-oci8/ext/oci8/ocinumber.c	2008-08-04 14:13:56 UTC (rev 275)
@@ -978,7 +978,7 @@
 
 static VALUE onum_inspect(VALUE self)
 {
-    char *name = rb_class2name(CLASS_OF(self));
+    const char *name = rb_class2name(CLASS_OF(self));
     volatile VALUE s = onum_to_s(self);
     size_t len = strlen(name) + RSTRING_LEN(s) + 5;
     char *str = ALLOCA_N(char, len);




More information about the ruby-oci8-commit mailing list