[ruby-oci8-commit] [491] trunk/ruby-oci8: replace OCILogon() with OCILogon2() and use the latter to use ConnectionPool.

nobody at rubyforge.org nobody at rubyforge.org
Thu Jan 19 06:56:20 EST 2012


Revision: 491
Author:   kubo
Date:     2012-01-19 06:56:19 -0500 (Thu, 19 Jan 2012)

Log Message:
-----------
replace OCILogon() with OCILogon2() and use the latter to use ConnectionPool.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/apiwrap.yml
    trunk/ruby-oci8/ext/oci8/oci8.c
    trunk/ruby-oci8/lib/oci8/oci8.rb
    trunk/ruby-oci8/test/config.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2012-01-09 07:23:25 UTC (rev 490)
+++ trunk/ruby-oci8/ChangeLog	2012-01-19 11:56:19 UTC (rev 491)
@@ -1,3 +1,9 @@
+2012-01-19  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/apiwrap.yml, ext/oci8/oci8.c, lib/oci8/oci8.rb: replace
+	    OCILogon() with OCILogon2() and use the latter to use
+	    ConnectionPool.
+	* test/config.rb: fix to pass lob tests.
+
 2012-01-09  KUBO Takehiro  <kubo at jiubao.org>
 	* docs/install-full-client.md: add a new document file.
 

Modified: trunk/ruby-oci8/ext/oci8/apiwrap.yml
===================================================================
--- trunk/ruby-oci8/ext/oci8/apiwrap.yml	2012-01-09 07:23:25 UTC (rev 490)
+++ trunk/ruby-oci8/ext/oci8/apiwrap.yml	2012-01-19 11:56:19 UTC (rev 491)
@@ -379,20 +379,6 @@
             - OCISvcCtx *svchp
             - OCIError *errhp
 
-# round trip: 1
-OCILogon_nb:
-  :version: 800
-  :args:
-            - OCIEnv *envhp
-            - OCIError *errhp
-            - OCISvcCtx **svchp
-            - CONST text *username
-            - ub4 uname_len
-            - CONST text *password
-            - ub4 passwd_len
-            - CONST text *dbname
-            - ub4 dbname_len
-
 # round trip: 0
 OCINumberAbs:
   :version: 800
@@ -1301,6 +1287,21 @@
             - sb4 mnth
             - OCIInterval *result
 
+# round trip: 1
+OCILogon2_nb:
+  :version: 900
+  :args:
+            - OCIEnv *envhp
+            - OCIError *errhp
+            - OCISvcCtx **svchp
+            - CONST text *username
+            - ub4 uname_len
+            - CONST text *password
+            - ub4 passwd_len
+            - CONST text *dbname
+            - ub4 dbname_len
+            - ub4 mode
+
 # round trip: 0 (not docmented. I guess.)
 OCIRowidToChar:
   :version: 900

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2012-01-09 07:23:25 UTC (rev 490)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2012-01-19 11:56:19 UTC (rev 491)
@@ -329,13 +329,13 @@
 
 /*
  * call-seq:
- *   logon(username, password, dbname) -> connection
+ *   logon2(username, password, dbname, mode) -> connection
  *
  * <b>internal use only</b>
  *
- * Creates a simple logon session by the OCI function OCILogon().
+ * Creates a simple logon session by the OCI function OCILogon2().
  */
-static VALUE oci8_logon(VALUE self, VALUE username, VALUE password, VALUE dbname)
+static VALUE oci8_logon2(VALUE self, VALUE username, VALUE password, VALUE dbname, VALUE mode)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
 
@@ -352,11 +352,11 @@
 
     /* logon */
     svcctx->base.type = OCI_HTYPE_SVCCTX;
-    chker2(OCILogon_nb(svcctx, oci8_envhp, oci8_errhp, &svcctx->base.hp.svc,
-                       RSTRING_ORATEXT(username), RSTRING_LEN(username),
-                       RSTRING_ORATEXT(password), RSTRING_LEN(password),
-                       NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
-                       NIL_P(dbname) ? 0 : RSTRING_LEN(dbname)),
+    chker2(OCILogon2_nb(svcctx, oci8_envhp, oci8_errhp, &svcctx->base.hp.svc,
+                        RSTRING_ORATEXT(username), RSTRING_LEN(username),
+                        RSTRING_ORATEXT(password), RSTRING_LEN(password),
+                        NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
+                        NIL_P(dbname) ? 0 : RSTRING_LEN(dbname), NUM2UINT(mode)),
            &svcctx->base);
     svcctx->logoff_strategy = &simple_logoff;
 
@@ -1099,7 +1099,7 @@
     rb_define_singleton_method_nodoc(cOCI8, "__set_property", oci8_s_set_property, 2);
     rb_define_singleton_method(cOCI8, "error_message", oci8_s_error_message, 1);
     rb_define_private_method(cOCI8, "parse_connect_string", oci8_parse_connect_string, 1);
-    rb_define_private_method(cOCI8, "logon", oci8_logon, 3);
+    rb_define_private_method(cOCI8, "logon2", oci8_logon2, 4);
     rb_define_private_method(cOCI8, "allocate_handles", oci8_allocate_handles, 0);
     rb_define_private_method(cOCI8, "session_handle", oci8_get_session_handle, 0);
     rb_define_private_method(cOCI8, "server_handle", oci8_get_server_handle, 0);

Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb	2012-01-09 07:23:25 UTC (rev 490)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb	2012-01-19 11:56:19 UTC (rev 491)
@@ -118,17 +118,22 @@
       raise "unknown privilege type #{mode}"
     end
 
-    if mode.nil? and cred.nil? and (not dbname.is_a? OCI8::ConnectionPool)
-      # logon by the OCI function OCILogon().
-      logon(username, password, dbname)
+    if mode.nil? and cred.nil?
+      # logon by the OCI function OCILogon2().
+      logon2_mode = 0
+      if dbname.is_a? OCI8::ConnectionPool
+        @pool = dbname # to prevent GC from freeing the connection pool.
+        dbname = dbname.send(:pool_name)
+        logon2_mode |= 0x0200 # OCI_LOGON2_CPOOL
+      end
+      logon2(username, password, dbname, logon2_mode)
     else
       # logon by the OCI function OCISessionBegin().
+      attach_mode = 0
       if dbname.is_a? OCI8::ConnectionPool
         @pool = dbname # to prevent GC from freeing the connection pool.
-        attach_mode = OCI_CPOOL
         dbname = dbname.send(:pool_name)
-      else
-        attach_mode = OCI_DEFAULT
+        attach_mode |= 0x0200 # OCI_CPOOL
       end
 
       allocate_handles()

Modified: trunk/ruby-oci8/test/config.rb
===================================================================
--- trunk/ruby-oci8/test/config.rb	2012-01-09 07:23:25 UTC (rev 490)
+++ trunk/ruby-oci8/test/config.rb	2012-01-19 11:56:19 UTC (rev 491)
@@ -13,12 +13,7 @@
 nls_lang = ENV['NLS_LANG']
 nls_lang = nls_lang.split('.')[1] unless nls_lang.nil?
 nls_lang = nls_lang.upcase unless nls_lang.nil?
-case nls_lang
-when 'JA16EUC'
-  $lobfile = File.dirname(__FILE__) + '/../doc/api.ja.rd' # EUC-JP file
-else
-  $lobfile = File.dirname(__FILE__) + '/../doc/api.en.rd' # ASCII file
-end
+$lobfile = File.dirname(__FILE__) + '/../setup.rb'
 $lobreadnum = 256 # counts in charactors
 
 # don't modify below.




More information about the ruby-oci8-commit mailing list