[ruby-oci8-commit] [258] branches/ruby-oci8-1.0: * ext/oci8/oraconf.rb: add error messages for the beta

nobody at rubyforge.org nobody at rubyforge.org
Mon Apr 7 22:51:31 EDT 2008


Revision: 258
Author:   kubo
Date:     2008-04-07 22:51:31 -0400 (Mon, 07 Apr 2008)

Log Message:
-----------
* ext/oci8/oraconf.rb: add error messages for the beta
    version of intel mac oracle instant client. But the production
    version may not need this.
* lib/oci8.rb.in: change the spec of OCI8#exec and OCI8::Cursor#exec.
    Before this change, the number of rows had been returned
    only when the SQL statement is update, delete or insert
    statement. After this, it is returned when the SQL statement
    is not select statement. For example OCI8#exec had returned
    true for MERGE statement (pointed by Jim Cain). But now it is
    the number of rows processed.
* ext/oci8/oradate.c, ext/oci8/oranumber.c: fix some (not all) warnings
    in compilation by HP-UX C compiler.
* ext/oci8/stmt.c: fix a compilation warning. iter's type is ub4. It
    cannot be minus value.

Modified Paths:
--------------
    branches/ruby-oci8-1.0/ChangeLog
    branches/ruby-oci8-1.0/ext/oci8/oraconf.rb
    branches/ruby-oci8-1.0/ext/oci8/oradate.c
    branches/ruby-oci8-1.0/ext/oci8/oranumber.c
    branches/ruby-oci8-1.0/ext/oci8/stmt.c
    branches/ruby-oci8-1.0/lib/oci8.rb.in

Modified: branches/ruby-oci8-1.0/ChangeLog
===================================================================
--- branches/ruby-oci8-1.0/ChangeLog	2008-03-29 13:06:30 UTC (rev 257)
+++ branches/ruby-oci8-1.0/ChangeLog	2008-04-08 02:51:31 UTC (rev 258)
@@ -1,3 +1,19 @@
+2008-04-08  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oraconf.rb: add error messages for the beta
+	    version of intel mac oracle instant client. But the production
+	    version may not need this.
+	* lib/oci8.rb.in: change the spec of OCI8#exec and OCI8::Cursor#exec.
+	    Before this change, the number of rows had been returned
+	    only when the SQL statement is update, delete or insert
+	    statement. After this, it is returned when the SQL statement
+	    is not select statement. For example OCI8#exec had returned
+	    true for MERGE statement (pointed by Jim Cain). But now it is
+	    the number of rows processed.
+	* ext/oci8/oradate.c, ext/oci8/oranumber.c: fix some (not all) warnings
+	    in compilation by HP-UX C compiler.
+	* ext/oci8/stmt.c: fix a compilation warning. iter's type is ub4. It
+	    cannot be minus value.
+
 2008-03-04  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/extconf.rb: output a message to say 'install
 	    a ruby development package' when 'mkmf.rb' is not

Modified: branches/ruby-oci8-1.0/ext/oci8/oraconf.rb
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/oraconf.rb	2008-03-29 13:06:30 UTC (rev 257)
+++ branches/ruby-oci8-1.0/ext/oci8/oraconf.rb	2008-04-08 02:51:31 UTC (rev 258)
@@ -931,21 +931,72 @@
       return
     end
 
-    if RUBY_PLATFORM =~ /i.*-darwin/
+    if RUBY_PLATFORM =~ /darwin/
+      is_intelmac = ([1].pack('s') == "\001\000")
+      arch_ppc_error = false
+      arch_i386_error = false
       open('mkmf.log', 'r') do |f|
         while line = f.gets
+          # universal-darwin8.0 (Mac OS X 10.4?)
           if line.include? 'cputype (18, architecture ppc) does not match cputype (7)'
-            raise <<EOS
-Oracle doesn't support intel mac.
-  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/223854
+            arch_i386_error = true
+          end
+          if line.include? 'cputype (7, architecture i386) does not match cputype (18)'
+            arch_ppc_error = true
+          end
+          # universal-darwin9.0 (Mac OS X 10.5?)
+          if line.include? 'Undefined symbols for architecture i386:'
+            arch_i386_error = true
+          end
+          if line.include? 'Undefined symbols for architecture ppc:'
+            arch_ppc_error = true
+          end
 
-There are three solutions:
-1. Compile ruby as ppc binary.
-2. Wait until Oracle releases mac intel binary.
-3. Use a third-party ODBC driver and ruby-odbc instead.
-     http://www.actualtechnologies.com/
+          if arch_i386_error
+            if is_intelmac
+              # intel mac and '-arch i386' error
+              raise <<EOS
+Could not compile with Oracle instant client.
+Use intel mac client, which will be released in a couple of weeks.
+   http://forums.oracle.com/forums/thread.jspa?threadID=634246
+
+If it has not been released yet, you have three workarounds.
+  1. Compile ruby as ppc binary.
+  2. Use JRuby and JDBC
+  3. Use a third-party ODBC driver and ruby-odbc.
 EOS
+            else
+              # ppc mac and '-arch i386' error
+              raise <<EOS
+Could not compile with Oracle instant client.
+You may need to set a environment variable:
+    RC_ARCHS=ppc
+    export RC_ARCHS
+If it does not fix the problem, delete all '-arch i386'
+in '#{Config::CONFIG['archdir']}/rbconfig.rb'.
+EOS
+            end
           end
+
+          if arch_ppc_error
+            if is_intelmac
+              # intel mac and '-arch ppc' error
+              raise <<EOS
+Could not compile with Oracle instant client.
+You may need to set a environment variable:
+    RC_ARCHS=i386
+    export RC_ARCHS
+If it does not fix the problem, delete all '-arch ppc'
+in '#{Config::CONFIG['archdir']}/rbconfig.rb'.
+EOS
+            else
+              # ppc mac and '-arch ppc' error
+              raise <<EOS
+Could not compile with Oracle instant client.
+Use ppc instant client.
+EOS
+            end
+          end
         end
       end
     end

Modified: branches/ruby-oci8-1.0/ext/oci8/oradate.c
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/oradate.c	2008-03-29 13:06:30 UTC (rev 257)
+++ branches/ruby-oci8-1.0/ext/oci8/oradate.c	2008-04-08 02:51:31 UTC (rev 258)
@@ -361,7 +361,7 @@
 {
 #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
   /* ruby 1.8 */
-  rb_define_alloc_func(cOraDate, ora_date_s_allocate);
+  rb_define_alloc_func(cOraDate, RUBY_METHOD_FUNC(ora_date_s_allocate));
   rb_define_method(cOraDate, "initialize", ora_date_initialize, -1);
   rb_define_method(cOraDate, "initialize_copy", ora_date_initialize_copy, 1);
 #else

Modified: branches/ruby-oci8-1.0/ext/oci8/oranumber.c
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/oranumber.c	2008-03-29 13:06:30 UTC (rev 257)
+++ branches/ruby-oci8-1.0/ext/oci8/oranumber.c	2008-04-08 02:51:31 UTC (rev 258)
@@ -189,7 +189,7 @@
 {
 #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
   /* ruby 1.8 */
-  rb_define_alloc_func(cOraNumber, ora_number_s_allocate);
+  rb_define_alloc_func(cOraNumber, RUBY_METHOD_FUNC(ora_number_s_allocate));
   rb_define_method(cOraNumber, "initialize", ora_number_initialize, -1);
   rb_define_method(cOraNumber, "initialize_copy", ora_number_initialize_copy, 1);
 #else

Modified: branches/ruby-oci8-1.0/ext/oci8/stmt.c
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/stmt.c	2008-03-29 13:06:30 UTC (rev 257)
+++ branches/ruby-oci8-1.0/ext/oci8/stmt.c	2008-04-08 02:51:31 UTC (rev 258)
@@ -505,7 +505,7 @@
   Get_Handle(self, h); /* 0 */
   Check_Handle(vsvc, OCISvcCtx, svch); /* 1 */
   if (argc >= 2) {
-    iters = NUM2INT(viters); /* 2 */
+    iters = NUM2UINT(viters); /* 2 */
   } else {
     rv = OCIAttrGet(h->hp, OCI_HTYPE_STMT, &stmt_type, 0, OCI_ATTR_STMT_TYPE, h->errhp);
     if (rv != OCI_SUCCESS) {
@@ -521,9 +521,7 @@
   }
   Get_Int_With_Default(argc, 3, vmode, mode, OCI_DEFAULT); /* 3 */
 
-  if (iters < 0) {
-    rb_raise(rb_eArgError, "use Positive value for the 2nd argument");
-  } else if (iters > 1) {
+  if (iters > 1) {
     rb_raise(rb_eArgError, "current implementation doesn't support array fatch or batch mode");
   }
 

Modified: branches/ruby-oci8-1.0/lib/oci8.rb.in
===================================================================
--- branches/ruby-oci8-1.0/lib/oci8.rb.in	2008-03-29 13:06:30 UTC (rev 257)
+++ branches/ruby-oci8-1.0/lib/oci8.rb.in	2008-04-08 02:51:31 UTC (rev 258)
@@ -752,12 +752,9 @@
       when OCI_STMT_SELECT
         do_ocicall(@ctx) { @stmt.execute(@svc, 0, OCI_DEFAULT) }
         define_columns()
-      when OCI_STMT_UPDATE, OCI_STMT_DELETE, OCI_STMT_INSERT
-        do_ocicall(@ctx) { @stmt.execute(@svc, 1, @ctx[CTX_EXECFLAG]) }
-        @stmt.attrGet(OCI_ATTR_ROW_COUNT)
       else
         do_ocicall(@ctx) { @stmt.execute(@svc, 1, @ctx[CTX_EXECFLAG]) }
-        true
+        @stmt.attrGet(OCI_ATTR_ROW_COUNT)
       end
     end # exec
 




More information about the ruby-oci8-commit mailing list