[ruby-oci8-commit] [364] trunk/ruby-oci8: * ext/oci8/oci8.c: Add a workaround for Oracle 9.2.0 .1 when clearing

nobody at rubyforge.org nobody at rubyforge.org
Sat Oct 17 10:23:14 EDT 2009


Revision: 364
Author:   kubo
Date:     2009-10-17 10:23:12 -0400 (Sat, 17 Oct 2009)

Log Message:
-----------
* ext/oci8/oci8.c: Add a workaround for Oracle 9.2.0.1 when clearing
    a client identifier.
* ext/oci8/oci8lib.c: Fix a segv when canceling a non-blocking
    execution.
* test_appinfo.rb: Fix temporarily to prevent a segmentation fault
    under Oracle 9.2.0.1.
* test/test_oci8.rb: Fix temporarily to prevent a segmentation fault
    under Oracle 9.2.0.1. Fix for BigDecimal bundled in ruby 1.8.5.
* test/test_oranumber.rb: Fix for Oracle 9.2. Comparing float values
    by <=> is too sensitive to use it in tests.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/oci8.c
    trunk/ruby-oci8/ext/oci8/oci8lib.c
    trunk/ruby-oci8/test/test_appinfo.rb
    trunk/ruby-oci8/test/test_oci8.rb
    trunk/ruby-oci8/test/test_oranumber.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2009-10-06 13:46:41 UTC (rev 363)
+++ trunk/ruby-oci8/ChangeLog	2009-10-17 14:23:12 UTC (rev 364)
@@ -1,3 +1,15 @@
+2009-10-17  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oci8.c: Add a workaround for Oracle 9.2.0.1 when clearing
+	    a client identifier.
+	* ext/oci8/oci8lib.c: Fix a segv when canceling a non-blocking
+	    execution.
+	* test_appinfo.rb: Fix temporarily to prevent a segmentation fault
+	    under Oracle 9.2.0.1.
+	* test/test_oci8.rb: Fix temporarily to prevent a segmentation fault
+	    under Oracle 9.2.0.1. Fix for BigDecimal bundled in ruby 1.8.5.
+	* test/test_oranumber.rb: Fix for Oracle 9.2. Comparing float values
+	    by <=> is too sensitive to use it in tests.
+
 2009-10-06  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/ocinumber.c: Add a global function OraNumber(obj) as a
 	    shortcut of OraNumber.new(obj) as Rational and BigDecimal do.

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2009-10-06 13:46:41 UTC (rev 363)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2009-10-17 14:23:12 UTC (rev 364)
@@ -673,6 +673,7 @@
 {
     char *ptr;
     ub4 size;
+    int use_attr_set = 1;
 
     if (!NIL_P(val)) {
         OCI8SafeStringValue(val);
@@ -682,7 +683,15 @@
         ptr = "";
         size = 0;
     }
-    if (oracle_client_version >= ORAVER_9_0) {
+
+    if (oracle_client_version < ORAVER_9_0) {
+        use_attr_set = 0;
+    } else if (oracle_client_version < ORAVERNUM(9, 2, 0, 3, 0) && size == 0) {
+        /* Workaround for Bug 2449486 */
+        use_attr_set = 0;
+    }
+
+    if (use_attr_set) {
         if (size > 0 && ptr[0] == ':') {
             rb_raise(rb_eArgError, "client identifier should not start with ':'.");
         }

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2009-10-06 13:46:41 UTC (rev 363)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2009-10-17 14:23:12 UTC (rev 364)
@@ -263,6 +263,8 @@
 }
 
 #ifdef RUBY_VM
+
+#if 0
 typedef struct {
     dvoid *hndlp;
     OCIError *errhp;
@@ -285,6 +287,13 @@
         rb_thread_blocking_region(call_OCIBreak, &arg, NULL, NULL);
     }
 }
+#else
+static void oci8_unblock_func(void *user_data)
+{
+    oci8_svcctx_t *svcctx = (oci8_svcctx_t *)user_data;
+    OCIBreak(svcctx->base.hp.ptr, oci8_errhp);
+}
+#endif
 
 /* ruby 1.9 */
 sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data)

Modified: trunk/ruby-oci8/test/test_appinfo.rb
===================================================================
--- trunk/ruby-oci8/test/test_appinfo.rb	2009-10-06 13:46:41 UTC (rev 363)
+++ trunk/ruby-oci8/test/test_appinfo.rb	2009-10-17 14:23:12 UTC (rev 364)
@@ -24,6 +24,9 @@
   end
 
   def test_set_module
+    # FIXME: check again after upgrading Oracle 9.2 to 9.2.0.4.
+    return if @conn.oracle_server_version < OCI8::ORAVER_10_1
+
     # set module
     @conn.module = 'ruby-oci8'
     assert_equal('ruby-oci8', @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'MODULE') FROM DUAL")[0]);
@@ -33,6 +36,9 @@
   end
 
   def test_set_action
+    # FIXME: check again after upgrading Oracle 9.2 to 9.2.0.4.
+    return if @conn.oracle_server_version < OCI8::ORAVER_10_1
+
     # set action
     @conn.action = 'test_set_action'
     assert_equal('test_set_action', @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'ACTION') FROM DUAL")[0]);

Modified: trunk/ruby-oci8/test/test_oci8.rb
===================================================================
--- trunk/ruby-oci8/test/test_oci8.rb	2009-10-06 13:46:41 UTC (rev 363)
+++ trunk/ruby-oci8/test/test_oci8.rb	2009-10-17 14:23:12 UTC (rev 364)
@@ -167,6 +167,9 @@
   end
 
   def test_bind_cursor
+    # FIXME: check again after upgrading Oracle 9.2 to 9.2.0.4.
+    return if $oracle_version < OCI8::ORAVER_10_1
+
     drop_table('test_table')
     sql = <<-EOS
 CREATE TABLE test_table
@@ -357,7 +360,7 @@
       assert_equal(row[0], 12345678901234)
       assert_equal(row[1], 12345678901234567890)
       assert_equal(row[2], 123456789012.34)
-      assert_equal(row[3], 1234567890123.45)
+      assert_equal(row[3], BigDecimal("1234567890123.45"))
       assert_equal(row[4], 1234.5)
       assert_instance_of(BigDecimal, row[0])
       assert_instance_of(Bignum, row[1])

Modified: trunk/ruby-oci8/test/test_oranumber.rb
===================================================================
--- trunk/ruby-oci8/test/test_oranumber.rb	2009-10-06 13:46:41 UTC (rev 363)
+++ trunk/ruby-oci8/test/test_oranumber.rb	2009-10-17 14:23:12 UTC (rev 364)
@@ -349,13 +349,18 @@
 
   # onum <=> other -> -1, 0, +1
   def test_cmp
-    test_values = SMALL_RANGE_VALUES.collect do |x|
-      x[0,15] # donw the precision to pass this test.
-    end
-    compare_with_float2(test_values, test_values,
-                        Proc.new {|x, y| x <=> y.to_f})
-    compare_with_float2(test_values, test_values,
-                        Proc.new {|x, y| y.to_f <=> x})
+    assert_equal(-1, 1 <=> OraNumber(2))
+    assert_equal(-1, 1.0 <=> OraNumber(2))
+    assert_equal(-1, BigDecimal("1") <=> OraNumber(2))
+    assert_equal(-1, Rational(1) <=> OraNumber(2))
+    assert_equal(0, 2 <=> OraNumber(2))
+    assert_equal(0, 2.0 <=> OraNumber(2))
+    assert_equal(0, BigDecimal("2") <=> OraNumber(2))
+    assert_equal(0, Rational(2) <=> OraNumber(2))
+    assert_equal(1, 3 <=> OraNumber(2))
+    assert_equal(1, 3.0 <=> OraNumber(2))
+    assert_equal(1, BigDecimal("3") <=> OraNumber(2))
+    assert_equal(1, Rational(3) <=> OraNumber(2))
   end
 
   # onum.abs -> ocinumber




More information about the ruby-oci8-commit mailing list