[ruby-oci8-commit] [240] trunk/ruby-oci8: * ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check.
nobody at rubyforge.org
nobody at rubyforge.org
Mon Jan 14 00:38:50 EST 2008
Revision: 240
Author: kubo
Date: 2008-01-14 00:38:49 -0500 (Mon, 14 Jan 2008)
Log Message:
-----------
* ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check.
* ext/oci8/ocidatetime.c, test/test_datetime.rb: use
DateTime.parse('0001-01-01 00:00:00.1') instead of
DateTime.parse('00:00:00.1'). The latter doesn't work
on ruby 1.8.5 or earlier.
* test/config.rb: revert the previous commit and add
get_oci8_connection() and get_dbi_connection() to the
base class of test cases. When an attempt to connect fails
by ORA-12516 or ORA-12520, their methods sleep one seconds
and try again more once.
delete unused method setup_lowapi().
* test/test_bind_raw.rb, test/test_bind_time.rb,
test/test_break.rb, test/test_clob.rb, test/test_datetime.rb,
test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb,
test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb,
test_oranumber.rb: revert the previous commit and use
get_oci8_connection() or get_dbi_connection() to make a
connection.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl
trunk/ruby-oci8/ext/oci8/ocidatetime.c
trunk/ruby-oci8/test/config.rb
trunk/ruby-oci8/test/test_bind_raw.rb
trunk/ruby-oci8/test/test_bind_time.rb
trunk/ruby-oci8/test/test_break.rb
trunk/ruby-oci8/test/test_clob.rb
trunk/ruby-oci8/test/test_datetime.rb
trunk/ruby-oci8/test/test_dbi.rb
trunk/ruby-oci8/test/test_dbi_clob.rb
trunk/ruby-oci8/test/test_metadata.rb
trunk/ruby-oci8/test/test_object.rb
trunk/ruby-oci8/test/test_oci8.rb
trunk/ruby-oci8/test/test_oradate.rb
trunk/ruby-oci8/test/test_oranumber.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/ChangeLog 2008-01-14 05:38:49 UTC (rev 240)
@@ -1,3 +1,23 @@
+2008-01-14 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/apiwrap.c.tmpl: fix a bug on runtime-api check.
+ * ext/oci8/ocidatetime.c, test/test_datetime.rb: use
+ DateTime.parse('0001-01-01 00:00:00.1') instead of
+ DateTime.parse('00:00:00.1'). The latter doesn't work
+ on ruby 1.8.5 or earlier.
+ * test/config.rb: revert the previous commit and add
+ get_oci8_connection() and get_dbi_connection() to the
+ base class of test cases. When an attempt to connect fails
+ by ORA-12516 or ORA-12520, their methods sleep one seconds
+ and try again more once.
+ delete unused method setup_lowapi().
+ * test/test_bind_raw.rb, test/test_bind_time.rb,
+ test/test_break.rb, test/test_clob.rb, test/test_datetime.rb,
+ test/test_dbi.rb, test/test_dbi_clob.rb, test/test_metadata.rb,
+ test/test_object.rb, test/test_oci8.rb, test/test_oradate.rb,
+ test_oranumber.rb: revert the previous commit and use
+ get_oci8_connection() or get_dbi_connection() to make a
+ connection.
+
2008-01-08 KUBO Takehiro <kubo at jiubao.org>
* test/config.rb, test/test_bind_raw.rb, test/test_bind_time.rb,
test/test_break.rb, test/test_clob.rb, test/test_datetime.rb,
Modified: trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl
===================================================================
--- trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl 2008-01-14 05:38:49 UTC (rev 240)
@@ -174,7 +174,7 @@
end
have_vars << 'have_' + f.name + (f.remote ? '_nb' : '')
%> <%=f.name%>_func = (<%=f.name%>_func_t)oci8_find_symbol("<%=f.name%>");
- if (<%=f.name%>_func != NULL)
+ if (<%=f.name%>_func == NULL)
return;
<%
end
Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocidatetime.c 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/ext/oci8/ocidatetime.c 2008-01-14 05:38:49 UTC (rev 240)
@@ -730,7 +730,7 @@
minute_base = rb_funcall(hour_base, id_mul, 1, INT2FIX(60));
sec_base = rb_funcall(minute_base, id_mul, 1, INT2FIX(60));
fsec_base = rb_funcall(sec_base, id_mul, 1, INT2FIX(1000000000));
- fsec_mul = rb_eval_string("(100_000_000 / DateTime.parse('00:00:00.1').sec_fraction).to_i");
+ fsec_mul = rb_eval_string("(100_000_000 / DateTime.parse('0001-01-01 00:00:00.1').sec_fraction).to_i");
rb_global_variable(&hour_base);
rb_global_variable(&minute_base);
rb_global_variable(&sec_base);
Modified: trunk/ruby-oci8/test/config.rb
===================================================================
--- trunk/ruby-oci8/test/config.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/config.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -20,21 +20,15 @@
# don't modify below.
-$dbconn = OCI8.new($dbuser, $dbpass, $dbname)
-begin
- require 'dbi'
- $dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
-rescue LoadError
-end
-
-
# $oracle_server_version: database compatible level of the Oracle server.
# $oracle_client_version: Oracle client library version for which oci8 is compiled.
# $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
-$dbconn.exec('select value from database_compatible_level') do |row|
+conn = OCI8.new($dbuser, $dbpass, $dbname)
+conn.exec('select value from database_compatible_level') do |row|
ver = row[0].split('.')
$oracle_server_version = (ver[0] + ver[1] + ver[2]).to_i
end
+conn.logoff
$oracle_client_version = OCI8::CLIENT_VERSION.to_i
if $oracle_server_version < $oracle_client_version
@@ -54,25 +48,40 @@
$test_clob = true
end
-$env_is_initialized = false
-def setup_lowapi()
- if ! $env_is_initialized
- if $describe_need_object_mode
- OCIEnv.initialise(OCI_OBJECT)
- else
- OCIEnv.initialise(OCI_DEFAULT)
- end
- $env_is_initialized = true
- end
- env = OCIEnv.init()
- svc = env.logon($dbuser, $dbpass, $dbname)
- stmt = env.alloc(OCIStmt)
- return env, svc, stmt
-end
-
module Test
module Unit
class TestCase
+
+ def get_oci8_connection()
+ OCI8.new($dbuser, $dbpass, $dbname)
+ rescue OCIError
+ raise if $!.code != 12516 && $!.code != 12520
+ # sleep one second and try again if
+ # the error code is ORA-12516 or ORA-12520.
+ #
+ # ORA-12516 - TNS:listener could not find available handler with
+ # matching protocol stack
+ # ORA-12520 - TNS:listener could not find available handler for
+ # requested type of server
+ #
+ # Thanks to Christopher Jones.
+ #
+ # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
+ # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
+ #
+ sleep(1)
+ OCI8.new($dbuser, $dbpass, $dbname)
+ end
+
+ def get_dbi_connection()
+ DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+ rescue DBI::DatabaseError
+ raise if $!.err != 12516 && $!.err != 12520
+ # same as get_oci8_connection()
+ sleep(1)
+ DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+ end
+
def drop_table(table_name)
if $oracle_server_version < 1000
# Oracle 8 - 9i
Modified: trunk/ruby-oci8/test/test_bind_raw.rb
===================================================================
--- trunk/ruby-oci8/test/test_bind_raw.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_bind_raw.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -13,7 +13,7 @@
]
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection()
end
def test_set_raw
@@ -41,6 +41,6 @@
end
def teardown
- @conn.rollback
+ @conn.logoff
end
end
Modified: trunk/ruby-oci8/test/test_bind_time.rb
===================================================================
--- trunk/ruby-oci8/test/test_bind_time.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_bind_time.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -12,7 +12,7 @@
SEC_CHECK_TARGET = [0, 15, 30, 45, 59]
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def test_set_year
@@ -173,6 +173,6 @@
end
def teardown
- @conn.rollback
+ @conn.logoff
end
end
Modified: trunk/ruby-oci8/test/test_break.rb
===================================================================
--- trunk/ruby-oci8/test/test_break.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_break.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -6,12 +6,11 @@
class TestBreak < Test::Unit::TestCase
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def teardown
- @conn.non_blocking = false
- @conn.rollback
+ @conn.logoff
end
def report(str)
Modified: trunk/ruby-oci8/test/test_clob.rb
===================================================================
--- trunk/ruby-oci8/test/test_clob.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_clob.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -6,7 +6,7 @@
class TestCLob < Test::Unit::TestCase
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def test_insert
@@ -58,6 +58,6 @@
end
def teardown
- @conn.rollback
+ @conn.logoff
end
end
Modified: trunk/ruby-oci8/test/test_datetime.rb
===================================================================
--- trunk/ruby-oci8/test/test_datetime.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_datetime.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -13,12 +13,12 @@
end
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
@local_timezone = timezone_string(*((::Time.now.utc_offset / 60).divmod 60))
end
def teardown
- @conn.rollback
+ @conn.logoff
end
def test_date_select
@@ -187,7 +187,7 @@
cursor.exec
assert_equal(DateTime.parse('2006-12-31 23:59:59'), cursor[:out])
# test sec_fraction
- def obj.sec_fraction; DateTime.parse('00:00:00.000001').sec_fraction * 999999 ; end
+ def obj.sec_fraction; DateTime.parse('0001-01-01 00:00:00.000001').sec_fraction * 999999 ; end
cursor[:in] = obj
cursor.exec
assert_equal(DateTime.parse('2006-12-31 23:59:59.999999'), cursor[:out])
Modified: trunk/ruby-oci8/test/test_dbi.rb
===================================================================
--- trunk/ruby-oci8/test/test_dbi.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_dbi.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -6,11 +6,11 @@
class TestDBI < Test::Unit::TestCase
def setup
- @dbh = $dbh
+ @dbh = get_dbi_connection()
end
def teardown
- @dbh.rollback
+ @dbh.disconnect
end
def test_select
Modified: trunk/ruby-oci8/test/test_dbi_clob.rb
===================================================================
--- trunk/ruby-oci8/test/test_dbi_clob.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_dbi_clob.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -5,7 +5,7 @@
class TestDbiCLob < Test::Unit::TestCase
def setup
- @dbh = $dbh
+ @dbh = get_dbi_connection()
end
def test_insert
@@ -45,6 +45,6 @@
end
def teardown
- @dbh.rollback
+ @dbh.disconnect
end
end
Modified: trunk/ruby-oci8/test/test_metadata.rb
===================================================================
--- trunk/ruby-oci8/test/test_metadata.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_metadata.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -5,11 +5,11 @@
class TestMetadata < Test::Unit::TestCase
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def teardown
- @conn.rollback
+ @conn.logoff
end
def test_metadata
Modified: trunk/ruby-oci8/test/test_object.rb
===================================================================
--- trunk/ruby-oci8/test/test_object.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_object.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -9,12 +9,12 @@
Delta = 0.00001
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
RbTestObj.default_connection = @conn
end
def teardown
- @conn.rollback
+ @conn.logoff
end
class ExpectedValObjElem
Modified: trunk/ruby-oci8/test/test_oci8.rb
===================================================================
--- trunk/ruby-oci8/test/test_oci8.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_oci8.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -5,11 +5,11 @@
class TestOCI8 < Test::Unit::TestCase
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def teardown
- @conn.rollback
+ @conn.logoff
end
def test_rename
Modified: trunk/ruby-oci8/test/test_oradate.rb
===================================================================
--- trunk/ruby-oci8/test/test_oradate.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_oradate.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -13,7 +13,7 @@
SECOND_CHECK_TARGET = [0, 15, 30, 45, 59]
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def check_oradate(target, year, month, day, hour, minute, second)
@@ -251,6 +251,6 @@
end
def teardown
- @conn.rollback
+ @conn.logoff
end
end
Modified: trunk/ruby-oci8/test/test_oranumber.rb
===================================================================
--- trunk/ruby-oci8/test/test_oranumber.rb 2008-01-12 07:12:45 UTC (rev 239)
+++ trunk/ruby-oci8/test/test_oranumber.rb 2008-01-14 05:38:49 UTC (rev 240)
@@ -53,7 +53,7 @@
]
def setup
- @conn = $dbconn
+ @conn = get_oci8_connection
end
def test_to_s
@@ -137,6 +137,6 @@
end
def teardown
- @conn.rollback
+ @conn.logoff
end
end
More information about the ruby-oci8-commit
mailing list