ruby-oci8 2.2.10-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,333 @@
|
|
1
|
+
#--
|
2
|
+
# bindtype.rb -- OCI8::BindType
|
3
|
+
#
|
4
|
+
# Copyright (C) 2009-2011 KUBO Takehiro <kubo@jiubao.org>
|
5
|
+
#++
|
6
|
+
|
7
|
+
#
|
8
|
+
class OCI8
|
9
|
+
module BindType
|
10
|
+
Mapping = {}
|
11
|
+
|
12
|
+
class Base
|
13
|
+
def self.create(con, val, param, max_array_size)
|
14
|
+
self.new(con, val, param, max_array_size)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# get/set Date
|
19
|
+
class Date < OCI8::BindType::OraDate
|
20
|
+
def set(val)
|
21
|
+
super(val && ::OraDate.new(val.year, val.mon, val.mday))
|
22
|
+
end
|
23
|
+
def get()
|
24
|
+
(val = super()) && val.to_date
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class BigDecimal < OCI8::BindType::OraNumber
|
29
|
+
@@bigdecimal_is_required = false
|
30
|
+
def get()
|
31
|
+
unless @@bigdecimal_is_required
|
32
|
+
require 'bigdecimal'
|
33
|
+
@@bigdecimal_is_required = true
|
34
|
+
end
|
35
|
+
(val = super()) && val.to_d
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Rational < OCI8::BindType::OraNumber
|
40
|
+
@@rational_is_required = false
|
41
|
+
def get()
|
42
|
+
unless @@rational_is_required
|
43
|
+
require 'rational'
|
44
|
+
@@rational_is_required = true
|
45
|
+
end
|
46
|
+
(val = super()) && val.to_r
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class BasicNumberType < OCI8::BindType::OraNumber
|
51
|
+
def get()
|
52
|
+
(val = super()) && (val.has_fractional_part? ? val.to_f : val.to_i)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# get/set Number (for OCI8::SQLT_NUM)
|
57
|
+
class Number
|
58
|
+
def self.create(con, val, param, max_array_size)
|
59
|
+
if param.is_a? OCI8::Metadata::Base
|
60
|
+
precision = param.precision
|
61
|
+
scale = param.scale
|
62
|
+
end
|
63
|
+
if scale == -127
|
64
|
+
if precision == 0
|
65
|
+
# NUMBER declared without its scale and precision. (Oracle 9.2.0.3 or above)
|
66
|
+
klass = OCI8::BindType::Mapping[:number_no_prec_setting]
|
67
|
+
else
|
68
|
+
# FLOAT or FLOAT(p)
|
69
|
+
klass = OCI8::BindType::Float
|
70
|
+
end
|
71
|
+
elsif scale == 0
|
72
|
+
if precision == 0
|
73
|
+
# NUMBER whose scale and precision is unknown
|
74
|
+
# or
|
75
|
+
# NUMBER declared without its scale and precision. (Oracle 9.2.0.2 or below)
|
76
|
+
klass = OCI8::BindType::Mapping[:number_unknown_prec]
|
77
|
+
else
|
78
|
+
# NUMBER(p, 0)
|
79
|
+
klass = OCI8::BindType::Integer
|
80
|
+
end
|
81
|
+
else
|
82
|
+
# NUMBER(p, s)
|
83
|
+
if precision < 15 # the precision of double.
|
84
|
+
klass = OCI8::BindType::Float
|
85
|
+
else
|
86
|
+
# use BigDecimal instead
|
87
|
+
klass = OCI8::BindType::BigDecimal
|
88
|
+
end
|
89
|
+
end
|
90
|
+
klass.new(con, val, nil, max_array_size)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class String
|
95
|
+
# 1333 <= ceil(4000 / 3). 4000 is max size of char. 3 is NLS ratio of UTF-8.
|
96
|
+
@@minimum_bind_length = 1333
|
97
|
+
|
98
|
+
def self.minimum_bind_length
|
99
|
+
@@minimum_bind_length
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.minimum_bind_length=(val)
|
103
|
+
@@minimum_bind_length = val
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.create(con, val, param, max_array_size)
|
107
|
+
case param
|
108
|
+
when Hash
|
109
|
+
param[:length_semantics] = OCI8::properties[:length_semantics] unless param.has_key? :length_semantics
|
110
|
+
unless param[:length]
|
111
|
+
if val.respond_to? :to_str
|
112
|
+
val = val.to_str
|
113
|
+
if param[:length_semantics] == :char
|
114
|
+
# character semantics
|
115
|
+
param[:length] = val.size
|
116
|
+
else
|
117
|
+
# byte semantics
|
118
|
+
if OCI8.encoding != val.encoding
|
119
|
+
# If the string encoding is different with NLS_LANG character set,
|
120
|
+
# convert it to get the length.
|
121
|
+
val = val.encode(OCI8.encoding)
|
122
|
+
end
|
123
|
+
param[:length] = val.bytesize
|
124
|
+
end
|
125
|
+
else
|
126
|
+
param[:length] = @@minimum_bind_length
|
127
|
+
end
|
128
|
+
end
|
129
|
+
# use the default value when :nchar is not set explicitly.
|
130
|
+
param[:nchar] = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
|
131
|
+
when OCI8::Metadata::Base
|
132
|
+
case param.data_type
|
133
|
+
when :char, :varchar2
|
134
|
+
length_semantics = OCI8.properties[:length_semantics]
|
135
|
+
if length_semantics == :char
|
136
|
+
length = param.char_size
|
137
|
+
else
|
138
|
+
length = param.data_size * OCI8.nls_ratio
|
139
|
+
end
|
140
|
+
param = {
|
141
|
+
:length => length,
|
142
|
+
:length_semantics => length_semantics,
|
143
|
+
:nchar => (param.charset_form == :nchar),
|
144
|
+
}
|
145
|
+
when :raw
|
146
|
+
# HEX needs twice space.
|
147
|
+
param = {:length => param.data_size * 2}
|
148
|
+
else
|
149
|
+
param = {:length => @@minimum_bind_length}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
self.new(con, val, param, max_array_size)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class RAW
|
157
|
+
def self.create(con, val, param, max_array_size)
|
158
|
+
case param
|
159
|
+
when Hash
|
160
|
+
unless param[:length]
|
161
|
+
if val.respond_to? :to_str
|
162
|
+
val = val.to_str
|
163
|
+
param[:length] = val.bytesize
|
164
|
+
else
|
165
|
+
param[:length] = 400
|
166
|
+
end
|
167
|
+
end
|
168
|
+
when OCI8::Metadata::Base
|
169
|
+
param = {:length => param.data_size}
|
170
|
+
end
|
171
|
+
self.new(con, val, param, max_array_size)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class CLOB
|
176
|
+
def self.create(con, val, param, max_array_size)
|
177
|
+
if param.is_a? OCI8::Metadata::Base and param.charset_form == :nchar
|
178
|
+
OCI8::BindType::NCLOB.new(con, val, nil, max_array_size)
|
179
|
+
else
|
180
|
+
OCI8::BindType::CLOB.new(con, val, nil, max_array_size)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end # BindType
|
185
|
+
end
|
186
|
+
|
187
|
+
# bind or explicitly define
|
188
|
+
OCI8::BindType::Mapping[String] = OCI8::BindType::String
|
189
|
+
OCI8::BindType::Mapping[OraNumber] = OCI8::BindType::OraNumber
|
190
|
+
OCI8::BindType::Mapping['BigDecimal'] = OCI8::BindType::BigDecimal
|
191
|
+
OCI8::BindType::Mapping['Rational'] = OCI8::BindType::Rational
|
192
|
+
OCI8::BindType::Mapping[Float] = OCI8::BindType::Float
|
193
|
+
OCI8::BindType::Mapping[Integer] = OCI8::BindType::Integer
|
194
|
+
unless 0.class == Integer
|
195
|
+
# ruby before integer unification
|
196
|
+
OCI8::BindType::Mapping[Fixnum] = OCI8::BindType::Integer
|
197
|
+
OCI8::BindType::Mapping[Bignum] = OCI8::BindType::Integer
|
198
|
+
end
|
199
|
+
OCI8::BindType::Mapping[OraDate] = OCI8::BindType::OraDate
|
200
|
+
OCI8::BindType::Mapping[Time] = OCI8::BindType::Time
|
201
|
+
OCI8::BindType::Mapping[Date] = OCI8::BindType::Date
|
202
|
+
OCI8::BindType::Mapping[DateTime] = OCI8::BindType::DateTime
|
203
|
+
OCI8::BindType::Mapping[OCI8::CLOB] = OCI8::BindType::CLOB
|
204
|
+
OCI8::BindType::Mapping[OCI8::NCLOB] = OCI8::BindType::NCLOB
|
205
|
+
OCI8::BindType::Mapping[OCI8::BLOB] = OCI8::BindType::BLOB
|
206
|
+
OCI8::BindType::Mapping[OCI8::BFILE] = OCI8::BindType::BFILE
|
207
|
+
OCI8::BindType::Mapping[OCI8::Cursor] = OCI8::BindType::Cursor
|
208
|
+
if defined? OCI8::BindType::Boolean
|
209
|
+
OCI8::BindType::Mapping[TrueClass] = OCI8::BindType::Boolean
|
210
|
+
OCI8::BindType::Mapping[FalseClass] = OCI8::BindType::Boolean
|
211
|
+
end
|
212
|
+
|
213
|
+
# implicitly define
|
214
|
+
|
215
|
+
# datatype type size prec scale
|
216
|
+
# -------------------------------------------------
|
217
|
+
# CHAR(1) SQLT_AFC 1 0 0
|
218
|
+
# CHAR(10) SQLT_AFC 10 0 0
|
219
|
+
OCI8::BindType::Mapping[:char] = OCI8::BindType::String
|
220
|
+
|
221
|
+
# datatype type size prec scale
|
222
|
+
# -------------------------------------------------
|
223
|
+
# VARCHAR(1) SQLT_CHR 1 0 0
|
224
|
+
# VARCHAR(10) SQLT_CHR 10 0 0
|
225
|
+
# VARCHAR2(1) SQLT_CHR 1 0 0
|
226
|
+
# VARCHAR2(10) SQLT_CHR 10 0 0
|
227
|
+
OCI8::BindType::Mapping[:varchar2] = OCI8::BindType::String
|
228
|
+
|
229
|
+
# datatype type size prec scale
|
230
|
+
# -------------------------------------------------
|
231
|
+
# RAW(1) SQLT_BIN 1 0 0
|
232
|
+
# RAW(10) SQLT_BIN 10 0 0
|
233
|
+
OCI8::BindType::Mapping[:raw] = OCI8::BindType::RAW
|
234
|
+
|
235
|
+
# datatype type size prec scale
|
236
|
+
# -------------------------------------------------
|
237
|
+
# LONG SQLT_LNG 0 0 0
|
238
|
+
OCI8::BindType::Mapping[:long] = OCI8::BindType::Long
|
239
|
+
|
240
|
+
# datatype type size prec scale
|
241
|
+
# -------------------------------------------------
|
242
|
+
# LONG RAW SQLT_LBI 0 0 0
|
243
|
+
OCI8::BindType::Mapping[:long_raw] = OCI8::BindType::LongRaw
|
244
|
+
|
245
|
+
# datatype type size prec scale
|
246
|
+
# -------------------------------------------------
|
247
|
+
# CLOB SQLT_CLOB 4000 0 0
|
248
|
+
OCI8::BindType::Mapping[:clob] = OCI8::BindType::CLOB
|
249
|
+
OCI8::BindType::Mapping[:nclob] = OCI8::BindType::NCLOB
|
250
|
+
|
251
|
+
# datatype type size prec scale
|
252
|
+
# -------------------------------------------------
|
253
|
+
# BLOB SQLT_BLOB 4000 0 0
|
254
|
+
OCI8::BindType::Mapping[:blob] = OCI8::BindType::BLOB
|
255
|
+
|
256
|
+
# datatype type size prec scale
|
257
|
+
# -------------------------------------------------
|
258
|
+
# BFILE SQLT_BFILE 4000 0 0
|
259
|
+
OCI8::BindType::Mapping[:bfile] = OCI8::BindType::BFILE
|
260
|
+
|
261
|
+
# datatype type size prec scale
|
262
|
+
# -------------------------------------------------
|
263
|
+
# DATE SQLT_DAT 7 0 0
|
264
|
+
OCI8::BindType::Mapping[:date] = OCI8::BindType::Time
|
265
|
+
|
266
|
+
OCI8::BindType::Mapping[:timestamp] = OCI8::BindType::Time
|
267
|
+
OCI8::BindType::Mapping[:timestamp_tz] = OCI8::BindType::Time
|
268
|
+
OCI8::BindType::Mapping[:timestamp_ltz] = OCI8::BindType::Time
|
269
|
+
OCI8::BindType::Mapping[:interval_ym] = OCI8::BindType::IntervalYM
|
270
|
+
OCI8::BindType::Mapping[:interval_ds] = OCI8::BindType::IntervalDS
|
271
|
+
|
272
|
+
# datatype type size prec scale
|
273
|
+
# -------------------------------------------------
|
274
|
+
# ROWID SQLT_RDD 4 0 0
|
275
|
+
OCI8::BindType::Mapping[:rowid] = OCI8::BindType::String
|
276
|
+
|
277
|
+
# datatype type size prec scale
|
278
|
+
# -----------------------------------------------------
|
279
|
+
# FLOAT SQLT_NUM 22 126 -127
|
280
|
+
# FLOAT(1) SQLT_NUM 22 1 -127
|
281
|
+
# FLOAT(126) SQLT_NUM 22 126 -127
|
282
|
+
# DOUBLE PRECISION SQLT_NUM 22 126 -127
|
283
|
+
# REAL SQLT_NUM 22 63 -127
|
284
|
+
# NUMBER SQLT_NUM 22 0 0
|
285
|
+
# NUMBER(1) SQLT_NUM 22 1 0
|
286
|
+
# NUMBER(38) SQLT_NUM 22 38 0
|
287
|
+
# NUMBER(1, 0) SQLT_NUM 22 1 0
|
288
|
+
# NUMBER(38, 0) SQLT_NUM 22 38 0
|
289
|
+
# NUMERIC SQLT_NUM 22 38 0
|
290
|
+
# INT SQLT_NUM 22 38 0
|
291
|
+
# INTEGER SQLT_NUM 22 38 0
|
292
|
+
# SMALLINT SQLT_NUM 22 38 0
|
293
|
+
OCI8::BindType::Mapping[:number] = OCI8::BindType::Number
|
294
|
+
|
295
|
+
# mapping for calculated number values.
|
296
|
+
#
|
297
|
+
# for example:
|
298
|
+
# select col1 * 1.1 from tab1;
|
299
|
+
#
|
300
|
+
# For Oracle 9.2.0.2 or below, this is also used for NUMBER
|
301
|
+
# datatypes that have no explicit setting of their precision
|
302
|
+
# and scale.
|
303
|
+
#
|
304
|
+
# The default mapping is Float for ruby-oci8 1.0, OraNumber for 2.0.0 ~ 2.0.2,
|
305
|
+
# BigDecimal for 2.0.3 ~.
|
306
|
+
OCI8::BindType::Mapping[:number_unknown_prec] = OCI8::BindType::BigDecimal
|
307
|
+
|
308
|
+
# mapping for number without precision and scale.
|
309
|
+
#
|
310
|
+
# for example:
|
311
|
+
# create table tab1 (col1 number);
|
312
|
+
# select col1 from tab1;
|
313
|
+
#
|
314
|
+
# note: This is available only on Oracle 9.2.0.3 or above.
|
315
|
+
# see: Oracle 9.2.0.x Patch Set Notes.
|
316
|
+
#
|
317
|
+
# The default mapping is Float for ruby-oci8 1.0, OraNumber for 2.0.0 ~ 2.0.2,
|
318
|
+
# BigDecimal for 2.0.3 ~.
|
319
|
+
OCI8::BindType::Mapping[:number_no_prec_setting] = OCI8::BindType::BigDecimal
|
320
|
+
|
321
|
+
if defined? OCI8::BindType::BinaryDouble
|
322
|
+
OCI8::BindType::Mapping[:binary_float] = OCI8::BindType::BinaryDouble
|
323
|
+
OCI8::BindType::Mapping[:binary_double] = OCI8::BindType::BinaryDouble
|
324
|
+
else
|
325
|
+
OCI8::BindType::Mapping[:binary_float] = OCI8::BindType::Float
|
326
|
+
OCI8::BindType::Mapping[:binary_double] = OCI8::BindType::Float
|
327
|
+
end
|
328
|
+
|
329
|
+
# Cursor
|
330
|
+
OCI8::BindType::Mapping[:cursor] = OCI8::BindType::Cursor
|
331
|
+
|
332
|
+
# XMLType (This mapping will be changed before release.)
|
333
|
+
OCI8::BindType::Mapping[:xmltype] = OCI8::BindType::Long
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# This file is loaded only on LoadError.
|
2
|
+
|
3
|
+
class OCI8
|
4
|
+
module Util
|
5
|
+
|
6
|
+
case RUBY_PLATFORM
|
7
|
+
when /mswin32|cygwin|mingw32|bccwin32/
|
8
|
+
|
9
|
+
require 'fiddle/import'
|
10
|
+
require 'fiddle/types'
|
11
|
+
|
12
|
+
extend Fiddle::Importer
|
13
|
+
dlload 'kernel32.dll'
|
14
|
+
include Fiddle::BasicTypes
|
15
|
+
include Fiddle::Win32Types
|
16
|
+
|
17
|
+
typealias "HANDLE", "void*"
|
18
|
+
typealias "HMODULE", "void*"
|
19
|
+
extern "DWORD GetModuleFileNameA(HMODULE, LPSTR, DWORD)"
|
20
|
+
extern "UINT GetSystemDirectoryA(LPCSTR, UINT)"
|
21
|
+
extern "UINT GetWindowsDirectoryA(LPCSTR, UINT)"
|
22
|
+
extern "HMODULE LoadLibraryExA(LPCSTR, HANDLE, DWORD)"
|
23
|
+
extern "BOOL FreeLibrary(HMODULE)"
|
24
|
+
|
25
|
+
MAX_PATH = 260
|
26
|
+
DONT_RESOLVE_DLL_REFERENCES = 0x00000001
|
27
|
+
|
28
|
+
def self.check_os_specific_load_error(exc)
|
29
|
+
case exc.message
|
30
|
+
when /^OCI\.DLL: 193\(/, /^193: / # "OCI.DLL: 193(%1 is not a valid Win32 application.)" in English
|
31
|
+
check_win32_pe_arch(exc.message.split(' - ')[1], "ruby-oci8")
|
32
|
+
dll_load_path_list.each do |path|
|
33
|
+
check_win32_pe_arch(File.join(path, '\OCI.DLL'), "Oracle client")
|
34
|
+
end
|
35
|
+
when /^OCI.DLL: 126\(/, /^126: / # "OCI.DLL: 126(The specified module could not be found.)" in English
|
36
|
+
oci_dll_files = dll_load_path_list.inject([]) do |files, path|
|
37
|
+
file = File.join(path, '\OCI.DLL')
|
38
|
+
files << file if File.exist?(file)
|
39
|
+
files
|
40
|
+
end
|
41
|
+
if oci_dll_files.empty?
|
42
|
+
raise LoadError, "Cannot find OCI.DLL in PATH."
|
43
|
+
end
|
44
|
+
if oci_dll_files.none? {|file| open(file, 'rb') {true} rescue false}
|
45
|
+
raise LoadError, "OCI.DLL in PATH isn't readable."
|
46
|
+
end
|
47
|
+
first_error = nil
|
48
|
+
oci_dll_files.each do |file|
|
49
|
+
begin
|
50
|
+
check_win32_pe_arch(file, "Oracle client")
|
51
|
+
valid_arch = true
|
52
|
+
rescue LoadError
|
53
|
+
first_error ||= $!
|
54
|
+
valid_arch = false
|
55
|
+
end
|
56
|
+
if valid_arch
|
57
|
+
handle = LoadLibraryExA(file, nil, DONT_RESOLVE_DLL_REFERENCES)
|
58
|
+
unless handle.null?
|
59
|
+
FreeLibrary(handle)
|
60
|
+
raise LoadError, <<EOS
|
61
|
+
Cannot find DLLs depended by #{file}.
|
62
|
+
See http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md#Windows
|
63
|
+
EOS
|
64
|
+
end
|
65
|
+
break
|
66
|
+
end
|
67
|
+
end
|
68
|
+
raise first_error if first_error
|
69
|
+
end
|
70
|
+
end # self.check_os_specific_load_error
|
71
|
+
|
72
|
+
def self.dll_load_path_list
|
73
|
+
buf = "\0" * MAX_PATH
|
74
|
+
paths = []
|
75
|
+
paths << buf[0, GetModuleFileNameA(nil, buf, MAX_PATH)].force_encoding("locale").gsub(/\\[^\\]*$/, '')
|
76
|
+
paths << buf[0, GetSystemDirectoryA(buf, MAX_PATH)].force_encoding("locale")
|
77
|
+
paths << buf[0, GetWindowsDirectoryA(buf, MAX_PATH)].force_encoding("locale")
|
78
|
+
paths << "."
|
79
|
+
paths + (ENV['PATH'].split(';').reject {|path| path.empty?})
|
80
|
+
end # self.dll_load_path_list
|
81
|
+
|
82
|
+
def self.check_win32_pe_arch(filename, package)
|
83
|
+
open(filename, 'rb') do |f|
|
84
|
+
# DOS header.
|
85
|
+
if f.read(2) == 'MZ'
|
86
|
+
f.seek(60, IO::SEEK_SET)
|
87
|
+
pe_offset = f.read(4).unpack('V')[0]
|
88
|
+
f.seek(pe_offset)
|
89
|
+
# PE header.
|
90
|
+
if f.read(4) == "PE\000\000"
|
91
|
+
case f.read(2).unpack('v')[0]
|
92
|
+
when 0x8664
|
93
|
+
if [nil].pack('P').size == 4
|
94
|
+
raise LoadError, "\"#{filename}\" is x64 DLL. Use 32-bit #{package} instead."
|
95
|
+
end
|
96
|
+
return true
|
97
|
+
when 0x014c
|
98
|
+
if [nil].pack('P').size == 8
|
99
|
+
raise LoadError, "\"#{filename}\" is 32-bit DLL. Use x64 #{package} instead."
|
100
|
+
end
|
101
|
+
return true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
raise LoadError, "\"#{filename}\" is not a valid Win32 application."
|
106
|
+
end
|
107
|
+
nil
|
108
|
+
rescue
|
109
|
+
nil
|
110
|
+
end # self.check_win32_pe_arch
|
111
|
+
|
112
|
+
when /linux/
|
113
|
+
|
114
|
+
def self.check_os_specific_load_error(exc)
|
115
|
+
case exc.message
|
116
|
+
when /^libaio\.so\.1:/ # "libaio.so.1: cannot open shared object file: No such file or directory" in English
|
117
|
+
install_cmd = if File.executable? '/usr/bin/apt-get'
|
118
|
+
'apt-get install libaio1'
|
119
|
+
elsif File.executable? '/usr/bin/yum'
|
120
|
+
'yum install libaio'
|
121
|
+
end
|
122
|
+
if install_cmd
|
123
|
+
raise LoadError, "You need to install libaio.so.1. Run '#{install_cmd}'."
|
124
|
+
else
|
125
|
+
raise LoadError, "You need to install libaio.so.1."
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end # self.check_os_specific_load_error
|
129
|
+
|
130
|
+
else
|
131
|
+
|
132
|
+
def self.check_os_specific_load_error(exc)
|
133
|
+
end
|
134
|
+
|
135
|
+
end # case RUBY_PLATFORM
|
136
|
+
|
137
|
+
def self.check_load_error(exc)
|
138
|
+
check_os_specific_load_error(exc)
|
139
|
+
case exc.message
|
140
|
+
when /^OCI Library Initialization Error/
|
141
|
+
# TODO
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end # module Util
|
146
|
+
end
|
data/lib/oci8/compat.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#
|
2
|
+
# add compatible code with old versions.
|
3
|
+
#
|
4
|
+
|
5
|
+
OCI_STMT_SELECT = :select_stmt
|
6
|
+
OCI_STMT_UPDATE = :update_stmt
|
7
|
+
OCI_STMT_DELETE = :delete_stmt
|
8
|
+
OCI_STMT_INSERT = :insert_stmt
|
9
|
+
OCI_STMT_CREATE = :create_stmt
|
10
|
+
OCI_STMT_DROP = :drop_stmt
|
11
|
+
OCI_STMT_ALTER = :alter_stmt
|
12
|
+
OCI_STMT_BEGIN = :begin_stmt
|
13
|
+
OCI_STMT_DECLARE = :declare_stmt
|
14
|
+
|
15
|
+
class OCI8
|
16
|
+
|
17
|
+
STMT_SELECT = :select_stmt
|
18
|
+
STMT_UPDATE = :update_stmt
|
19
|
+
STMT_DELETE = :delete_stmt
|
20
|
+
STMT_INSERT = :insert_stmt
|
21
|
+
STMT_CREATE = :create_stmt
|
22
|
+
STMT_DROP = :drop_stmt
|
23
|
+
STMT_ALTER = :alter_stmt
|
24
|
+
STMT_BEGIN = :begin_stmt
|
25
|
+
STMT_DECLARE = :declare_stmt
|
26
|
+
|
27
|
+
RAW = :raw
|
28
|
+
|
29
|
+
# varchar, varchar2
|
30
|
+
SQLT_CHR = :varchar2
|
31
|
+
# number, double precision, float, real, numeric, int, integer, smallint
|
32
|
+
SQLT_NUM = :number
|
33
|
+
# long
|
34
|
+
SQLT_LNG = :long
|
35
|
+
# date
|
36
|
+
SQLT_DAT = :date
|
37
|
+
# raw
|
38
|
+
SQLT_BIN = :raw
|
39
|
+
# long raw
|
40
|
+
SQLT_LBI = :long_raw
|
41
|
+
# char
|
42
|
+
SQLT_AFC = :char
|
43
|
+
# binary_float
|
44
|
+
SQLT_IBFLOAT = :binary_float
|
45
|
+
# binary_double
|
46
|
+
SQLT_IBDOUBLE = :binary_double
|
47
|
+
# rowid
|
48
|
+
SQLT_RDD = :rowid
|
49
|
+
# clob
|
50
|
+
SQLT_CLOB = :clob
|
51
|
+
# blob
|
52
|
+
SQLT_BLOB = :blob
|
53
|
+
# bfile
|
54
|
+
SQLT_BFILE = :bfile
|
55
|
+
# ref cursor
|
56
|
+
SQLT_RSET = 116
|
57
|
+
# timestamp
|
58
|
+
SQLT_TIMESTAMP = :timestamp
|
59
|
+
# timestamp with time zone
|
60
|
+
SQLT_TIMESTAMP_TZ = :timestamp_tz
|
61
|
+
# interval year to month
|
62
|
+
SQLT_INTERVAL_YM = :interval_ym
|
63
|
+
# interval day to second
|
64
|
+
SQLT_INTERVAL_DS = :interval_ds
|
65
|
+
# timestamp with local time zone
|
66
|
+
SQLT_TIMESTAMP_LTZ = :timestamp_ltz
|
67
|
+
|
68
|
+
# mapping of sql type number to sql type name.
|
69
|
+
SQLT_NAMES = {}
|
70
|
+
constants.each do |name|
|
71
|
+
next if name.to_s.index("SQLT_") != 0
|
72
|
+
val = const_get name.intern
|
73
|
+
if val.is_a? Integer
|
74
|
+
SQLT_NAMES[val] = name
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# add alias compatible with 'Oracle7 Module for Ruby'.
|
79
|
+
alias autocommit autocommit?
|
80
|
+
|
81
|
+
class Cursor
|
82
|
+
# @!visibility private
|
83
|
+
# dirty hack to suppress "warning: constant ::Fixnum is deprecated"
|
84
|
+
Fixnum = (0.class == ::Integer) ? ::Integer : ::Fixnum
|
85
|
+
|
86
|
+
def self.select_number_as=(val)
|
87
|
+
if val == Fixnum
|
88
|
+
@@bind_unknown_number = OCI8::BindType::Fixnum
|
89
|
+
elsif val == Integer
|
90
|
+
@@bind_unknown_number = OCI8::BindType::Integer
|
91
|
+
elsif val == Float
|
92
|
+
@@bind_unknown_number = OCI8::BindType::Float
|
93
|
+
else
|
94
|
+
raise ArgumentError, "must be Fixnum, Integer or Float"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.select_number_as
|
99
|
+
case @@bind_unknown_number
|
100
|
+
when OCI8::BindType::Fixnum
|
101
|
+
return Fixnum
|
102
|
+
when OCI8::BindType::Integer
|
103
|
+
return Integer
|
104
|
+
when OCI8::BindType::Float
|
105
|
+
return Float
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# add alias compatible with 'Oracle7 Module for Ruby'.
|
110
|
+
alias getColNames get_col_names
|
111
|
+
end
|
112
|
+
|
113
|
+
module BindType
|
114
|
+
# alias to Integer for compatibility with ruby-oci8 1.0.
|
115
|
+
Fixnum = Integer
|
116
|
+
end
|
117
|
+
end
|