ruby-oci8 2.2.10-x64-mingw-ucrt
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.
- checksums.yaml +7 -0
- data/.yardopts +14 -0
- data/COPYING +30 -0
- data/COPYING_old +64 -0
- data/ChangeLog +3826 -0
- data/Makefile +92 -0
- data/NEWS +1209 -0
- data/README.md +66 -0
- data/dist-files +112 -0
- data/docs/bind-array-to-in_cond.md +38 -0
- data/docs/conflicts-local-connections-and-processes.md +98 -0
- data/docs/hanging-after-inactivity.md +63 -0
- data/docs/install-binary-package.md +44 -0
- data/docs/install-full-client.md +111 -0
- data/docs/install-instant-client.md +194 -0
- data/docs/install-on-osx.md +46 -0
- data/docs/ldap-auth-and-function-interposition.md +123 -0
- data/docs/number-type-mapping.md +79 -0
- data/docs/platform-specific-issues.md +164 -0
- data/docs/report-installation-issue.md +50 -0
- data/docs/timeout-parameters.md +94 -0
- data/lib/.document +1 -0
- data/lib/dbd/OCI8.rb +591 -0
- data/lib/oci8/.document +8 -0
- data/lib/oci8/bindtype.rb +333 -0
- data/lib/oci8/check_load_error.rb +146 -0
- data/lib/oci8/compat.rb +117 -0
- data/lib/oci8/connection_pool.rb +179 -0
- data/lib/oci8/cursor.rb +605 -0
- data/lib/oci8/datetime.rb +605 -0
- data/lib/oci8/encoding-init.rb +45 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2148 -0
- data/lib/oci8/object.rb +641 -0
- data/lib/oci8/oci8.rb +756 -0
- data/lib/oci8/ocihandle.rb +591 -0
- data/lib/oci8/oracle_version.rb +153 -0
- data/lib/oci8/properties.rb +196 -0
- data/lib/oci8/version.rb +3 -0
- data/lib/oci8.rb +190 -0
- data/lib/oci8lib_310.so +0 -0
- data/lib/ruby-oci8.rb +1 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +85 -0
- data/setup.rb +1342 -0
- data/test/README.md +37 -0
- data/test/config.rb +201 -0
- data/test/setup_test_object.sql +199 -0
- data/test/setup_test_package.sql +59 -0
- data/test/test_all.rb +56 -0
- data/test/test_appinfo.rb +62 -0
- data/test/test_array_dml.rb +332 -0
- data/test/test_bind_array.rb +70 -0
- data/test/test_bind_boolean.rb +99 -0
- data/test/test_bind_integer.rb +47 -0
- data/test/test_bind_raw.rb +45 -0
- data/test/test_bind_string.rb +105 -0
- data/test/test_bind_time.rb +177 -0
- data/test/test_break.rb +125 -0
- data/test/test_clob.rb +85 -0
- data/test/test_connection_pool.rb +124 -0
- data/test/test_connstr.rb +220 -0
- data/test/test_datetime.rb +585 -0
- data/test/test_dbi.rb +365 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +103 -0
- data/test/test_error.rb +87 -0
- data/test/test_metadata.rb +2674 -0
- data/test/test_object.rb +546 -0
- data/test/test_oci8.rb +624 -0
- data/test/test_oracle_version.rb +68 -0
- data/test/test_oradate.rb +255 -0
- data/test/test_oranumber.rb +792 -0
- data/test/test_package_type.rb +981 -0
- data/test/test_properties.rb +17 -0
- data/test/test_rowid.rb +32 -0
- metadata +123 -0
data/test/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Before running unit test:
|
2
|
+
|
3
|
+
1. Connect to Oracle as sys
|
4
|
+
```shell
|
5
|
+
$ sqlplus sys/<password_of_sys> as sysdba
|
6
|
+
SQL>
|
7
|
+
```
|
8
|
+
2. Create user ruby
|
9
|
+
```sql
|
10
|
+
SQL> CREATE USER ruby IDENTIFIED BY oci8 DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
|
11
|
+
SQL> alter user ruby quota unlimited on users;
|
12
|
+
```
|
13
|
+
3. Grant the privilege to connect and execute.
|
14
|
+
```sql
|
15
|
+
SQL> GRANT connect, resource, create view, create synonym TO ruby;
|
16
|
+
SQL> GRANT execute ON dbms_lock TO ruby;
|
17
|
+
```
|
18
|
+
4. Connect as ruby user.
|
19
|
+
```shell
|
20
|
+
$ sqlplus ruby/oci8
|
21
|
+
SQL>
|
22
|
+
```
|
23
|
+
5. Create object types
|
24
|
+
```sql
|
25
|
+
SQL> @test/setup_test_object.sql
|
26
|
+
SQL> @test/setup_test_package.sql
|
27
|
+
```
|
28
|
+
6. change $dbname in test/config.rb.
|
29
|
+
|
30
|
+
Then run the following command:
|
31
|
+
```shell
|
32
|
+
$ make check
|
33
|
+
```
|
34
|
+
or
|
35
|
+
```
|
36
|
+
$ nmake check (If your compiler is MS Visual C++.)
|
37
|
+
````
|
data/test/config.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
# $dbuser must have permission to run DBMS_LOCK.SLEEP
|
2
|
+
# connect as sys
|
3
|
+
# GRANT EXECUTE ON dbms_lock TO ruby;
|
4
|
+
$dbuser = "ruby"
|
5
|
+
$dbpass = "oci8"
|
6
|
+
$dbname = nil
|
7
|
+
|
8
|
+
# for test_bind_string_as_nchar in test_encoding.rb
|
9
|
+
ENV['ORA_NCHAR_LITERAL_REPLACE'] = 'TRUE' if OCI8.client_charset_name.include? 'UTF8'
|
10
|
+
|
11
|
+
# test_clob.rb
|
12
|
+
|
13
|
+
nls_lang = ENV['NLS_LANG']
|
14
|
+
nls_lang = nls_lang.split('.')[1] unless nls_lang.nil?
|
15
|
+
nls_lang = nls_lang.upcase unless nls_lang.nil?
|
16
|
+
$lobfile = File.dirname(__FILE__) + '/../setup.rb'
|
17
|
+
$lobreadnum = 256 # counts in charactors
|
18
|
+
|
19
|
+
# don't modify below.
|
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
|
+
|
36
|
+
# $oracle_server_version: database compatible level of the Oracle server.
|
37
|
+
# $oracle_client_version: Oracle client library version for which oci8 is compiled.
|
38
|
+
# $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
|
39
|
+
conn = OCI8.new($dbuser, $dbpass, $dbname)
|
40
|
+
begin
|
41
|
+
conn.exec('select value from database_compatible_level') do |row|
|
42
|
+
$oracle_server_version = OCI8::OracleVersion.new(row[0])
|
43
|
+
end
|
44
|
+
rescue OCIError
|
45
|
+
raise if $!.code != 942 # ORA-00942: table or view does not exist
|
46
|
+
$oracle_server_version = OCI8::ORAVER_8_0
|
47
|
+
end
|
48
|
+
conn.logoff
|
49
|
+
|
50
|
+
if $oracle_server_version < OCI8.oracle_client_version
|
51
|
+
$oracle_version = $oracle_server_version
|
52
|
+
else
|
53
|
+
$oracle_version = OCI8.oracle_client_version
|
54
|
+
end
|
55
|
+
|
56
|
+
if $oracle_version < OCI8::ORAVER_8_1
|
57
|
+
$test_clob = false
|
58
|
+
else
|
59
|
+
$test_clob = true
|
60
|
+
end
|
61
|
+
|
62
|
+
begin
|
63
|
+
Time.new(2001, 1, 1, 0, 0, 0, '+00:00')
|
64
|
+
# ruby 1.9.2 or later
|
65
|
+
def convert_to_time(year, month, day, hour, minute, sec, subsec, timezone)
|
66
|
+
subsec ||= 0
|
67
|
+
if timezone
|
68
|
+
# with time zone
|
69
|
+
Time.new(year, month, day, hour, minute, sec + subsec, timezone)
|
70
|
+
else
|
71
|
+
# without time zone
|
72
|
+
Time.local(year, month, day, hour, minute, sec, subsec * 1000000)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
rescue
|
76
|
+
# ruby 1.9.1 or former
|
77
|
+
def convert_to_time(year, month, day, hour, minute, sec, subsec, timezone)
|
78
|
+
subsec ||= 0
|
79
|
+
if timezone
|
80
|
+
# with time zone
|
81
|
+
/([+-])(\d+):(\d+)/ =~ timezone
|
82
|
+
offset = ($1 + '1').to_i * ($2.to_i * 60 + $3.to_i)
|
83
|
+
if offset == 0
|
84
|
+
Time.utc(year, month, day, hour, minute, sec, subsec * 1000000)
|
85
|
+
else
|
86
|
+
tm = Time.local(year, month, day, hour, minute, sec, subsec * 1000000)
|
87
|
+
raise "Failed to convert #{str} to Time" if tm.utc_offset != offset * 60
|
88
|
+
tm
|
89
|
+
end
|
90
|
+
else
|
91
|
+
# without time zone
|
92
|
+
Time.local(year, month, day, hour, minute, sec, subsec * 1000000)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def convert_to_datetime(year, month, day, hour, minute, sec, subsec, timezone)
|
98
|
+
subsec ||= 0
|
99
|
+
utc_offset = if timezone
|
100
|
+
# with time zone
|
101
|
+
/([+-])(\d+):(\d+)/ =~ timezone
|
102
|
+
($1 + '1').to_i * ($2.to_i * 60 + $3.to_i) * 60
|
103
|
+
else
|
104
|
+
Time.local(year, month, day, hour, minute, sec).utc_offset
|
105
|
+
end
|
106
|
+
begin
|
107
|
+
DateTime.civil(year, month, day, hour, minute, sec + subsec, utc_offset.to_r / 86400)
|
108
|
+
rescue ArgumentError
|
109
|
+
raise $! if $!.to_s != 'invalid date'
|
110
|
+
# for ruby 1.8.6.
|
111
|
+
# convert to a DateTime via a String as a workaround.
|
112
|
+
if utc_offset >= 0
|
113
|
+
sign = ?+
|
114
|
+
else
|
115
|
+
sign = ?-
|
116
|
+
utc_offset = - utc_offset;
|
117
|
+
end
|
118
|
+
tz_min = utc_offset / 60
|
119
|
+
tz_hour, tz_min = tz_min.divmod 60
|
120
|
+
time_str = format("%04d-%02d-%02dT%02d:%02d:%02d.%09d%c%02d:%02d",
|
121
|
+
year, month, day, hour, minute, sec, (subsec * 1000_000_000).to_i, sign, tz_hour, tz_min)
|
122
|
+
::DateTime.parse(time_str)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
class Minitest::Test
|
127
|
+
|
128
|
+
# @!visibility private
|
129
|
+
# dirty hack to suppress "warning: constant ::Fixnum is deprecated"
|
130
|
+
Fixnum = (0.class == ::Integer) ? ::Integer : ::Fixnum
|
131
|
+
# @!visibility private
|
132
|
+
# dirty hack to suppress "warning: constant ::Bignum is deprecated"
|
133
|
+
Bignum = (0.class == ::Integer) ? ::Integer : ::Bignum
|
134
|
+
|
135
|
+
def get_oci8_connection()
|
136
|
+
OCI8.new($dbuser, $dbpass, $dbname)
|
137
|
+
rescue OCIError
|
138
|
+
raise if $!.code != 12516 && $!.code != 12520
|
139
|
+
# sleep a few second and try again if
|
140
|
+
# the error code is ORA-12516 or ORA-12520.
|
141
|
+
#
|
142
|
+
# ORA-12516 - TNS:listener could not find available handler with
|
143
|
+
# matching protocol stack
|
144
|
+
# ORA-12520 - TNS:listener could not find available handler for
|
145
|
+
# requested type of server
|
146
|
+
#
|
147
|
+
# Thanks to Christopher Jones.
|
148
|
+
#
|
149
|
+
# Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
|
150
|
+
# http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
|
151
|
+
#
|
152
|
+
sleep(5)
|
153
|
+
OCI8.new($dbuser, $dbpass, $dbname)
|
154
|
+
end
|
155
|
+
|
156
|
+
def get_dbi_connection()
|
157
|
+
DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
|
158
|
+
rescue DBI::DatabaseError
|
159
|
+
raise if $!.err != 12516 && $!.err != 12520
|
160
|
+
# same as get_oci8_connection()
|
161
|
+
sleep(5)
|
162
|
+
DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
|
163
|
+
end
|
164
|
+
|
165
|
+
def drop_table(table_name)
|
166
|
+
if $oracle_server_version < OCI8::ORAVER_10_1
|
167
|
+
# Oracle 8 - 9i
|
168
|
+
sql = "DROP TABLE #{table_name}"
|
169
|
+
else
|
170
|
+
# Oracle 10g -
|
171
|
+
sql = "DROP TABLE #{table_name} PURGE"
|
172
|
+
end
|
173
|
+
|
174
|
+
if defined? @conn
|
175
|
+
begin
|
176
|
+
@conn.exec(sql)
|
177
|
+
rescue OCIError
|
178
|
+
raise if $!.code != 942 # table or view does not exist
|
179
|
+
end
|
180
|
+
elsif instance_variable_get(:@dbh)
|
181
|
+
begin
|
182
|
+
@dbh.do(sql)
|
183
|
+
rescue DBI::DatabaseError
|
184
|
+
raise if $!.err != 942 # table or view does not exist
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end # drop_table
|
188
|
+
|
189
|
+
def drop_type(type_name)
|
190
|
+
begin
|
191
|
+
@conn.exec("DROP TYPE BODY #{type_name}")
|
192
|
+
rescue OCIError
|
193
|
+
raise if $!.code != 4043
|
194
|
+
end
|
195
|
+
begin
|
196
|
+
@conn.exec("DROP TYPE #{type_name}")
|
197
|
+
rescue OCIError
|
198
|
+
raise if $!.code != 4043
|
199
|
+
end
|
200
|
+
end # drop_type
|
201
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
drop table rb_test_obj_tab1 purge
|
2
|
+
/
|
3
|
+
drop table rb_test_obj_tab2 purge
|
4
|
+
/
|
5
|
+
drop type rb_test_obj
|
6
|
+
/
|
7
|
+
drop type rb_test_obj_elem_ary_of_ary
|
8
|
+
/
|
9
|
+
drop type rb_test_obj_elem_array
|
10
|
+
/
|
11
|
+
drop type rb_test_obj_elem
|
12
|
+
/
|
13
|
+
drop type rb_test_obj_sub
|
14
|
+
/
|
15
|
+
drop type rb_test_obj_base
|
16
|
+
/
|
17
|
+
create type rb_test_obj_elem as object (
|
18
|
+
x integer,
|
19
|
+
y integer
|
20
|
+
)
|
21
|
+
/
|
22
|
+
create or replace type rb_test_int_array as array(50) of integer
|
23
|
+
/
|
24
|
+
create or replace type rb_test_flt_array as array(50) of float
|
25
|
+
/
|
26
|
+
create or replace type rb_test_num_array as array(50) of number(10,1)
|
27
|
+
/
|
28
|
+
create or replace type rb_test_bdbl_array as array(50) of binary_double
|
29
|
+
/
|
30
|
+
create or replace type rb_test_bflt_array as array(50) of binary_float
|
31
|
+
/
|
32
|
+
create or replace type rb_test_str_array as array(50) of varchar2(50)
|
33
|
+
/
|
34
|
+
create or replace type rb_test_raw_array as array(50) of raw(50)
|
35
|
+
/
|
36
|
+
create or replace type rb_test_obj_elem_array as array(50) of rb_test_obj_elem
|
37
|
+
/
|
38
|
+
create or replace type rb_test_obj_elem_ary_of_ary as array(50) of rb_test_obj_elem_array
|
39
|
+
/
|
40
|
+
--create or replace type rb_test_date_array as array(50) of date
|
41
|
+
--/
|
42
|
+
create type rb_test_obj as object (
|
43
|
+
int_val integer,
|
44
|
+
flt_val float,
|
45
|
+
num_val number(10,1),
|
46
|
+
bdbl_val binary_double,
|
47
|
+
bflt_val binary_float,
|
48
|
+
str_val varchar2(50),
|
49
|
+
raw_val raw(50),
|
50
|
+
clob_val clob,
|
51
|
+
nclob_val nclob,
|
52
|
+
blob_val blob,
|
53
|
+
obj_val rb_test_obj_elem,
|
54
|
+
int_array_val rb_test_int_array,
|
55
|
+
flt_array_val rb_test_flt_array,
|
56
|
+
num_array_val rb_test_num_array,
|
57
|
+
bdbl_array_val rb_test_bdbl_array,
|
58
|
+
bflt_array_val rb_test_bflt_array,
|
59
|
+
str_array_val rb_test_str_array,
|
60
|
+
raw_array_val rb_test_raw_array,
|
61
|
+
obj_array_val rb_test_obj_elem_array,
|
62
|
+
obj_ary_of_ary_val rb_test_obj_elem_ary_of_ary,
|
63
|
+
date_val date,
|
64
|
+
timestamp_val timestamp(9),
|
65
|
+
timestamp_tz_val timestamp(9) with time zone,
|
66
|
+
-- date_array_val rb_test_date_array,
|
67
|
+
|
68
|
+
constructor function rb_test_obj(n number) return self as result,
|
69
|
+
static function test_object_version return integer,
|
70
|
+
static function class_func(n number) return rb_test_obj,
|
71
|
+
static procedure class_proc1(obj out rb_test_obj, n number),
|
72
|
+
static procedure class_proc2(obj in out rb_test_obj),
|
73
|
+
member function member_func return integer,
|
74
|
+
member procedure member_proc(n in integer)
|
75
|
+
)
|
76
|
+
/
|
77
|
+
create type body rb_test_obj is
|
78
|
+
constructor function rb_test_obj(n number) return self as result is
|
79
|
+
str varchar(28);
|
80
|
+
ts timestamp(9);
|
81
|
+
ts_tz timestamp(9) with time zone;
|
82
|
+
begin
|
83
|
+
str := to_char(1990 + n, 'FM0000') ||
|
84
|
+
to_char(mod(round(n) * 5, 12) + 1, 'FM00') ||
|
85
|
+
to_char(mod(round(n) * 7, 27) + 1, 'FM00') ||
|
86
|
+
to_char(mod(round(n) * 9, 24), 'FM00') ||
|
87
|
+
to_char(mod(round(n) * 11, 60), 'FM00') ||
|
88
|
+
to_char(mod(round(n) * 13, 60), 'FM00') ||
|
89
|
+
to_char(mod(round(n) * 333333333, 1000000000), 'FM000000000');
|
90
|
+
ts := to_timestamp(str, 'yyyymmddhh24missff9');
|
91
|
+
str := str || to_char(mod(round(n) * 15, 24) - 11, 'FMS00') ||
|
92
|
+
to_char(mod(round(n) * 17, 60), 'FM00');
|
93
|
+
ts_tz := to_timestamp_tz(str, 'yyyymmddhh24missff9tzhtzm');
|
94
|
+
self.int_val := n;
|
95
|
+
self.flt_val := n;
|
96
|
+
self.num_val := n;
|
97
|
+
self.bdbl_val := n;
|
98
|
+
self.bflt_val := n;
|
99
|
+
self.str_val := to_char(n);
|
100
|
+
self.raw_val := utl_raw.cast_to_raw(to_char(n));
|
101
|
+
self.clob_val := to_clob(n);
|
102
|
+
self.nclob_val := to_clob(n);
|
103
|
+
self.blob_val := to_blob(utl_raw.cast_to_raw(to_char(n)));
|
104
|
+
self.obj_val := rb_test_obj_elem(n, n + 1);
|
105
|
+
self.date_val := ts;
|
106
|
+
self.timestamp_val := ts;
|
107
|
+
self.timestamp_tz_val := ts_tz;
|
108
|
+
if self.int_val != 1 then
|
109
|
+
self.int_array_val := rb_test_int_array(n, n + 1, n + 2);
|
110
|
+
self.flt_array_val := rb_test_flt_array(n, n + 1, n + 2);
|
111
|
+
self.num_array_val := rb_test_num_array(n, n + 1, n + 2);
|
112
|
+
self.bdbl_array_val := rb_test_bdbl_array(n, n + 1, n + 2);
|
113
|
+
self.bflt_array_val := rb_test_bflt_array(n, n + 1, n + 2);
|
114
|
+
self.str_array_val := rb_test_str_array(to_char(n), to_char(n + 1), to_char(n + 2));
|
115
|
+
self.raw_array_val := rb_test_raw_array(utl_raw.cast_to_raw(to_char(n)),
|
116
|
+
utl_raw.cast_to_raw(to_char(n + 1)),
|
117
|
+
utl_raw.cast_to_raw(to_char(n + 2)));
|
118
|
+
self.obj_array_val := rb_test_obj_elem_array(rb_test_obj_elem(n + 0, n + 1),
|
119
|
+
rb_test_obj_elem(n + 1, n + 2),
|
120
|
+
rb_test_obj_elem(n + 2, n + 3));
|
121
|
+
self.obj_ary_of_ary_val := rb_test_obj_elem_ary_of_ary(self.obj_array_val);
|
122
|
+
-- self.date_array_val := rb_test_date_array(to_test_date(n),
|
123
|
+
-- to_test_date(n + 1),
|
124
|
+
-- to_test_date(n + 2));
|
125
|
+
end if;
|
126
|
+
return;
|
127
|
+
end;
|
128
|
+
|
129
|
+
static function test_object_version return integer is
|
130
|
+
begin
|
131
|
+
return 4;
|
132
|
+
end;
|
133
|
+
|
134
|
+
static function class_func(n number) return rb_test_obj is
|
135
|
+
begin
|
136
|
+
return rb_test_obj(n);
|
137
|
+
end;
|
138
|
+
|
139
|
+
static procedure class_proc1(obj out rb_test_obj, n number) is
|
140
|
+
begin
|
141
|
+
obj := rb_test_obj(n);
|
142
|
+
end;
|
143
|
+
|
144
|
+
static procedure class_proc2(obj in out rb_test_obj) is
|
145
|
+
begin
|
146
|
+
obj.int_val := obj.int_val + 1;
|
147
|
+
end;
|
148
|
+
|
149
|
+
member function member_func return integer is
|
150
|
+
begin
|
151
|
+
return int_val;
|
152
|
+
end;
|
153
|
+
|
154
|
+
member procedure member_proc(n in integer) is
|
155
|
+
begin
|
156
|
+
self.int_val := n;
|
157
|
+
end;
|
158
|
+
end;
|
159
|
+
/
|
160
|
+
create table rb_test_obj_tab1 (
|
161
|
+
n number primary key,
|
162
|
+
obj rb_test_obj
|
163
|
+
)
|
164
|
+
/
|
165
|
+
create table rb_test_obj_tab2 of rb_test_obj (
|
166
|
+
int_val primary key
|
167
|
+
)
|
168
|
+
/
|
169
|
+
declare
|
170
|
+
n number := 0;
|
171
|
+
obj rb_test_obj;
|
172
|
+
begin
|
173
|
+
loop
|
174
|
+
n := n + 1.2;
|
175
|
+
exit when n > 20;
|
176
|
+
obj := rb_test_obj(n);
|
177
|
+
insert into rb_test_obj_tab1 values (n, obj);
|
178
|
+
insert into rb_test_obj_tab2 values (obj);
|
179
|
+
end loop;
|
180
|
+
end;
|
181
|
+
/
|
182
|
+
|
183
|
+
create type rb_test_obj_base as object (
|
184
|
+
id varchar2(30)
|
185
|
+
) not final
|
186
|
+
/
|
187
|
+
create type rb_test_obj_sub under rb_test_obj_base (
|
188
|
+
subid varchar2(30)
|
189
|
+
) final
|
190
|
+
/
|
191
|
+
create or replace function rb_test_obj_get_object(get_base integer) return rb_test_obj_base is
|
192
|
+
begin
|
193
|
+
if get_base = 0 then
|
194
|
+
return rb_test_obj_base('base');
|
195
|
+
else
|
196
|
+
return rb_test_obj_sub('sub', 'subid');
|
197
|
+
end if;
|
198
|
+
end;
|
199
|
+
/
|
@@ -0,0 +1,59 @@
|
|
1
|
+
create or replace package rb_test_pkg is
|
2
|
+
package_version pls_integer := 1;
|
3
|
+
|
4
|
+
type array_of_integer is array(50) of integer;
|
5
|
+
type table_of_pls_integer is table of pls_integer;
|
6
|
+
type table_of_boolean is table of boolean;
|
7
|
+
type indexed_table_of_varchar2 is table of varchar2(10) index by varchar2(5);
|
8
|
+
type rec1 is record (i pls_integer, j integer);
|
9
|
+
type rec2 is record (b boolean, it indexed_table_of_varchar2, rec rec1);
|
10
|
+
type table_of_rec1 is table of rec1;
|
11
|
+
type table_of_rec2 is table of rec2;
|
12
|
+
|
13
|
+
function sum_table_of_pls_integer(tbl in table_of_pls_integer) return pls_integer;
|
14
|
+
function add_rec1_values(tbl in table_of_rec1) return pls_integer;
|
15
|
+
procedure out_rec1_values(tbl out table_of_rec1);
|
16
|
+
end;
|
17
|
+
/
|
18
|
+
create or replace package body rb_test_pkg is
|
19
|
+
function sum_table_of_pls_integer(tbl in table_of_pls_integer) return pls_integer is
|
20
|
+
i pls_integer;
|
21
|
+
ret pls_integer := 0;
|
22
|
+
begin
|
23
|
+
for i in tbl.first..tbl.last loop
|
24
|
+
ret := ret + tbl(i);
|
25
|
+
end loop;
|
26
|
+
return ret;
|
27
|
+
end;
|
28
|
+
|
29
|
+
function add_rec1_values(tbl in table_of_rec1) return pls_integer is
|
30
|
+
i pls_integer;
|
31
|
+
ret pls_integer := 0;
|
32
|
+
begin
|
33
|
+
for i in tbl.first..tbl.last loop
|
34
|
+
ret := ret + nvl(tbl(i).i, 0) + nvl(tbl(i).j, 0);
|
35
|
+
end loop;
|
36
|
+
return ret;
|
37
|
+
end;
|
38
|
+
|
39
|
+
procedure out_rec1_values(tbl out table_of_rec1) is
|
40
|
+
i pls_integer;
|
41
|
+
rec1val rec1;
|
42
|
+
begin
|
43
|
+
tbl := table_of_rec1();
|
44
|
+
for i in 1..20 loop
|
45
|
+
tbl.extend;
|
46
|
+
if i mod 6 != 0 then
|
47
|
+
if i mod 3 != 0 then
|
48
|
+
rec1val.i := i;
|
49
|
+
rec1val.j := i;
|
50
|
+
else
|
51
|
+
rec1val.i := null;
|
52
|
+
rec1val.j := null;
|
53
|
+
end if;
|
54
|
+
tbl(i) := rec1val;
|
55
|
+
end if;
|
56
|
+
end loop;
|
57
|
+
end;
|
58
|
+
end;
|
59
|
+
/
|
data/test/test_all.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
srcdir = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'oci8'
|
4
|
+
require "#{srcdir}/config"
|
5
|
+
|
6
|
+
require "#{srcdir}/test_oradate"
|
7
|
+
require "#{srcdir}/test_oranumber"
|
8
|
+
require "#{srcdir}/test_bind_array.rb"
|
9
|
+
require "#{srcdir}/test_bind_string"
|
10
|
+
require "#{srcdir}/test_bind_time"
|
11
|
+
require "#{srcdir}/test_bind_raw"
|
12
|
+
require "#{srcdir}/test_bind_integer"
|
13
|
+
if $test_clob
|
14
|
+
require "#{srcdir}/test_clob"
|
15
|
+
end
|
16
|
+
|
17
|
+
require "#{srcdir}/test_break"
|
18
|
+
require "#{srcdir}/test_oci8"
|
19
|
+
require "#{srcdir}/test_datetime"
|
20
|
+
require "#{srcdir}/test_connstr"
|
21
|
+
require "#{srcdir}/test_metadata"
|
22
|
+
require "#{srcdir}/test_array_dml"
|
23
|
+
require "#{srcdir}/test_rowid"
|
24
|
+
require "#{srcdir}/test_appinfo"
|
25
|
+
require "#{srcdir}/test_oracle_version"
|
26
|
+
require "#{srcdir}/test_error"
|
27
|
+
require "#{srcdir}/test_connection_pool"
|
28
|
+
require "#{srcdir}/test_object"
|
29
|
+
require "#{srcdir}/test_properties.rb"
|
30
|
+
|
31
|
+
if OCI8.respond_to? :encoding
|
32
|
+
require "#{srcdir}/test_encoding"
|
33
|
+
end
|
34
|
+
|
35
|
+
if $oracle_version >= OCI8::ORAVER_12_1
|
36
|
+
require "#{srcdir}/test_package_type"
|
37
|
+
require "#{srcdir}/test_bind_boolean.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Ruby/DBI
|
41
|
+
begin
|
42
|
+
require 'dbi'
|
43
|
+
rescue LoadError
|
44
|
+
begin
|
45
|
+
require 'rubygems'
|
46
|
+
require 'dbi'
|
47
|
+
rescue LoadError
|
48
|
+
dbi_not_found = true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
unless dbi_not_found
|
52
|
+
require "#{srcdir}/test_dbi"
|
53
|
+
if $test_clob
|
54
|
+
require "#{srcdir}/test_dbi_clob"
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'oci8'
|
2
|
+
require File.dirname(__FILE__) + '/config'
|
3
|
+
|
4
|
+
class TestAppInfo < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@conn = get_oci8_connection
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_set_client_identifier
|
11
|
+
# set client_id
|
12
|
+
client_id = "ruby-oci8:#{Process.pid()}"
|
13
|
+
@conn.client_identifier = client_id
|
14
|
+
assert_equal(client_id, @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'CLIENT_IDENTIFIER') FROM DUAL")[0]);
|
15
|
+
# check the first character
|
16
|
+
assert_raises ArgumentError do
|
17
|
+
@conn.client_identifier = ':bad_identifier'
|
18
|
+
end
|
19
|
+
|
20
|
+
# clear client_id
|
21
|
+
@conn.client_identifier = nil
|
22
|
+
assert_nil(@conn.select_one("SELECT SYS_CONTEXT('USERENV', 'CLIENT_IDENTIFIER') FROM DUAL")[0]);
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_set_module
|
26
|
+
# FIXME: check again after upgrading Oracle 9.2 to 9.2.0.4.
|
27
|
+
return if @conn.oracle_server_version < OCI8::ORAVER_10_1
|
28
|
+
|
29
|
+
# set module
|
30
|
+
@conn.module = 'ruby-oci8'
|
31
|
+
assert_equal('ruby-oci8', @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'MODULE') FROM DUAL")[0]);
|
32
|
+
# clear module
|
33
|
+
@conn.module = nil
|
34
|
+
assert_nil(@conn.select_one("SELECT SYS_CONTEXT('USERENV', 'MODULE') FROM DUAL")[0]);
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_set_action
|
38
|
+
# FIXME: check again after upgrading Oracle 9.2 to 9.2.0.4.
|
39
|
+
return if @conn.oracle_server_version < OCI8::ORAVER_10_1
|
40
|
+
|
41
|
+
# set action
|
42
|
+
@conn.action = 'test_set_action'
|
43
|
+
assert_equal('test_set_action', @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'ACTION') FROM DUAL")[0]);
|
44
|
+
# clear action
|
45
|
+
@conn.action = nil
|
46
|
+
assert_nil(@conn.select_one("SELECT SYS_CONTEXT('USERENV', 'ACTION') FROM DUAL")[0]);
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_set_client_info
|
50
|
+
# set client_info
|
51
|
+
client_info = "ruby-oci8:#{Process.pid()}"
|
52
|
+
@conn.client_info = client_info
|
53
|
+
assert_equal(client_info, @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'CLIENT_INFO') FROM DUAL")[0]);
|
54
|
+
# clear client_info
|
55
|
+
@conn.client_info = nil
|
56
|
+
assert_nil(@conn.select_one("SELECT SYS_CONTEXT('USERENV', 'CLIENT_INFO') FROM DUAL")[0]);
|
57
|
+
end
|
58
|
+
|
59
|
+
def teardown
|
60
|
+
@conn.logoff
|
61
|
+
end
|
62
|
+
end
|