[ruby-oci8-commit] [424] trunk/ruby-oci8/ext/oci8: * ext/oci8/lob.c, ext/oci8/metadata.c, ext/ oci8/oci8.c,

nobody at rubyforge.org nobody at rubyforge.org
Mon Feb 21 06:10:58 EST 2011


Revision: 424
Author:   kubo
Date:     2011-02-21 06:10:57 -0500 (Mon, 21 Feb 2011)

Log Message:
-----------
* ext/oci8/lob.c, ext/oci8/metadata.c, ext/oci8/oci8.c,
  ext/oci8/oci8.h, ext/oci8/oci8lib.c, ext/oci8/stmt.c:
    fix segmentation fault when calling closed statement object's
    OCI8::Cursor#[]. (reported by Hugo L. Borges)

Modified Paths:
--------------
    branches/ruby-oci8-2.0/ChangeLog
    branches/ruby-oci8-2.0/ext/oci8/lob.c
    branches/ruby-oci8-2.0/ext/oci8/metadata.c
    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/stmt.c
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/lob.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/stmt.c

Modified: branches/ruby-oci8-2.0/ChangeLog
===================================================================
--- branches/ruby-oci8-2.0/ChangeLog	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ChangeLog	2011-02-21 11:10:57 UTC (rev 424)
@@ -1,3 +1,9 @@
+2011-02-21  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/lob.c, ext/oci8/metadata.c, ext/oci8/oci8.c,
+	  ext/oci8/oci8.h, ext/oci8/oci8lib.c, ext/oci8/stmt.c:
+	    fix segmentation fault when calling closed statement object's
+	    OCI8::Cursor#[]. (reported by Hugo L. Borges)
+
 2011-02-01  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/ocidatetime.c, lib/oci8/datetime.rb: rename
 	    the name of the class to binding timestamp with time zone

Modified: branches/ruby-oci8-2.0/ext/oci8/lob.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/lob.c	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ext/oci8/lob.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -66,8 +66,7 @@
 
 static void oci8_assign_lob(VALUE klass, oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest)
 {
-    oci8_base_t *base;
-    Check_Handle(lob, klass, base);
+    oci8_base_t *base = oci8_get_handle(lob, klass);
     oci_lc(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, base->hp.lob, dest));
 }
 

Modified: branches/ruby-oci8-2.0/ext/oci8/metadata.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/metadata.c	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ext/oci8/metadata.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -38,7 +38,7 @@
     VALUE klass;
     VALUE obj;
 
-    Check_Handle(parent, oci8_cOCIHandle, p);
+    p = oci8_get_handle(parent, oci8_cOCIHandle);
 
     oci_lc(OCIAttrGet(parmhp, OCI_DTYPE_PARAM, &ptype, &size, OCI_ATTR_PTYPE, oci8_errhp));
     klass = rb_hash_aref(ptype_to_class, INT2FIX(ptype));

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8.c	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -992,12 +992,7 @@
 
 oci8_svcctx_t *oci8_get_svcctx(VALUE obj)
 {
-    oci8_base_t *base;
-    Check_Handle(obj, cOCI8, base);
-    if (base->type == 0) {
-        rb_raise(eOCIException, "invalid argument %s was freed already.", rb_class2name(CLASS_OF(obj)));
-    }
-    return (oci8_svcctx_t *)base;
+    return (oci8_svcctx_t *)oci8_get_handle(obj, cOCI8);
 }
 
 OCISvcCtx *oci8_get_oci_svcctx(VALUE obj)

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.h
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8.h	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8.h	2011-02-21 11:10:57 UTC (rev 424)
@@ -418,6 +418,7 @@
 #if defined RUNTIME_API_CHECK
 void *oci8_find_symbol(const char *symbol_name);
 #endif
+oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass);
 
 /* error.c */
 extern VALUE eOCIException;

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8lib.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8lib.c	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8lib.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -484,3 +484,19 @@
 #endif /* defined _WIN32 */
 }
 #endif /* RUNTIME_API_CHECK */
+
+oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass)
+{
+    oci8_base_t *hp;
+
+    if (!rb_obj_is_kind_of(obj, klass)) {
+        rb_raise(rb_eTypeError, "invalid argument %s (expect %s)",
+                 rb_obj_classname(obj), rb_class2name(klass));
+    }
+    Data_Get_Struct(obj, oci8_base_t, hp);
+    if (hp->type == 0) {
+        rb_raise(rb_eRuntimeError, "%s was already closed.",
+                 rb_obj_classname(obj));
+    }
+    return hp;
+}

Modified: branches/ruby-oci8-2.0/ext/oci8/stmt.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/stmt.c	2011-02-01 13:04:42 UTC (rev 423)
+++ branches/ruby-oci8-2.0/ext/oci8/stmt.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -28,6 +28,8 @@
 
 VALUE cOCIStmt;
 
+#define TO_STMT(obj) ((oci8_stmt_t *)oci8_get_handle((obj), cOCIStmt))
+
 typedef struct {
     oci8_base_t base;
     VALUE svc;
@@ -94,7 +96,7 @@
 
 static VALUE oci8_define_by_pos(VALUE self, VALUE vposition, VALUE vbindobj)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     ub4 position;
     oci8_bind_t *obind;
     const oci8_bind_class_t *bind_class;
@@ -144,7 +146,7 @@
 
 static VALUE oci8_bind(VALUE self, VALUE vplaceholder, VALUE vbindobj)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     char *placeholder_ptr = (char*)-1; /* initialize as an invalid value */
     ub4 placeholder_len = 0;
     ub4 position = 0;
@@ -241,7 +243,7 @@
 
 static VALUE oci8_stmt_execute(VALUE self, VALUE iteration_count)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     oci8_svcctx_t *svcctx = oci8_get_svcctx(stmt->svc);
     ub4 iters;
     ub4 mode;
@@ -327,8 +329,8 @@
 
 static VALUE oci8_stmt_clear_binds(VALUE self)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
-    
+    oci8_stmt_t *stmt = TO_STMT(self);
+
     if(!RTEST(rb_funcall(stmt->binds, id_empty_p, 0)))
     {
         rb_iterate(each_value, stmt->binds, clear_binds_iterator_proc, Qnil);
@@ -453,7 +455,7 @@
  */
 static VALUE oci8_stmt_fetch(VALUE self)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     oci8_svcctx_t *svcctx = oci8_get_svcctx(stmt->svc);
 
     if (rb_block_given_p()) {
@@ -470,7 +472,7 @@
 
 static VALUE oci8_stmt_get_param(VALUE self, VALUE pos)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     OCIParam *parmhp = NULL;
     sword rv;
 
@@ -502,7 +504,7 @@
  */
 static VALUE oci8_stmt_get_stmt_type(VALUE self)
 {
-    VALUE stmt_type = oci8_get_ub2_attr(DATA_PTR(self), OCI_ATTR_STMT_TYPE);
+    VALUE stmt_type = oci8_get_ub2_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_STMT_TYPE);
     switch (FIX2INT(stmt_type)) {
     case OCI_STMT_SELECT:
         return oci8_sym_select_stmt;
@@ -532,7 +534,7 @@
  */
 static VALUE oci8_stmt_get_row_count(VALUE self)
 {
-    return oci8_get_ub4_attr(DATA_PTR(self), OCI_ATTR_ROW_COUNT);
+    return oci8_get_ub4_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_ROW_COUNT);
 }
 
 /*
@@ -551,12 +553,12 @@
  */
 static VALUE oci8_stmt_get_rowid(VALUE self)
 {
-    return oci8_get_rowid_attr(DATA_PTR(self), OCI_ATTR_ROWID);
+    return oci8_get_rowid_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_ROWID);
 }
 
 static VALUE oci8_stmt_get_param_count(VALUE self)
 {
-    return oci8_get_ub4_attr(DATA_PTR(self), OCI_ATTR_PARAM_COUNT);
+    return oci8_get_ub4_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_PARAM_COUNT);
 }
 
 /*
@@ -599,7 +601,7 @@
  */
 static VALUE oci8_stmt_aref(VALUE self, VALUE key)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     VALUE obj = rb_hash_aref(stmt->binds, key);
     if (NIL_P(obj)) {
         return Qnil;
@@ -637,7 +639,7 @@
     long actual_array_size;
     long bind_array_size;
 
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     VALUE obj = rb_hash_aref(stmt->binds, key);
     if (NIL_P(obj)) {
         return Qnil; /* ?? MUST BE ERROR? */
@@ -654,7 +656,7 @@
         if(bind_array_size <= max_array_size && actual_array_size == 0) {
             rb_ivar_set(self, id_at_actual_array_size, INT2NUM(bind_array_size));
         }
-    }     
+    }
     oci8_bind_set_data(obj, val);
     return val;
 }
@@ -667,13 +669,13 @@
  */
 static VALUE oci8_stmt_keys(VALUE self)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     return rb_funcall(stmt->binds, oci8_id_keys, 0);
 }
 
 static VALUE oci8_stmt_defined_p(VALUE self, VALUE pos)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     long position = NUM2INT(pos);
 
     if (position - 1 < RARRAY_LEN(stmt->defns)) {
@@ -697,7 +699,7 @@
  */
 static VALUE oci8_stmt_set_prefetch_rows(VALUE self, VALUE rows)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     ub4 num = NUM2UINT(rows);
 
     oci_lc(OCIAttrSet(stmt->base.hp.ptr, OCI_HTYPE_STMT, &num, 0, OCI_ATTR_PREFETCH_ROWS, oci8_errhp));

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ChangeLog	2011-02-21 11:10:57 UTC (rev 424)
@@ -1,3 +1,9 @@
+2011-02-21  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/lob.c, ext/oci8/metadata.c, ext/oci8/oci8.c,
+	  ext/oci8/oci8.h, ext/oci8/oci8lib.c, ext/oci8/stmt.c:
+	    fix segmentation fault when calling closed statement object's
+	    OCI8::Cursor#[]. (reported by Hugo L. Borges)
+
 2011-02-01  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/ocidatetime.c, lib/oci8/datetime.rb: rename
 	    the name of the class to binding timestamp with time zone

Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ext/oci8/lob.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -66,8 +66,7 @@
 
 static void oci8_assign_lob(VALUE klass, oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest)
 {
-    oci8_base_t *base;
-    Check_Handle(lob, klass, base);
+    oci8_base_t *base = oci8_get_handle(lob, klass);
     oci_lc(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, base->hp.lob, dest));
 }
 

Modified: trunk/ruby-oci8/ext/oci8/metadata.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/metadata.c	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ext/oci8/metadata.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -38,7 +38,7 @@
     VALUE klass;
     VALUE obj;
 
-    Check_Handle(parent, oci8_cOCIHandle, p);
+    p = oci8_get_handle(parent, oci8_cOCIHandle);
 
     oci_lc(OCIAttrGet(parmhp, OCI_DTYPE_PARAM, &ptype, &size, OCI_ATTR_PTYPE, oci8_errhp));
     klass = rb_hash_aref(ptype_to_class, INT2FIX(ptype));

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -1056,12 +1056,7 @@
 
 oci8_svcctx_t *oci8_get_svcctx(VALUE obj)
 {
-    oci8_base_t *base;
-    Check_Handle(obj, cOCI8, base);
-    if (base->type == 0) {
-        rb_raise(eOCIException, "invalid argument %s was freed already.", rb_class2name(CLASS_OF(obj)));
-    }
-    return (oci8_svcctx_t *)base;
+    return (oci8_svcctx_t *)oci8_get_handle(obj, cOCI8);
 }
 
 OCISvcCtx *oci8_get_oci_svcctx(VALUE obj)

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2011-02-21 11:10:57 UTC (rev 424)
@@ -425,6 +425,7 @@
 #if defined RUNTIME_API_CHECK
 void *oci8_find_symbol(const char *symbol_name);
 #endif
+oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass);
 
 /* error.c */
 extern VALUE eOCIException;

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -488,3 +488,19 @@
 #endif /* defined _WIN32 */
 }
 #endif /* RUNTIME_API_CHECK */
+
+oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass)
+{
+    oci8_base_t *hp;
+
+    if (!rb_obj_is_kind_of(obj, klass)) {
+        rb_raise(rb_eTypeError, "invalid argument %s (expect %s)",
+                 rb_obj_classname(obj), rb_class2name(klass));
+    }
+    Data_Get_Struct(obj, oci8_base_t, hp);
+    if (hp->type == 0) {
+        rb_raise(rb_eRuntimeError, "%s was already closed.",
+                 rb_obj_classname(obj));
+    }
+    return hp;
+}

Modified: trunk/ruby-oci8/ext/oci8/stmt.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/stmt.c	2011-02-01 13:04:42 UTC (rev 423)
+++ trunk/ruby-oci8/ext/oci8/stmt.c	2011-02-21 11:10:57 UTC (rev 424)
@@ -28,6 +28,8 @@
 
 VALUE cOCIStmt;
 
+#define TO_STMT(obj) ((oci8_stmt_t *)oci8_get_handle((obj), cOCIStmt))
+
 typedef struct {
     oci8_base_t base;
     VALUE svc;
@@ -94,7 +96,7 @@
 
 static VALUE oci8_define_by_pos(VALUE self, VALUE vposition, VALUE vbindobj)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     ub4 position;
     oci8_bind_t *obind;
     const oci8_bind_class_t *bind_class;
@@ -139,7 +141,7 @@
 
 static VALUE oci8_bind(VALUE self, VALUE vplaceholder, VALUE vbindobj)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     char *placeholder_ptr = (char*)-1; /* initialize as an invalid value */
     ub4 placeholder_len = 0;
     ub4 position = 0;
@@ -231,7 +233,7 @@
 
 static VALUE oci8_stmt_execute(VALUE self, VALUE iteration_count)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     oci8_svcctx_t *svcctx = oci8_get_svcctx(stmt->svc);
     ub4 iters;
     ub4 mode;
@@ -317,8 +319,8 @@
 
 static VALUE oci8_stmt_clear_binds(VALUE self)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
-    
+    oci8_stmt_t *stmt = TO_STMT(self);
+
     if(!RTEST(rb_funcall(stmt->binds, id_empty_p, 0)))
     {
         rb_iterate(each_value, stmt->binds, clear_binds_iterator_proc, Qnil);
@@ -443,7 +445,7 @@
  */
 static VALUE oci8_stmt_fetch(VALUE self)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     oci8_svcctx_t *svcctx = oci8_get_svcctx(stmt->svc);
 
     if (rb_block_given_p()) {
@@ -460,7 +462,7 @@
 
 static VALUE oci8_stmt_get_param(VALUE self, VALUE pos)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     OCIParam *parmhp = NULL;
     sword rv;
 
@@ -492,7 +494,7 @@
  */
 static VALUE oci8_stmt_get_stmt_type(VALUE self)
 {
-    VALUE stmt_type = oci8_get_ub2_attr(DATA_PTR(self), OCI_ATTR_STMT_TYPE);
+    VALUE stmt_type = oci8_get_ub2_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_STMT_TYPE);
     switch (FIX2INT(stmt_type)) {
     case OCI_STMT_SELECT:
         return oci8_sym_select_stmt;
@@ -522,7 +524,7 @@
  */
 static VALUE oci8_stmt_get_row_count(VALUE self)
 {
-    return oci8_get_ub4_attr(DATA_PTR(self), OCI_ATTR_ROW_COUNT);
+    return oci8_get_ub4_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_ROW_COUNT);
 }
 
 /*
@@ -541,12 +543,12 @@
  */
 static VALUE oci8_stmt_get_rowid(VALUE self)
 {
-    return oci8_get_rowid_attr(DATA_PTR(self), OCI_ATTR_ROWID);
+    return oci8_get_rowid_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_ROWID);
 }
 
 static VALUE oci8_stmt_get_param_count(VALUE self)
 {
-    return oci8_get_ub4_attr(DATA_PTR(self), OCI_ATTR_PARAM_COUNT);
+    return oci8_get_ub4_attr(oci8_get_handle(self, cOCIStmt), OCI_ATTR_PARAM_COUNT);
 }
 
 /*
@@ -589,7 +591,7 @@
  */
 static VALUE oci8_stmt_aref(VALUE self, VALUE key)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     VALUE obj = rb_hash_aref(stmt->binds, key);
     if (NIL_P(obj)) {
         return Qnil;
@@ -627,7 +629,7 @@
     long actual_array_size;
     long bind_array_size;
 
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     VALUE obj = rb_hash_aref(stmt->binds, key);
     if (NIL_P(obj)) {
         return Qnil; /* ?? MUST BE ERROR? */
@@ -644,7 +646,7 @@
         if(bind_array_size <= max_array_size && actual_array_size == 0) {
             rb_ivar_set(self, id_at_actual_array_size, INT2NUM(bind_array_size));
         }
-    }     
+    }
     oci8_bind_set_data(obj, val);
     return val;
 }
@@ -657,13 +659,13 @@
  */
 static VALUE oci8_stmt_keys(VALUE self)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     return rb_funcall(stmt->binds, oci8_id_keys, 0);
 }
 
 static VALUE oci8_stmt_defined_p(VALUE self, VALUE pos)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     long position = NUM2INT(pos);
 
     if (position - 1 < RARRAY_LEN(stmt->defns)) {
@@ -687,7 +689,7 @@
  */
 static VALUE oci8_stmt_set_prefetch_rows(VALUE self, VALUE rows)
 {
-    oci8_stmt_t *stmt = DATA_PTR(self);
+    oci8_stmt_t *stmt = TO_STMT(self);
     ub4 num = NUM2UINT(rows);
 
     oci_lc(OCIAttrSet(stmt->base.hp.ptr, OCI_HTYPE_STMT, &num, 0, OCI_ATTR_PREFETCH_ROWS, oci8_errhp));




More information about the ruby-oci8-commit mailing list