[ruby-oci8-commit] [332] branches/ruby-oci8-1.0: * ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/ oci8/oraconf.rb:

nobody at rubyforge.org nobody at rubyforge.org
Sat Apr 11 22:36:40 EDT 2009


Revision: 332
Author:   kubo
Date:     2009-04-11 22:36:39 -0400 (Sat, 11 Apr 2009)

Log Message:
-----------
* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oraconf.rb:
    fix a problem when compiling for Oracle 8.0.
    (reported by Axel Reinhold as a ruby-oci8 2.0 issue)
* lib/dbd/OCI8.rb: fix DBI::DBD::OCI8::BindType::DBIStatementHandle
    to pass a newly added sanity check in dbi 0.4.1.
    (reported by Dirk Herzhauser as a ruby-oci8 2.0 issue)
* test/test_all.rb: fix to use dbi installed as a rubygem.

Modified Paths:
--------------
    branches/ruby-oci8-1.0/ChangeLog
    branches/ruby-oci8-1.0/ext/oci8/extconf.rb
    branches/ruby-oci8-1.0/ext/oci8/oci8.h
    branches/ruby-oci8-1.0/ext/oci8/oraconf.rb
    branches/ruby-oci8-1.0/lib/dbd/OCI8.rb
    branches/ruby-oci8-1.0/test/test_all.rb

Modified: branches/ruby-oci8-1.0/ChangeLog
===================================================================
--- branches/ruby-oci8-1.0/ChangeLog	2009-04-04 07:32:50 UTC (rev 331)
+++ branches/ruby-oci8-1.0/ChangeLog	2009-04-12 02:36:39 UTC (rev 332)
@@ -1,3 +1,12 @@
+2009-04-12  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oraconf.rb:
+	    fix a problem when compiling for Oracle 8.0.
+	    (reported by Axel Reinhold as a ruby-oci8 2.0 issue)
+	* lib/dbd/OCI8.rb: fix DBI::DBD::OCI8::BindType::DBIStatementHandle
+	    to pass a newly added sanity check in dbi 0.4.1.
+	    (reported by Dirk Herzhauser as a ruby-oci8 2.0 issue)
+	* test/test_all.rb: fix to use dbi installed as a rubygem.
+
 2009-03-17  KUBO Takehiro  <kubo at jiubao.org>
 	* NEWS: add changes between 1.0.4 and 1.0.5.
 	* VERSION: change version to 1.0.5.

Modified: branches/ruby-oci8-1.0/ext/oci8/extconf.rb
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/extconf.rb	2009-04-04 07:32:50 UTC (rev 331)
+++ branches/ruby-oci8-1.0/ext/oci8/extconf.rb	2009-04-12 02:36:39 UTC (rev 332)
@@ -44,6 +44,8 @@
 $CFLAGS += oraconf.cflags
 $libs += oraconf.libs
 
+have_type('oratext', 'ociap.h')
+
 # OCIEnvCreate
 #   8.0.5  - NG
 #   9.0.1  - OK

Modified: branches/ruby-oci8-1.0/ext/oci8/oci8.h
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/oci8.h	2009-04-04 07:32:50 UTC (rev 331)
+++ branches/ruby-oci8-1.0/ext/oci8/oci8.h	2009-04-12 02:36:39 UTC (rev 332)
@@ -52,6 +52,10 @@
 #define RARRAY_LEN(obj) RARRAY(obj)->len
 #endif
 
+#ifndef HAVE_TYPE_ORATEXT
+typedef unsigned char oratext;
+#endif
+
 #define IS_OCI_ERROR(v) (((v) != OCI_SUCCESS) && ((v) != OCI_SUCCESS_WITH_INFO))
 
 #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))

Modified: branches/ruby-oci8-1.0/ext/oci8/oraconf.rb
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/oraconf.rb	2009-04-04 07:32:50 UTC (rev 331)
+++ branches/ruby-oci8-1.0/ext/oci8/oraconf.rb	2009-04-12 02:36:39 UTC (rev 332)
@@ -944,21 +944,18 @@
         end
       end
 
-      # remove object files from libs.
-      objs = []
-      libs.gsub!(/\S+\.o\b/) do |obj|
-        objs << obj
-        ""
-      end
-      # change object files to an archive file to work around.
-      if objs.length > 0
-        Logging::open do
-          puts "change object files to an archive file."
-          command = Config::CONFIG["AR"] + " cru oracle_objs.a " + objs.join(" ")
-          puts command
-          system(command)
-          libs = "oracle_objs.a " + libs
+      # check whether object files are included.
+      if /\S+\.o\b/ =~ libs
+
+        # monkey patching!
+        Object.module_eval do
+          alias :orig_link_command :link_command
+          def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
+            opt = "" if opt == $libs
+            orig_link_command(ldflags, opt, libpath)
+          end
         end
+
       end
       libs
     end # get_libs

Modified: branches/ruby-oci8-1.0/lib/dbd/OCI8.rb
===================================================================
--- branches/ruby-oci8-1.0/lib/dbd/OCI8.rb	2009-04-04 07:32:50 UTC (rev 331)
+++ branches/ruby-oci8-1.0/lib/dbd/OCI8.rb	2009-04-12 02:36:39 UTC (rev 332)
@@ -401,6 +401,21 @@
   end
 end
 
+# DBI_STMT_NEW_ARGS is DBI::StatementHandle.new's arguments except +handle+.
+#
+# FYI: DBI::StatementHandle.new method signatures are follows:
+#   0.2.2: handle, fetchable=false, prepared=true
+#   0.4.0: handle, fetchable=false, prepared=true, convert_types=true
+#   0.4.1: handle, fetchable=false, prepared=true, convert_types=true, executed=false
+begin
+  DBI::StatementHandle.new(nil, false, true, true, true)
+  # dbi 0.4.1
+  DBI_STMT_NEW_ARGS = [true, true, true, true] # :nodoc:
+rescue ArgumentError
+  # dbi 0.4.0 or lower
+  DBI_STMT_NEW_ARGS = [true] # :nodoc:
+end
+
 if defined? ::OCI8::BindType::Base
   ##
   ## ruby-oci8 2.0 bind classes.
@@ -490,7 +505,7 @@
         val = super
         return nil if val.nil?
         stmt = DBI::DBD::OCI8::Statement.new(val)
-        DBI::StatementHandle.new(stmt, true, false)
+        DBI::StatementHandle.new(stmt, *DBI_STMT_NEW_ARGS)
       end
     end
   end # BindType
@@ -559,7 +574,7 @@
           return val if val.nil?
           cur = ::OCI8::Cursor.new(@env, @svc, @ctx, val)
           stmt = DBI::DBD::OCI8::Statement.new(cur)
-          DBI::StatementHandle.new(stmt, true, false)
+          DBI::StatementHandle.new(stmt, *DBI_STMT_NEW_ARGS)
         end
       end
     end

Modified: branches/ruby-oci8-1.0/test/test_all.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_all.rb	2009-04-04 07:32:50 UTC (rev 331)
+++ branches/ruby-oci8-1.0/test/test_all.rb	2009-04-12 02:36:39 UTC (rev 332)
@@ -23,11 +23,15 @@
 # Ruby/DBI
 begin
   require 'dbi'
-  is_dbi_loaded = true
 rescue LoadError
-  is_dbi_loaded = false
+  begin
+    require 'rubygems'
+    require 'dbi'
+  rescue LoadError
+    dbi_not_found = false
+  end
 end
-if is_dbi_loaded
+unless dbi_not_found
   require "#{srcdir}/test_dbi"
   if $test_clob
     require "#{srcdir}/test_dbi_clob"




More information about the ruby-oci8-commit mailing list