From nobody at rubyforge.org Fri Nov 4 07:32:27 2011 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 4 Nov 2011 07:32:27 -0400 (EDT) Subject: [ruby-oci8-commit] [462] trunk/ruby-oci8: fix to pass tests on Oracle 9i. Message-ID: <20111104113227.8515D1779950@rubyforge.org> Revision: 462 Author: kubo Date: 2011-11-04 07:32:18 -0400 (Fri, 04 Nov 2011) Log Message: ----------- fix to pass tests on Oracle 9i. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/extconf.rb trunk/ruby-oci8/ext/oci8/oci8.c trunk/ruby-oci8/ext/oci8/oci8.h trunk/ruby-oci8/test/test_datetime.rb trunk/ruby-oci8/test/test_metadata.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2011-10-29 12:37:04 UTC (rev 461) +++ trunk/ruby-oci8/ChangeLog 2011-11-04 11:32:18 UTC (rev 462) @@ -1,3 +1,8 @@ +2011-11-04 KUBO Takehiro + * ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h, + test/test_datetime.rb, test/test_metadata.rb: fix to pass tests + on Oracle 9i. + 2011-10-29 KUBO Takehiro * ext/oci8/error.c, ext/oci8/oci8.c, lib/oci8/object.rb, lib/oci8/oci8.rb: reset OCI8#last_error when OCI8#parse or OCI8#exec is called. Modified: trunk/ruby-oci8/ext/oci8/extconf.rb =================================================================== --- trunk/ruby-oci8/ext/oci8/extconf.rb 2011-10-29 12:37:04 UTC (rev 461) +++ trunk/ruby-oci8/ext/oci8/extconf.rb 2011-11-04 11:32:18 UTC (rev 462) @@ -69,6 +69,7 @@ have_type('OCICallbackLobRead2', 'ociap.h') have_type('OCICallbackLobWrite2', 'ociap.h') have_type('OCIAdmin*', 'ociap.h') +have_type('OCIAuthInfo*', 'ociap.h') have_type('OCIMsg*', 'ociap.h') have_type('OCICPool*', 'ociap.h') Modified: trunk/ruby-oci8/ext/oci8/oci8.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.c 2011-10-29 12:37:04 UTC (rev 461) +++ trunk/ruby-oci8/ext/oci8/oci8.c 2011-11-04 11:32:18 UTC (rev 462) @@ -844,7 +844,7 @@ size = 0; } - if (oracle_client_version >= ORAVERNUM(9, 2, 0, 3, 0) || size >= 0) { + if (oracle_client_version >= ORAVERNUM(9, 2, 0, 3, 0) || size > 0) { if (size > 0 && ptr[0] == ':') { rb_raise(rb_eArgError, "client identifier should not start with ':'."); } Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2011-10-29 12:37:04 UTC (rev 461) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2011-11-04 11:32:18 UTC (rev 462) @@ -90,6 +90,9 @@ #if !defined HAVE_TYPE_OCIADMIN_ && !defined HAVE_TYPE_OCIADMINP typedef struct OCIAdmin OCIAdmin; #endif +#if !defined HAVE_TYPE_OCIAUTHINFO_ && !defined HAVE_TYPE_OCIAUTHINFOP +typedef struct OCIAuthInfo OCIAuthInfo; +#endif #if !defined HAVE_TYPE_OCIMSG_ && !defined HAVE_TYPE_OCIMSGP typedef struct OCIMsg OCIMsg; #endif Modified: trunk/ruby-oci8/test/test_datetime.rb =================================================================== --- trunk/ruby-oci8/test/test_datetime.rb 2011-10-29 12:37:04 UTC (rev 461) +++ trunk/ruby-oci8/test/test_datetime.rb 2011-11-04 11:32:18 UTC (rev 462) @@ -442,7 +442,7 @@ ts1 TIMESTAMP; BEGIN ts1 := TO_TIMESTAMP(:in1, 'YYYY-MM-DD HH24:MI:SS.FF'); - :out := TO_CHAR(ts1 + :in2, 'YYYY-MM-DD HH24:MI:SS.FF6'); + :out := TO_CHAR(ts1 + :in2, 'YYYY-MM-DD HH24:MI:SS.FF'); END; EOS cursor.bind_param(:out, nil, String, 36) Modified: trunk/ruby-oci8/test/test_metadata.rb =================================================================== --- trunk/ruby-oci8/test/test_metadata.rb 2011-10-29 12:37:04 UTC (rev 461) +++ trunk/ruby-oci8/test/test_metadata.rb 2011-11-04 11:32:18 UTC (rev 462) @@ -1251,14 +1251,16 @@ :has_lob? => true, :has_file? => false, } - @conn.exec(<<-EOS) + if $oracle_version >= OCI8::ORAVER_9_2 + @conn.exec(<<-EOS) CREATE TYPE test_type_has_nclob AS OBJECT (lob NCLOB) EOS - expected_values << { - :obj_name => 'TEST_TYPE_HAS_NCLOB', - :has_lob? => true, - :has_file? => false, - } + expected_values << { + :obj_name => 'TEST_TYPE_HAS_NCLOB', + :has_lob? => true, + :has_file? => false, + } + end @conn.exec(<<-EOS) CREATE TYPE test_type_has_blob AS OBJECT (lob BLOB) EOS From nobody at rubyforge.org Fri Nov 4 07:57:58 2011 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 4 Nov 2011 07:57:58 -0400 (EDT) Subject: [ruby-oci8-commit] [463] trunk/ruby-oci8: add a workaround to avoid a gcc internal compiler error when using ruby 1. 9.2-p290 on ubuntu 11.10 (64bit). Message-ID: <20111104115758.E168B1779950@rubyforge.org> Revision: 463 Author: kubo Date: 2011-11-04 07:57:58 -0400 (Fri, 04 Nov 2011) Log Message: ----------- add a workaround to avoid a gcc internal compiler error when using ruby 1.9.2-p290 on ubuntu 11.10 (64bit). (reported by Bob Saveland.) Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/ocinumber.c Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2011-11-04 11:32:18 UTC (rev 462) +++ trunk/ruby-oci8/ChangeLog 2011-11-04 11:57:58 UTC (rev 463) @@ -1,4 +1,9 @@ 2011-11-04 KUBO Takehiro + * ext/oci8/ocinumber.c: add a workaround to avoid a gcc internal + compiler error when using ruby 1.9.2-p290 on ubuntu 11.10 (64bit). + (reported by Bob Saveland.) + +2011-11-04 KUBO Takehiro * ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h, test/test_datetime.rb, test/test_metadata.rb: fix to pass tests on Oracle 9i. Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocinumber.c 2011-11-04 11:32:18 UTC (rev 462) +++ trunk/ruby-oci8/ext/oci8/ocinumber.c 2011-11-04 11:57:58 UTC (rev 463) @@ -1329,7 +1329,7 @@ { char *c = DATA_PTR(self); int size = c[0] + 1; - int i, hash; + long i, hash; /* assert(size <= 22); ?*/ if (size > 22) From nobody at rubyforge.org Fri Nov 4 08:05:10 2011 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 4 Nov 2011 08:05:10 -0400 (EDT) Subject: [ruby-oci8-commit] [464] trunk/ruby-oci8: fix the mapping from Oracle NLS chacacter set to ruby encoding to use CP950 and CP951 , which are new encodings in ruby 1.9.3. Message-ID: <20111104120510.C8DDB1779950@rubyforge.org> Revision: 464 Author: kubo Date: 2011-11-04 08:05:10 -0400 (Fri, 04 Nov 2011) Log Message: ----------- fix the mapping from Oracle NLS chacacter set to ruby encoding to use CP950 and CP951, which are new encodings in ruby 1.9.3. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/lib/oci8/encoding.yml Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2011-11-04 11:57:58 UTC (rev 463) +++ trunk/ruby-oci8/ChangeLog 2011-11-04 12:05:10 UTC (rev 464) @@ -1,4 +1,9 @@ 2011-11-04 KUBO Takehiro + * lib/oci8/encoding.yml: fix the mapping from Oracle NLS chacacter set + to ruby encoding to use CP950 and CP951, which are new encodings + in ruby 1.9.3. + +2011-11-04 KUBO Takehiro * ext/oci8/ocinumber.c: add a workaround to avoid a gcc internal compiler error when using ruby 1.9.2-p290 on ubuntu 11.10 (64bit). (reported by Bob Saveland.) Modified: trunk/ruby-oci8/lib/oci8/encoding.yml =================================================================== --- trunk/ruby-oci8/lib/oci8/encoding.yml 2011-11-04 11:57:58 UTC (rev 463) +++ trunk/ruby-oci8/lib/oci8/encoding.yml 2011-11-04 12:05:10 UTC (rev 464) @@ -40,10 +40,10 @@ # MS Windows Code Page 950 with Hong Kong Supplementary Character # Set HKSCS-2001 (character set conversion to and from Unicode is # based on Unicode 3.0) -ZHT16HKSCS: [Big5-HKSCS, Big5] +ZHT16HKSCS: [CP951, Big5-HKSCS, Big5] # MS Windows Code Page 950 Traditional Chinese -ZHT16MSWIN950: Big5 +ZHT16MSWIN950: [CP950, Big5] # EUC 32-bit Traditional Chinese ZHT32EUC: EUC-TW # Who use this? @@ -166,7 +166,7 @@ # MS Windows Code Page 950 with Hong Kong Supplementary Character # Set HKSCS-2001 (character set conversion to and from Unicode is # based on Unicode 3.1) -ZHT16HKSCS31: [Big5-HKSCS, Big5] +ZHT16HKSCS31: [CP951, Big5-HKSCS, Big5] # SOPS 32-bit Traditional Chinese ZHT32SOPS: nil # FIXME From nobody at rubyforge.org Fri Nov 4 08:14:42 2011 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 4 Nov 2011 08:14:42 -0400 (EDT) Subject: [ruby-oci8-commit] [465] trunk/ruby-oci8: fix dist-files and others. Message-ID: <20111104121442.BCC4B1779950@rubyforge.org> Revision: 465 Author: kubo Date: 2011-11-04 08:14:41 -0400 (Fri, 04 Nov 2011) Log Message: ----------- fix dist-files and others. Modified Paths: -------------- trunk/ruby-oci8/.gitignore trunk/ruby-oci8/Makefile trunk/ruby-oci8/dist-files Modified: trunk/ruby-oci8/.gitignore =================================================================== --- trunk/ruby-oci8/.gitignore 2011-11-04 12:05:10 UTC (rev 464) +++ trunk/ruby-oci8/.gitignore 2011-11-04 12:14:41 UTC (rev 465) @@ -1,11 +1,23 @@ +.svn config.save +doc/.svn +ext/.svn +ext/oci8/.svn ext/oci8/apiwrap.h ext/oci8/Makefile ext/oci8/apiwrap.c ext/oci8/depend ext/oci8/extconf.h ext/oci8/mkmf.log +ext/oci8/*.def ext/oci8/*.o ext/oci8/*.so ext/oci8/*.obj +ext/oci8/*~ lib/oci8.rb +lib/*.rbc +lib/*~ +lib/oci8/*.rbc +lib/oci8/*~ +test/*.rbc +test/*~ Modified: trunk/ruby-oci8/Makefile =================================================================== --- trunk/ruby-oci8/Makefile 2011-11-04 12:05:10 UTC (rev 464) +++ trunk/ruby-oci8/Makefile 2011-11-04 12:14:41 UTC (rev 465) @@ -29,15 +29,9 @@ astyle --options=none --style=linux --indent=spaces=4 --brackets=linux --suffix=none ext/oci8/*.[ch] # internal use only -.PHONY: rdoc check-rdoc-version run-rdoc +.PHONY: rdoc run-rdoc -rdoc: check-rdoc-version run-rdoc - -check-rdoc-version: - @echo check rdoc version - @expr match "`$(RDOC) --version`" '^rdoc 2\.4' > /dev/null || (echo 'rdoc version is not 2.4.'; exit 1) - -run-rdoc: +rdoc: TZ= $(RDOC) -o rdoc -c us-ascii --threads=1 -W http://ruby-oci8.rubyforge.org/svn/trunk/ruby-oci8/ ext/oci8 lib dist: Modified: trunk/ruby-oci8/dist-files =================================================================== --- trunk/ruby-oci8/dist-files 2011-11-04 12:05:10 UTC (rev 464) +++ trunk/ruby-oci8/dist-files 2011-11-04 12:14:41 UTC (rev 465) @@ -28,6 +28,7 @@ ext/oci8/extconf.rb ext/oci8/lob.c ext/oci8/metadata.c +ext/oci8/object.c ext/oci8/oci8.c ext/oci8/oci8.h ext/oci8/oci8lib.c @@ -40,9 +41,9 @@ ext/oci8/oranumber_util.h ext/oci8/post-config.rb ext/oci8/stmt.c -ext/oci8/object.c +ext/oci8/thread_util.c +ext/oci8/thread_util.h ext/oci8/win32.c -ext/oci8/xmldb.c lib/.document lib/oci8.rb.in lib/dbd/OCI8.rb @@ -73,6 +74,7 @@ test/test_datetime.rb test/test_dbi.rb test/test_dbi_clob.rb +test/test_error.rb test/test_metadata.rb test/test_oci8.rb test/test_oracle_version.rb From nobody at rubyforge.org Wed Nov 23 08:15:16 2011 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Wed, 23 Nov 2011 08:15:16 -0500 (EST) Subject: [ruby-oci8-commit] [466] trunk/ruby-oci8: support sysasm privilege. Message-ID: <20111123131520.5BA1E1678366@rubyforge.org> Revision: 466 Author: kubo Date: 2011-11-23 08:15:14 -0500 (Wed, 23 Nov 2011) Log Message: ----------- support sysasm privilege. OCI8.new('username/password as sysasm') or OCI8.new('username', 'password', nil, :SYSASM) Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/oci8.c trunk/ruby-oci8/lib/oci8/oci8.rb trunk/ruby-oci8/lib/oci8/ocihandle.rb trunk/ruby-oci8/test/test_connstr.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2011-11-04 12:14:41 UTC (rev 465) +++ trunk/ruby-oci8/ChangeLog 2011-11-23 13:15:14 UTC (rev 466) @@ -1,3 +1,10 @@ +2011-11-23 KUBO Takehiro + * ext/oci8/oci8.c, lib/oci8/oci8.rb, lib/oci8/ocihandle.rb, + test/test_connstr.rb: support sysasm privilege. + OCI8.new('username/password as sysasm') + or + OCI8.new('username', 'password', nil, :SYSASM) + 2011-11-04 KUBO Takehiro * lib/oci8/encoding.yml: fix the mapping from Oracle NLS chacacter set to ruby encoding to use CP950 and CP951, which are new encodings Modified: trunk/ruby-oci8/ext/oci8/oci8.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.c 2011-11-04 12:14:41 UTC (rev 465) +++ trunk/ruby-oci8/ext/oci8/oci8.c 2011-11-23 13:15:14 UTC (rev 466) @@ -130,8 +130,6 @@ }; static VALUE oracle_client_vernum; /* Oracle client version number */ -static VALUE sym_SYSDBA; -static VALUE sym_SYSOPER; static ID id_at_prefetch_rows; static ID id_set_prefetch_rows; @@ -203,14 +201,7 @@ *pass = Qnil; } if (!NIL_P(*mode)) { - char *ptr; - SafeStringValue(*mode); - ptr = RSTRING_PTR(*mode); - if (strcasecmp(ptr, "SYSDBA") == 0) { - *mode = sym_SYSDBA; - } else if (strcasecmp(ptr, "SYSOPER") == 0) { - *mode = sym_SYSOPER; - } + *mode = ID2SYM(rb_to_id(rb_funcall(*mode, rb_intern("upcase"), 0))); } } else { rb_raise(rb_eArgError, "invalid connect string \"%s\" (expect \"username/password[@(tns_name|//host[:port]/service_name)][ as (sysdba|sysoper)]\"", RSTRING_PTR(conn_str)); @@ -1093,8 +1084,6 @@ oracle_client_vernum = INT2FIX(ORAVERNUM(major, minor, update, patch, port_update)); } - sym_SYSDBA = ID2SYM(rb_intern("SYSDBA")); - sym_SYSOPER = ID2SYM(rb_intern("SYSOPER")); id_at_prefetch_rows = rb_intern("@prefetch_rows"); id_set_prefetch_rows = rb_intern("prefetch_rows="); Modified: trunk/ruby-oci8/lib/oci8/oci8.rb =================================================================== --- trunk/ruby-oci8/lib/oci8/oci8.rb 2011-11-04 12:14:41 UTC (rev 465) +++ trunk/ruby-oci8/lib/oci8/oci8.rb 2011-11-23 13:15:14 UTC (rev 466) @@ -107,6 +107,11 @@ mode = OCI_SYSDBA when :SYSOPER mode = OCI_SYSOPER + when :SYSASM + if OCI8.oracle_client_version < OCI8::ORAVER_11_1 + raise "SYSASM is not supported on Oracle version #{OCI8.oracle_client_version}" + end + mode = OCI_SYSASM when nil # do nothing else Modified: trunk/ruby-oci8/lib/oci8/ocihandle.rb =================================================================== --- trunk/ruby-oci8/lib/oci8/ocihandle.rb 2011-11-04 12:14:41 UTC (rev 465) +++ trunk/ruby-oci8/lib/oci8/ocihandle.rb 2011-11-23 13:15:14 UTC (rev 466) @@ -300,6 +300,8 @@ OCI_SYSDBA = 0x0002 # for SYSOPER authorization OCI_SYSOPER = 0x0004 + # for SYSASM authorization + OCI_SYSASM = 0x8000 ################################# # Modified: trunk/ruby-oci8/test/test_connstr.rb =================================================================== --- trunk/ruby-oci8/test/test_connstr.rb 2011-11-04 12:14:41 UTC (rev 465) +++ trunk/ruby-oci8/test/test_connstr.rb 2011-11-23 13:15:14 UTC (rev 466) @@ -17,8 +17,8 @@ ["", ArgumentError], ["foo bar/baz", ArgumentError], ["foo at bar/baz", ArgumentError], - # raise error in connecting but no error in parse_connect_string. - ["foo/bar as sysdbaaa", ["foo", "bar", nil, "sysdbaaa"]], + # parse_connect_string doesn't check validity of privilege. + ["foo/bar as foo_bar", ["foo", "bar", nil, :FOO_BAR]], ## ## following test cases are contributed by Shiwei Zhang. From nobody at rubyforge.org Sat Nov 26 01:59:13 2011 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 26 Nov 2011 01:59:13 -0500 (EST) Subject: [ruby-oci8-commit] [467] trunk/ruby-oci8: fix a bug that an array is always bound as null. Message-ID: <20111126065913.912331779950@rubyforge.org> Revision: 467 Author: kubo Date: 2011-11-26 01:59:12 -0500 (Sat, 26 Nov 2011) Log Message: ----------- fix a bug that an array is always bound as null. This bug was introduced in ruby-oci8 2.0.5. (reported by Leo?\197?\161 Bitto) Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/object.c trunk/ruby-oci8/test/test_object.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2011-11-23 13:15:14 UTC (rev 466) +++ trunk/ruby-oci8/ChangeLog 2011-11-26 06:59:12 UTC (rev 467) @@ -1,3 +1,8 @@ +2011-11-26 KUBO Takehiro + * ext/oci8/object.c, test/test_object.rb: fix a bug that an array is + always bound as null. This bug was introduced in ruby-oci8 2.0.5. + (reported by Leo? Bitto) + 2011-11-23 KUBO Takehiro * ext/oci8/oci8.c, lib/oci8/oci8.rb, lib/oci8/ocihandle.rb, test/test_connstr.rb: support sysasm privilege. Modified: trunk/ruby-oci8/ext/oci8/object.c =================================================================== --- trunk/ruby-oci8/ext/oci8/object.c 2011-11-23 13:15:14 UTC (rev 466) +++ trunk/ruby-oci8/ext/oci8/object.c 2011-11-26 06:59:12 UTC (rev 467) @@ -389,6 +389,7 @@ set_coll_element_func(&cb_data); set_coll_element_ensure(&cb_data); #endif + *ind = 0; return Qnil; } Modified: trunk/ruby-oci8/test/test_object.rb =================================================================== --- trunk/ruby-oci8/test/test_object.rb 2011-11-23 13:15:14 UTC (rev 466) +++ trunk/ruby-oci8/test/test_object.rb 2011-11-26 06:59:12 UTC (rev 467) @@ -5,6 +5,9 @@ class RbTestObj < OCI8::Object::Base end +class RbTestIntArray < OCI8::Object::Base +end + class TestObj1 < Test::Unit::TestCase Delta = 0.00001 @@ -339,4 +342,35 @@ csr.exec assert_equal('IS NULL', csr[:out]) end + + def test_bind_array + csr = @conn.parse < Revision: 468 Author: kubo Date: 2011-11-27 01:23:24 -0500 (Sun, 27 Nov 2011) Log Message: ----------- add some testcases. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/test/test_all.rb trunk/ruby-oci8/test/test_break.rb trunk/ruby-oci8/test/test_oci8.rb trunk/ruby-oci8/test/test_oranumber.rb Added Paths: ----------- trunk/ruby-oci8/test/test_connection_pool.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2011-11-26 06:59:12 UTC (rev 467) +++ trunk/ruby-oci8/ChangeLog 2011-11-27 06:23:24 UTC (rev 468) @@ -1,3 +1,11 @@ +2011-11-27 KUBO Takehiro + * test/test_break.rb: fix test_timeout test for an Oracle server + on Windows. + * test/test_all.rb, test/test_connection_pool.rb: add testcases + of OCI8::ConnectionPool. + * test/test_oci8.rb: add a testcase for OCI8#last_error. + * test/test_oranumber.rb: add a testcase for OCI8.properties[:float_conversion_type]. + 2011-11-26 KUBO Takehiro * ext/oci8/object.c, test/test_object.rb: fix a bug that an array is always bound as null. This bug was introduced in ruby-oci8 2.0.5. Modified: trunk/ruby-oci8/test/test_all.rb =================================================================== --- trunk/ruby-oci8/test/test_all.rb 2011-11-26 06:59:12 UTC (rev 467) +++ trunk/ruby-oci8/test/test_all.rb 2011-11-27 06:23:24 UTC (rev 468) @@ -22,6 +22,7 @@ require "#{srcdir}/test_appinfo" require "#{srcdir}/test_oracle_version" require "#{srcdir}/test_error" +require "#{srcdir}/test_connection_pool" if OCI8.respond_to? :encoding require "#{srcdir}/test_encoding" Modified: trunk/ruby-oci8/test/test_break.rb =================================================================== --- trunk/ruby-oci8/test/test_break.rb 2011-11-26 06:59:12 UTC (rev 467) +++ trunk/ruby-oci8/test/test_break.rb 2011-11-27 06:23:24 UTC (rev 468) @@ -17,7 +17,18 @@ def report(str) printf "%d: %s\n", (Time.now - $start_time), str end - + + @@server_is_runing_on_windows = nil + def server_is_runing_on_windows? + if @@server_is_runing_on_windows.nil? + @@server_is_runing_on_windows = false + @conn.exec('select banner from v$version') do |row| + @@server_is_runing_on_windows = true if row[0].include? 'Windows' + end + end + @@server_is_runing_on_windows + end + PLSQL_DONE = 1 OCIBREAK = 2 SEND_BREAK = 3 @@ -56,15 +67,10 @@ end def test_non_blocking_mode - is_windows_server = false - @conn.exec('select banner from v$version') do |row| - is_windows_server = true if row[0].include? 'Windows' - end - @conn.non_blocking = true assert_equal(true, @conn.non_blocking?) expect = [] - if is_windows_server + if server_is_runing_on_windows? if $oracle_server_version >= OCI8::ORAVER_9_0 # raise after sleeping #{TIME_IN_PLSQL} seconds. expect[PLSQL_DONE] = "Invalid status" @@ -87,10 +93,16 @@ start_time = Time.now assert_raise(Timeout::Error) do Timeout.timeout(1) do - @conn.exec("BEGIN DBMS_LOCK.SLEEP(10); END;") + @conn.exec("BEGIN DBMS_LOCK.SLEEP(5); END;") end end + if server_is_runing_on_windows? + end_time = start_time + 5 + else + end_time = start_time + 1 + end + assert_in_delta(Time.now, end_time, 1) @conn.exec("BEGIN NULL; END;") - assert_operator(Time.now, :<, start_time + 2) + assert_in_delta(Time.now, end_time, 1) end end Added: trunk/ruby-oci8/test/test_connection_pool.rb =================================================================== --- trunk/ruby-oci8/test/test_connection_pool.rb (rev 0) +++ trunk/ruby-oci8/test/test_connection_pool.rb 2011-11-27 06:23:24 UTC (rev 468) @@ -0,0 +1,114 @@ +require 'oci8' +require 'test/unit' +require File.dirname(__FILE__) + '/config' + +class TestConnectionPool < Test::Unit::TestCase + + def create_pool(min, max, incr) + OCI8::ConnectionPool.new(min, max, incr, $dbuser, $dbpass, $dbname) + rescue OCIError + raise if $!.code != 12516 && $!.code != 12520 + sleep(5) + OCI8::ConnectionPool.new(min, max, incr, $dbuser, $dbpass, $dbname) + end + + def test_connect + pool = create_pool(1, 5, 3) + assert_equal(1, pool.min) + assert_equal(5, pool.max) + assert_equal(3, pool.incr) + end + + def test_reinitialize + pool = create_pool(1, 5, 3) + pool.reinitialize(2, 6, 4) + assert_equal(2, pool.min) + assert_equal(6, pool.max) + assert_equal(4, pool.incr) + end + + def test_busy_and_open_count + check_busy_and_open_count(1, 5, 3) + check_busy_and_open_count(2, 4, 1) + end + + def check_busy_and_open_count(min_cnt, max_cnt, incr_cnt) + # Create a connection pool. + pool = create_pool(min_cnt, max_cnt, incr_cnt) + assert_equal(min_cnt, pool.open_count) + assert_equal(0, pool.busy_count) + + # Create connections from the pool. + conns = [] + max_cnt.times do + conns << OCI8.new($dbuser, $dbpass, pool) + end + assert_equal(min_cnt, pool.open_count) + assert_equal(0, pool.busy_count) + + # Execute blocking SQL statements sequentially. + max_cnt.times do |n| + thread = Thread.start do + conns[n].exec "BEGIN DBMS_LOCK.SLEEP(1); END;" + end + sleep(0.5) + assert_equal(min_cnt, pool.open_count) + assert_equal(1, pool.busy_count) + thread.join + end + assert_equal(min_cnt, pool.open_count) + assert_equal(0, pool.busy_count) + + # Execute blocking SQL statements parallel to increment open_count. + threads = [] + (min_cnt + 1).times do |n| + threads << Thread.start do + conns[n].exec "BEGIN DBMS_LOCK.SLEEP(2); END;" + end + end + sleep(0.5) + assert_equal(min_cnt + incr_cnt, pool.open_count) + assert_equal(min_cnt + 1, pool.busy_count) + + # Execute blocking SQL statements parallel up to maximum. + (min_cnt + 1).upto(max_cnt - 1) do |n| + threads << Thread.start do + conns[n].exec "BEGIN DBMS_LOCK.SLEEP(1); END;" + end + end + sleep(0.5) + assert_equal(max_cnt, pool.open_count) + assert_equal(max_cnt, pool.busy_count) + + # + threads.each do |thr| + thr.join + end + assert_equal(max_cnt, pool.open_count) + assert_equal(0, pool.busy_count) + + # Set timeout + pool.timeout = 1 + sleep(1.5) + assert_equal(max_cnt, pool.open_count) # open_count doesn't shrink. + assert_equal(0, pool.busy_count) + conns[0].ping # make a network roundtrip. + sleep(0.5) + expected_cnt = max_cnt + while expected_cnt - incr_cnt > min_cnt + expected_cnt -= incr_cnt + end + assert_equal(expected_cnt, pool.open_count) # open_count shrinks. + assert_equal(0, pool.busy_count) + + # Close all conections. + conns.each do | conn | + conn.logoff + end + assert_equal(min_cnt, pool.open_count) + assert_equal(0, pool.busy_count) + end + + def test_nowait + end +end Modified: trunk/ruby-oci8/test/test_oci8.rb =================================================================== --- trunk/ruby-oci8/test/test_oci8.rb 2011-11-26 06:59:12 UTC (rev 467) +++ trunk/ruby-oci8/test/test_oci8.rb 2011-11-27 06:23:24 UTC (rev 468) @@ -431,4 +431,21 @@ end end + def test_last_error + # OCI8#parse and OCI8#exec reset OCI8#last_error + @conn.last_error = 'dummy' + @conn.exec('begin null; end;') + assert_nil(@conn.last_error) + @conn.last_error = 'dummy' + cursor = @conn.parse('select col1, max(col2) from (select 1 as col1, null as col2 from dual) group by col1') + assert_nil(@conn.last_error) + + # When an OCI function returns OCI_SUCCESS_WITH_INFO, OCI8#last_error is set. + @conn.last_error = 'dummy' + cursor.exec + assert_equal('dummy', @conn.last_error) + cursor.fetch + assert_kind_of(OCISuccessWithInfo, @conn.last_error) + assert_equal(24347, @conn.last_error.code) + end end # TestOCI8 Modified: trunk/ruby-oci8/test/test_oranumber.rb =================================================================== --- trunk/ruby-oci8/test/test_oranumber.rb 2011-11-26 06:59:12 UTC (rev 467) +++ trunk/ruby-oci8/test/test_oranumber.rb 2011-11-27 06:23:24 UTC (rev 468) @@ -743,4 +743,35 @@ assert_equal(false, OraNumber(10.0).has_decimal_part?) assert_equal(true, OraNumber(10.1).has_decimal_part?) end + + def test_float_conversion_type_ruby + orig = OCI8.properties[:float_conversion_type] + conn = get_oci8_connection + begin + OCI8.properties[:float_conversion_type] = :ruby + # Oracle Number -> Ruby Float + cursor = conn.parse('begin :out := :in; end;') + cursor.bind_param(:in, nil, String, 50) + cursor.bind_param(:out, nil, Float) + LARGE_RANGE_VALUES.each do |n| + cursor[:in] = n + cursor.exec + assert_equal(n.to_f, cursor[:out]) + end + cursor.close + # Ruby Float -> Oracle Number + cursor = conn.parse('begin :out := :in; end;') + cursor.bind_param(:in, nil, Float) + cursor.bind_param(:out, nil, String, 50) + LARGE_RANGE_VALUES.each do |n| + cursor[:in] = n.to_f + cursor.exec + assert_equal(n.to_f, cursor[:out].to_f) + end + cursor.close + ensure + OCI8.properties[:float_conversion_type] = orig + conn.logoff + end + end end