[ruby-oci8-commit] [396] trunk/ruby-oci8: * ext/oci8/extconf.rb, ext/oci8/oci8.c, lib/oci8.rb. in: move

nobody at rubyforge.org nobody at rubyforge.org
Tue Jun 1 09:18:10 EDT 2010


Revision: 396
Author:   kubo
Date:     2010-06-01 09:18:10 -0400 (Tue, 01 Jun 2010)

Log Message:
-----------
* ext/oci8/extconf.rb, ext/oci8/oci8.c, lib/oci8.rb.in: move
    the location where OCI8::VERSION is defined from oci8.rb to
    oci8lib_*.so. Add code to check the version of oci8.rb and
    oci8lib_*.so.
* test/test_clob.rb: create test_clob table while executing
    tests.
* README: delete the instruction to create test_clob before
    executing tests.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/README
    trunk/ruby-oci8/ext/oci8/extconf.rb
    trunk/ruby-oci8/ext/oci8/oci8.c
    trunk/ruby-oci8/lib/oci8.rb.in
    trunk/ruby-oci8/test/test_clob.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2010-05-17 13:37:21 UTC (rev 395)
+++ trunk/ruby-oci8/ChangeLog	2010-06-01 13:18:10 UTC (rev 396)
@@ -1,3 +1,13 @@
+2010-06-01  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/extconf.rb, ext/oci8/oci8.c, lib/oci8.rb.in: move
+	    the location where OCI8::VERSION is defined from oci8.rb to
+	    oci8lib_*.so. Add code to check the version of oci8.rb and
+	    oci8lib_*.so.
+	* test/test_clob.rb: create test_clob table while executing
+	    tests.
+	* README: delete the instruction to create test_clob before
+	    executing tests.
+
 2010-05-17  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/metadata.c: delete OCI8::Metadata::Base's methods which
 	    get and set OCI handle attributes.

Modified: trunk/ruby-oci8/README
===================================================================
--- trunk/ruby-oci8/README	2010-05-17 13:37:21 UTC (rev 395)
+++ trunk/ruby-oci8/README	2010-06-01 13:18:10 UTC (rev 396)
@@ -60,27 +60,17 @@
 
     SQL> GRANT connect, resource TO ruby;
 
-4. If the Oracle version is 8i or later:
+4. connect to Oracle as sys
 
-    SQL> CREATE TABLE ruby.test_clob (filename VARCHAR2(40), content CLOB);
-
-5. connect to Oracle as sys
-
     $ sqlplus 'sys/<password_of_sys> as sysdba'
 
-6. grant the privilege for the unittest of blocking-mode.
+5. grant the privilege for the unittest of blocking-mode.
 
     SQL> GRANT EXECUTE ON dbms_lock TO ruby;
 
-7. change test/config.rb as you like
+6. change test/config.rb as you like
 
 Then you can run:
   $ make check
 or
   $ nmake check   (If your compiler is MS Visual C++.)
-
-= TODO
-
-* more proper handling of OCI_SUCCESS_WITH_INFO.
-* more proper handling of NUMBER without its scale values.
-* support Timestamp.

Modified: trunk/ruby-oci8/ext/oci8/extconf.rb
===================================================================
--- trunk/ruby-oci8/ext/oci8/extconf.rb	2010-05-17 13:37:21 UTC (rev 395)
+++ trunk/ruby-oci8/ext/oci8/extconf.rb	2010-06-01 13:18:10 UTC (rev 396)
@@ -130,6 +130,7 @@
 
 $defs << "-DInit_oci8lib=Init_#{so_basename}"
 $defs << "-Doci8lib=#{so_basename}"
+$defs << "-DOCI8LIB_VERSION=\\\"#{RUBY_OCI8_VERSION}\\\""
 
 create_header()
 

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2010-05-17 13:37:21 UTC (rev 395)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2010-06-01 13:18:10 UTC (rev 396)
@@ -989,6 +989,7 @@
     id_at_prefetch_rows = rb_intern("@prefetch_rows");
     id_set_prefetch_rows = rb_intern("prefetch_rows=");
 
+    rb_define_const(cOCI8, "VERSION", rb_obj_freeze(rb_usascii_str_new_cstr(OCI8LIB_VERSION)));
     rb_define_singleton_method_nodoc(cOCI8, "oracle_client_vernum", oci8_s_oracle_client_vernum, 0);
     if (have_OCIMessageOpen && have_OCIMessageGet) {
         rb_define_singleton_method(cOCI8, "error_message", oci8_s_error_message, 1);

Modified: trunk/ruby-oci8/lib/oci8.rb.in
===================================================================
--- trunk/ruby-oci8/lib/oci8.rb.in	2010-05-17 13:37:21 UTC (rev 395)
+++ trunk/ruby-oci8/lib/oci8.rb.in	2010-06-01 13:18:10 UTC (rev 396)
@@ -18,15 +18,23 @@
   end
 end
 
+so_basename = nil
 case RUBY_VERSION
 when /^1\.9/
-  require 'oci8lib_191'
+  so_basename = 'oci8lib_191'
 when /^1\.8/
-  require 'oci8lib_18'
+  so_basename = 'oci8lib_18'
 else
   raise 'unsupported ruby version: ' + RUBY_VERSION
 end
+require so_basename
 
+if OCI8::VERSION != '@@OCI8_MODULE_VERSION@@'
+  require 'rbconfig'
+  so_name = so_basename + "." + Config::CONFIG['DLEXT']
+  raise "VERSION MISMATCH! #{so_name} version is #{OCI8::VERSION}, but oci8.rb version is @@OCI8_MODULE_VERSION@@."
+end
+
 require 'oci8/encoding-init.rb'
 require 'oci8/oracle_version.rb'
 
@@ -60,6 +68,11 @@
   def self.oracle_client_version
     @@oracle_client_version
   end
+
+  # defined for backward compatibility.
+  CLIENT_VERSION = @@oracle_client_version.major.to_s +
+    @@oracle_client_version.minor.to_s +
+    @@oracle_client_version.update.to_s
 end
 
 require 'oci8/ocihandle.rb'
@@ -70,8 +83,3 @@
 require 'oci8/compat.rb'
 require 'oci8/object.rb'
 require 'oci8/connection_pool.rb'
-
-class OCI8
-  VERSION = '@@OCI8_MODULE_VERSION@@'
-  CLIENT_VERSION = '@@OCI8_CLIENT_VERSION@@'
-end

Modified: trunk/ruby-oci8/test/test_clob.rb
===================================================================
--- trunk/ruby-oci8/test/test_clob.rb	2010-05-17 13:37:21 UTC (rev 395)
+++ trunk/ruby-oci8/test/test_clob.rb	2010-06-01 13:18:10 UTC (rev 396)
@@ -7,6 +7,8 @@
 
   def setup
     @conn = get_oci8_connection
+    drop_table('test_clob')
+    @conn.exec('CREATE TABLE test_clob (filename VARCHAR2(40), content CLOB)')
   end
 
   def test_insert
@@ -74,6 +76,7 @@
   end
 
   def teardown
+    drop_table('test_clob')
     @conn.logoff
   end
 end




More information about the ruby-oci8-commit mailing list