ruby-oci8 2.1.5-x86-mingw32 → 2.1.7-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +123 -0
- data/NEWS +54 -0
- data/README.md +9 -6
- data/VERSION +1 -1
- data/docs/install-full-client.md +2 -4
- data/docs/install-instant-client.md +14 -9
- data/docs/report-installation-issue.md +1 -1
- data/lib/oci8.rb +10 -19
- data/lib/oci8.rb.in +8 -17
- data/lib/oci8/cursor.rb +2 -0
- data/lib/oci8/metadata.rb +87 -9
- data/lib/oci8/object.rb +23 -0
- data/lib/oci8lib_18.so +0 -0
- data/lib/oci8lib_191.so +0 -0
- data/lib/oci8lib_200.so +0 -0
- data/lib/oci8lib_210.so +0 -0
- data/ruby-oci8.gemspec +2 -2
- data/test/config.rb +76 -66
- data/test/test_all.rb +4 -6
- data/test/test_appinfo.rb +2 -3
- data/test/test_array_dml.rb +6 -7
- data/test/test_bind_raw.rb +1 -2
- data/test/test_bind_string.rb +1 -2
- data/test/test_bind_time.rb +1 -2
- data/test/test_break.rb +2 -3
- data/test/test_clob.rb +1 -2
- data/test/test_connection_pool.rb +2 -3
- data/test/test_connstr.rb +1 -4
- data/test/test_datetime.rb +2 -3
- data/test/test_dbi.rb +1 -2
- data/test/test_dbi_clob.rb +6 -6
- data/test/test_encoding.rb +1 -2
- data/test/test_error.rb +1 -2
- data/test/test_metadata.rb +2086 -898
- data/test/test_object.rb +8 -11
- data/test/test_oci8.rb +1 -2
- data/test/test_oracle_version.rb +1 -3
- data/test/test_oradate.rb +1 -2
- data/test/test_oranumber.rb +5 -6
- data/test/test_rowid.rb +1 -2
- metadata +6 -5
data/lib/oci8/object.rb
CHANGED
@@ -71,6 +71,29 @@ EOS
|
|
71
71
|
OCI8::TDO.new(self, metadata, klass)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Returns the type descriptor object which correspond to the given type name.
|
75
|
+
#
|
76
|
+
# @param [String] typename
|
77
|
+
# @return [OCI8::TDO]
|
78
|
+
#
|
79
|
+
# @private
|
80
|
+
def get_tdo_by_typename(typename)
|
81
|
+
tdo = @name_to_tdo && @name_to_tdo[typename]
|
82
|
+
return tdo if tdo
|
83
|
+
|
84
|
+
metadata = describe_any(typename)
|
85
|
+
if metadata.is_a? OCI8::Metadata::Synonym
|
86
|
+
metadata = describe_any(metadata.translated_name)
|
87
|
+
end
|
88
|
+
unless metadata.is_a? OCI8::Metadata::Type
|
89
|
+
raise "unknown typename #{typename}"
|
90
|
+
end
|
91
|
+
tdo = get_tdo_by_metadata(metadata)
|
92
|
+
|
93
|
+
@name_to_tdo[typename] = tdo
|
94
|
+
tdo
|
95
|
+
end
|
96
|
+
|
74
97
|
# A helper class to bind arguments.
|
75
98
|
#
|
76
99
|
# @private
|
data/lib/oci8lib_18.so
CHANGED
Binary file
|
data/lib/oci8lib_191.so
CHANGED
Binary file
|
data/lib/oci8lib_200.so
CHANGED
Binary file
|
data/lib/oci8lib_210.so
ADDED
Binary file
|
data/ruby-oci8.gemspec
CHANGED
@@ -19,7 +19,7 @@ spec = Gem::Specification.new do |s|
|
|
19
19
|
s.version = File.read('VERSION').strip
|
20
20
|
s.summary = 'Ruby interface for Oracle using OCI8 API'
|
21
21
|
s.email = 'kubo@jiubao.org'
|
22
|
-
s.homepage = '
|
22
|
+
s.homepage = 'https://github.com/kubo/ruby-oci8/'
|
23
23
|
s.rubyforge_project = 'ruby-oci8'
|
24
24
|
s.description = <<EOS
|
25
25
|
ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle8i, Oracle9i, Oracle10g, Oracle11g and Oracle Instant Client.
|
@@ -57,7 +57,7 @@ EOS
|
|
57
57
|
if so_vers[0] < '2.0.0'
|
58
58
|
s.required_ruby_version = "~> #{so_vermin}"
|
59
59
|
else
|
60
|
-
s.required_ruby_version = "
|
60
|
+
s.required_ruby_version = "~> #{so_vermin}.0"
|
61
61
|
end
|
62
62
|
else
|
63
63
|
puts "Binary gem for ruby #{so_vers.join(', ')}"
|
data/test/config.rb
CHANGED
@@ -18,6 +18,21 @@ $lobreadnum = 256 # counts in charactors
|
|
18
18
|
|
19
19
|
# don't modify below.
|
20
20
|
|
21
|
+
begin
|
22
|
+
require 'minitest/autorun'
|
23
|
+
Minitest = MiniTest unless defined? Minitest
|
24
|
+
Minitest::Test = Minitest::Unit::TestCase unless defined? Minitest::Test
|
25
|
+
rescue LoadError
|
26
|
+
require 'test/unit'
|
27
|
+
module Minitest
|
28
|
+
Test = ::Test::Unit::TestCase
|
29
|
+
Assertions = ::Test::Unit::Assertions
|
30
|
+
module Assertions
|
31
|
+
alias refute_nil assert_not_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
21
36
|
# $oracle_server_version: database compatible level of the Oracle server.
|
22
37
|
# $oracle_client_version: Oracle client library version for which oci8 is compiled.
|
23
38
|
# $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
|
@@ -108,77 +123,72 @@ def convert_to_datetime(year, month, day, hour, minute, sec, subsec, timezone)
|
|
108
123
|
end
|
109
124
|
end
|
110
125
|
|
111
|
-
|
112
|
-
module Unit
|
113
|
-
class TestCase
|
126
|
+
class Minitest::Test
|
114
127
|
|
115
|
-
|
116
|
-
|
128
|
+
def get_oci8_connection()
|
129
|
+
OCI8.new($dbuser, $dbpass, $dbname)
|
117
130
|
rescue OCIError
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
131
|
+
raise if $!.code != 12516 && $!.code != 12520
|
132
|
+
# sleep a few second and try again if
|
133
|
+
# the error code is ORA-12516 or ORA-12520.
|
134
|
+
#
|
135
|
+
# ORA-12516 - TNS:listener could not find available handler with
|
136
|
+
# matching protocol stack
|
137
|
+
# ORA-12520 - TNS:listener could not find available handler for
|
138
|
+
# requested type of server
|
139
|
+
#
|
140
|
+
# Thanks to Christopher Jones.
|
141
|
+
#
|
142
|
+
# Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
|
143
|
+
# http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
|
144
|
+
#
|
145
|
+
sleep(5)
|
146
|
+
OCI8.new($dbuser, $dbpass, $dbname)
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_dbi_connection()
|
150
|
+
DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
|
151
|
+
rescue DBI::DatabaseError
|
152
|
+
raise if $!.err != 12516 && $!.err != 12520
|
153
|
+
# same as get_oci8_connection()
|
154
|
+
sleep(5)
|
155
|
+
DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
|
156
|
+
end
|
135
157
|
|
136
|
-
|
137
|
-
|
158
|
+
def drop_table(table_name)
|
159
|
+
if $oracle_server_version < OCI8::ORAVER_10_1
|
160
|
+
# Oracle 8 - 9i
|
161
|
+
sql = "DROP TABLE #{table_name}"
|
162
|
+
else
|
163
|
+
# Oracle 10g -
|
164
|
+
sql = "DROP TABLE #{table_name} PURGE"
|
165
|
+
end
|
166
|
+
|
167
|
+
if defined? @conn
|
168
|
+
begin
|
169
|
+
@conn.exec(sql)
|
170
|
+
rescue OCIError
|
171
|
+
raise if $!.code != 942 # table or view does not exist
|
172
|
+
end
|
173
|
+
elsif instance_variable_get(:@dbh)
|
174
|
+
begin
|
175
|
+
@dbh.do(sql)
|
138
176
|
rescue DBI::DatabaseError
|
139
|
-
raise if $!.err !=
|
140
|
-
# same as get_oci8_connection()
|
141
|
-
sleep(5)
|
142
|
-
DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
|
177
|
+
raise if $!.err != 942 # table or view does not exist
|
143
178
|
end
|
179
|
+
end
|
180
|
+
end # drop_table
|
144
181
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
# Oracle 10g -
|
151
|
-
sql = "DROP TABLE #{table_name} PURGE"
|
152
|
-
end
|
153
|
-
|
154
|
-
if defined? @conn
|
155
|
-
begin
|
156
|
-
@conn.exec(sql)
|
157
|
-
rescue OCIError
|
158
|
-
raise if $!.code != 942 # table or view does not exist
|
159
|
-
end
|
160
|
-
elsif instance_variable_get(:@dbh)
|
161
|
-
begin
|
162
|
-
@dbh.do(sql)
|
163
|
-
rescue DBI::DatabaseError
|
164
|
-
raise if $!.err != 942 # table or view does not exist
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end # drop_table
|
168
|
-
|
169
|
-
def drop_type(type_name)
|
170
|
-
begin
|
171
|
-
@conn.exec("DROP TYPE BODY #{type_name}")
|
172
|
-
rescue OCIError
|
173
|
-
raise if $!.code != 4043
|
174
|
-
end
|
175
|
-
begin
|
176
|
-
@conn.exec("DROP TYPE #{type_name}")
|
177
|
-
rescue OCIError
|
178
|
-
raise if $!.code != 4043
|
179
|
-
end
|
180
|
-
end # drop_type
|
182
|
+
def drop_type(type_name)
|
183
|
+
begin
|
184
|
+
@conn.exec("DROP TYPE BODY #{type_name}")
|
185
|
+
rescue OCIError
|
186
|
+
raise if $!.code != 4043
|
181
187
|
end
|
182
|
-
|
188
|
+
begin
|
189
|
+
@conn.exec("DROP TYPE #{type_name}")
|
190
|
+
rescue OCIError
|
191
|
+
raise if $!.code != 4043
|
192
|
+
end
|
193
|
+
end # drop_type
|
183
194
|
end
|
184
|
-
|
data/test/test_all.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
srcdir = File.dirname(__FILE__)
|
2
2
|
|
3
3
|
require 'oci8'
|
4
|
-
require 'test/unit'
|
5
4
|
require "#{srcdir}/config"
|
6
5
|
|
7
6
|
require "#{srcdir}/test_oradate"
|
@@ -30,6 +29,10 @@ if OCI8.respond_to? :encoding
|
|
30
29
|
require "#{srcdir}/test_encoding"
|
31
30
|
end
|
32
31
|
|
32
|
+
if $oracle_version >= OCI8::ORAVER_12_1
|
33
|
+
require "#{srcdir}/test_package_type"
|
34
|
+
end
|
35
|
+
|
33
36
|
# Ruby/DBI
|
34
37
|
begin
|
35
38
|
require 'dbi'
|
@@ -47,8 +50,3 @@ unless dbi_not_found
|
|
47
50
|
require "#{srcdir}/test_dbi_clob"
|
48
51
|
end
|
49
52
|
end
|
50
|
-
|
51
|
-
#Test::Unit::AutoRunner.run(true, true)
|
52
|
-
if defined? Test::Unit::AutoRunner
|
53
|
-
Test::Unit::AutoRunner.run()
|
54
|
-
end
|
data/test/test_appinfo.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require 'test/unit'
|
3
2
|
require File.dirname(__FILE__) + '/config'
|
4
3
|
|
5
|
-
class TestAppInfo < Test
|
4
|
+
class TestAppInfo < Minitest::Test
|
6
5
|
|
7
6
|
def setup
|
8
7
|
@conn = get_oci8_connection
|
@@ -14,7 +13,7 @@ class TestAppInfo < Test::Unit::TestCase
|
|
14
13
|
@conn.client_identifier = client_id
|
15
14
|
assert_equal(client_id, @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'CLIENT_IDENTIFIER') FROM DUAL")[0]);
|
16
15
|
# check the first character
|
17
|
-
|
16
|
+
assert_raises ArgumentError do
|
18
17
|
@conn.client_identifier = ':bad_identifier'
|
19
18
|
end
|
20
19
|
|
data/test/test_array_dml.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require 'test/unit'
|
3
2
|
require File.dirname(__FILE__) + '/config'
|
4
3
|
|
5
|
-
class TestArrayDML < Test
|
4
|
+
class TestArrayDML < Minitest::Test
|
6
5
|
def setup
|
7
6
|
@conn = get_oci8_connection
|
8
7
|
end
|
@@ -131,7 +130,7 @@ EOS
|
|
131
130
|
v_arr << i.to_s if i != max_array_size
|
132
131
|
end
|
133
132
|
cursor[1] = n_arr
|
134
|
-
|
133
|
+
assert_raises(RuntimeError) { cursor[2] = v_arr }
|
135
134
|
cursor.close
|
136
135
|
|
137
136
|
drop_table('test_table')
|
@@ -154,9 +153,9 @@ EOS
|
|
154
153
|
cursor.bind_param_array(1, [1, 2, 3])
|
155
154
|
cursor.bind_param_array(2, ['happy', 'new', 'year'])
|
156
155
|
cursor.bind_param_array(3, [Time.gm(1990,1,1), Time.gm(2000,1,1), Time.gm(2010,1,1)])
|
157
|
-
|
156
|
+
cursor.exec_array
|
158
157
|
cursor.max_array_size = 2
|
159
|
-
|
158
|
+
assert_raises(RuntimeError) { cursor.exec_array }
|
160
159
|
drop_table('test_table')
|
161
160
|
end
|
162
161
|
|
@@ -184,7 +183,7 @@ EOS
|
|
184
183
|
end
|
185
184
|
cursor[1] = n_arr
|
186
185
|
cursor[2] = v_arr
|
187
|
-
|
186
|
+
cursor.exec_array
|
188
187
|
cursor.close
|
189
188
|
|
190
189
|
cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
|
@@ -213,7 +212,7 @@ EOS
|
|
213
212
|
cursor.max_array_size = max_array_size
|
214
213
|
cursor.bind_param_array(1, nil, Fixnum)
|
215
214
|
cursor.bind_param_array(2, nil, String)
|
216
|
-
|
215
|
+
assert_raises(RuntimeError) { cursor.exec_array }
|
217
216
|
cursor.close
|
218
217
|
drop_table('test_table')
|
219
218
|
end
|
data/test/test_bind_raw.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# Low-level API
|
2
2
|
require 'oci8'
|
3
|
-
require 'test/unit'
|
4
3
|
require File.dirname(__FILE__) + '/config'
|
5
4
|
|
6
|
-
class TestBindRaw < Test
|
5
|
+
class TestBindRaw < Minitest::Test
|
7
6
|
CHECK_TARGET = [
|
8
7
|
["0123456789:;<=>?", "303132333435363738393A3B3C3D3E3F"],
|
9
8
|
["@ABCDEFGHIJKLMNO", "404142434445464748494A4B4C4D4E4F"],
|
data/test/test_bind_string.rb
CHANGED
data/test/test_bind_time.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require 'test/unit'
|
3
2
|
require File.dirname(__FILE__) + '/config'
|
4
3
|
|
5
|
-
class TestBindTime < Test
|
4
|
+
class TestBindTime < Minitest::Test
|
6
5
|
|
7
6
|
YEAR_CHECK_TARGET = [1971, 1989, 2002, 2037]
|
8
7
|
MON_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
data/test/test_break.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# High-level API
|
2
2
|
require 'oci8'
|
3
|
-
require 'test/unit'
|
4
3
|
require 'timeout'
|
5
4
|
require File.dirname(__FILE__) + '/config'
|
6
5
|
|
7
|
-
class TestBreak < Test
|
6
|
+
class TestBreak < Minitest::Test
|
8
7
|
|
9
8
|
def setup
|
10
9
|
@conn = get_oci8_connection
|
@@ -107,7 +106,7 @@ class TestBreak < Test::Unit::TestCase
|
|
107
106
|
# MRI and Rubinius 2.0.0
|
108
107
|
expected = Timeout::Error
|
109
108
|
end
|
110
|
-
|
109
|
+
assert_raises(expected) do
|
111
110
|
Timeout.timeout(1) do
|
112
111
|
@conn.exec("BEGIN DBMS_LOCK.SLEEP(5); END;")
|
113
112
|
end
|
data/test/test_clob.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require 'test/unit'
|
3
2
|
require File.dirname(__FILE__) + '/config'
|
4
3
|
|
5
|
-
class TestConnectionPool < Test
|
4
|
+
class TestConnectionPool < Minitest::Test
|
6
5
|
|
7
6
|
def create_pool(min, max, incr)
|
8
7
|
OCI8::ConnectionPool.new(min, max, incr, $dbuser, $dbpass, $dbname)
|
@@ -48,7 +47,7 @@ class TestConnectionPool < Test::Unit::TestCase
|
|
48
47
|
if cnt == 0
|
49
48
|
unless conn.non_blocking?
|
50
49
|
non_blocking = false
|
51
|
-
|
50
|
+
assert_raises(RuntimeError) do
|
52
51
|
# This should raise "Could not set non-blocking mode to a connection allocated from OCI8::ConnectionPool."
|
53
52
|
conn.non_blocking = true
|
54
53
|
end
|
data/test/test_connstr.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require 'test/unit'
|
3
2
|
require File.dirname(__FILE__) + '/config'
|
4
3
|
|
5
|
-
class TestConnStr < Test
|
4
|
+
class TestConnStr < Minitest::Test
|
6
5
|
TEST_CASES =
|
7
6
|
[
|
8
7
|
# success cases:
|
@@ -77,5 +76,3 @@ class TestConnStr < Test::Unit::TestCase
|
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
80
|
-
|
81
|
-
Test::Unit::AutoRunner.run() if $0 == __FILE__
|
data/test/test_datetime.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'oci8'
|
2
|
-
require 'test/unit'
|
3
2
|
require File.dirname(__FILE__) + '/config'
|
4
3
|
require 'scanf'
|
5
4
|
|
6
|
-
class TestDateTime < Test
|
5
|
+
class TestDateTime < Minitest::Test
|
7
6
|
|
8
7
|
def timezone_string(tzh, tzm)
|
9
8
|
if tzh >= 0
|
@@ -247,7 +246,7 @@ EOS
|
|
247
246
|
def test_timezone
|
248
247
|
begin
|
249
248
|
# temporarily change the mapping to test OCI8::BindType::Util.default_timezone.
|
250
|
-
|
249
|
+
assert_raises(ArgumentError) do
|
251
250
|
OCI8::BindType::Util.default_timezone = :invalid_value
|
252
251
|
end
|
253
252
|
|
data/test/test_dbi.rb
CHANGED
data/test/test_dbi_clob.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'dbi'
|
2
2
|
require 'oci8'
|
3
|
-
require 'test/unit'
|
4
3
|
require File.dirname(__FILE__) + '/config'
|
5
4
|
|
6
|
-
class TestDbiCLob < Test
|
5
|
+
class TestDbiCLob < Minitest::Test
|
7
6
|
|
8
7
|
def setup
|
9
8
|
@dbh = get_dbi_connection()
|
9
|
+
drop_table('test_table')
|
10
|
+
@dbh.execute('CREATE TABLE test_table (filename VARCHAR2(40), content CLOB)')
|
10
11
|
end
|
11
12
|
|
12
13
|
def test_insert
|
13
14
|
filename = File.basename($lobfile)
|
14
|
-
@dbh.do("DELETE FROM test_clob WHERE filename = :1", filename)
|
15
15
|
|
16
16
|
# insert an empty clob and get the rowid.
|
17
|
-
rowid = @dbh.execute("INSERT INTO
|
17
|
+
rowid = @dbh.execute("INSERT INTO test_table(filename, content) VALUES (:1, EMPTY_CLOB())", filename) do |sth|
|
18
18
|
sth.func(:rowid)
|
19
19
|
end
|
20
|
-
lob = @dbh.select_one("SELECT content FROM
|
20
|
+
lob = @dbh.select_one("SELECT content FROM test_table WHERE filename = :1 FOR UPDATE", filename)[0]
|
21
21
|
begin
|
22
22
|
open($lobfile) do |f|
|
23
23
|
while f.gets()
|
@@ -32,7 +32,7 @@ class TestDbiCLob < Test::Unit::TestCase
|
|
32
32
|
def test_read
|
33
33
|
filename = File.basename($lobfile)
|
34
34
|
test_insert() # first insert data.
|
35
|
-
lob = @dbh.select_one("SELECT content FROM
|
35
|
+
lob = @dbh.select_one("SELECT content FROM test_table WHERE filename = :1 FOR UPDATE", filename)[0]
|
36
36
|
begin
|
37
37
|
open($lobfile) do |f|
|
38
38
|
while buf = lob.read($lobreadnum)
|