ruby-oci8 2.2.6.1 → 2.2.10
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/ChangeLog +167 -3
- data/NEWS +162 -54
- data/README.md +1 -1
- data/dist-files +1 -2
- data/docs/install-instant-client.md +2 -1
- data/docs/install-on-osx.md +29 -116
- data/ext/oci8/apiwrap.c.tmpl +2 -5
- data/ext/oci8/apiwrap.yml +20 -0
- data/ext/oci8/attr.c +4 -2
- data/ext/oci8/bind.c +366 -6
- data/ext/oci8/connection_pool.c +3 -3
- data/ext/oci8/extconf.rb +5 -2
- data/ext/oci8/hook_funcs.c +21 -1
- data/ext/oci8/lob.c +24 -32
- data/ext/oci8/metadata.c +2 -2
- data/ext/oci8/object.c +42 -27
- data/ext/oci8/oci8.c +14 -16
- data/ext/oci8/oci8.h +1 -0
- data/ext/oci8/oci8lib.c +10 -7
- data/ext/oci8/ocihandle.c +2 -2
- data/ext/oci8/ocinumber.c +11 -9
- data/ext/oci8/oraconf.rb +130 -257
- data/ext/oci8/oradate.c +1 -1
- data/ext/oci8/plthook_osx.c +10 -10
- data/ext/oci8/stmt.c +51 -16
- data/ext/oci8/win32.c +4 -2
- data/lib/oci8/bindtype.rb +0 -14
- data/lib/oci8/check_load_error.rb +51 -16
- data/lib/oci8/cursor.rb +46 -13
- data/lib/oci8/oci8.rb +1 -1
- data/lib/oci8/version.rb +1 -1
- data/lib/oci8.rb +9 -4
- data/ruby-oci8.gemspec +2 -3
- data/setup.rb +11 -2
- data/test/README.md +37 -0
- data/test/config.rb +1 -1
- data/test/test_break.rb +9 -9
- data/test/test_datetime.rb +8 -3
- data/test/test_oci8.rb +154 -43
- data/test/test_oranumber.rb +7 -1
- metadata +33 -55
- data/docs/osx-install-dev-tools.png +0 -0
- data/test/README +0 -42
data/ext/oci8/oraconf.rb
CHANGED
@@ -4,7 +4,7 @@ require 'mkmf'
|
|
4
4
|
# compatibility for ruby-1.9
|
5
5
|
RbConfig = Config unless defined? RbConfig
|
6
6
|
|
7
|
-
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|
|
7
|
+
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw/
|
8
8
|
# Windows
|
9
9
|
require 'win32/registry'
|
10
10
|
module Registry
|
@@ -43,6 +43,10 @@ class MiniSOReader
|
|
43
43
|
attr_reader :endian
|
44
44
|
attr_reader :bits
|
45
45
|
|
46
|
+
MACH_O_CPU_TYPE_I386 = 7
|
47
|
+
MACH_O_CPU_TYPE_X86_64 = 7 + 0x01000000
|
48
|
+
MACH_O_CPU_TYPE_ARM64 = 12 + 0x01000000
|
49
|
+
|
46
50
|
def initialize(filename)
|
47
51
|
f = open(filename, 'rb')
|
48
52
|
begin
|
@@ -56,9 +60,6 @@ class MiniSOReader
|
|
56
60
|
when "\x02\x10"
|
57
61
|
# HP-UX PA-RISC1.1
|
58
62
|
read_parisc(f)
|
59
|
-
when "\xfe\xed"
|
60
|
-
# Big-endian Mach-O File
|
61
|
-
read_mach_o_be(f)
|
62
63
|
when "\xce\xfa"
|
63
64
|
# 32-bit Little-endian Mach-O File
|
64
65
|
read_mach_o_le(f, 32)
|
@@ -67,10 +68,10 @@ class MiniSOReader
|
|
67
68
|
read_mach_o_le(f, 64)
|
68
69
|
when "\xca\xfe"
|
69
70
|
# Universal binary
|
70
|
-
|
71
|
+
read_mach_o_universal(f)
|
71
72
|
else
|
72
73
|
# AIX and Tru64
|
73
|
-
raise format("unknown file header: %02x %02x", file_header[0].
|
74
|
+
raise format("unknown file header: %02x %02x (%s)", file_header[0].ord, file_header[1].ord, filename)
|
74
75
|
end
|
75
76
|
ensure
|
76
77
|
f.close
|
@@ -174,22 +175,6 @@ class MiniSOReader
|
|
174
175
|
@cpu = :parisc
|
175
176
|
end
|
176
177
|
|
177
|
-
# Big-endian Mach-O File
|
178
|
-
def read_mach_o_be(f)
|
179
|
-
@file_format = :mach_o
|
180
|
-
@endian = :big
|
181
|
-
case f.read(2)
|
182
|
-
when "\xfa\xce" # feedface
|
183
|
-
@cpu = :ppc
|
184
|
-
@bits = 32
|
185
|
-
when "\xfa\xcf" # feedfacf
|
186
|
-
@cpu = :ppc64
|
187
|
-
@bits = 64
|
188
|
-
else
|
189
|
-
raise "unknown file format"
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
178
|
def read_mach_o_le(f, bits)
|
194
179
|
@file_format = :mach_o
|
195
180
|
@endian = :little
|
@@ -199,12 +184,20 @@ class MiniSOReader
|
|
199
184
|
@cpu = :i386
|
200
185
|
@bits = 32
|
201
186
|
when 64
|
202
|
-
|
187
|
+
cputype = f.read(4).unpack('V')[0]
|
188
|
+
case cputype
|
189
|
+
when MACH_O_CPU_TYPE_X86_64
|
190
|
+
@cpu = :x86_64
|
191
|
+
when MACH_O_CPU_TYPE_ARM64
|
192
|
+
@cpu = :arm64
|
193
|
+
else
|
194
|
+
raise "unknown mach-o cpu type: #{cputype}"
|
195
|
+
end
|
203
196
|
@bits = 64
|
204
197
|
end
|
205
198
|
end
|
206
199
|
|
207
|
-
def
|
200
|
+
def read_mach_o_universal(f)
|
208
201
|
raise 'unknown file format' if f.read(2) != "\xba\xbe" # cafebabe
|
209
202
|
@file_format = :universal
|
210
203
|
nfat_arch = f.read(4).unpack('N')[0]
|
@@ -213,21 +206,17 @@ class MiniSOReader
|
|
213
206
|
@bits = []
|
214
207
|
nfat_arch.times do
|
215
208
|
case cputype = f.read(4).unpack('N')[0]
|
216
|
-
when
|
209
|
+
when MACH_O_CPU_TYPE_I386
|
217
210
|
@cpu << :i386
|
218
211
|
@endian << :little
|
219
212
|
@bits << 32
|
220
|
-
when
|
213
|
+
when MACH_O_CPU_TYPE_X86_64
|
221
214
|
@cpu << :x86_64
|
222
215
|
@endian << :little
|
223
216
|
@bits << 64
|
224
|
-
when
|
225
|
-
@cpu << :
|
226
|
-
@endian << :
|
227
|
-
@bits << 32
|
228
|
-
when 18 + 0x01000000
|
229
|
-
@cpu << :ppc64
|
230
|
-
@endian << :big
|
217
|
+
when MACH_O_CPU_TYPE_ARM64
|
218
|
+
@cpu << :arm64
|
219
|
+
@endian << :little
|
231
220
|
@bits << 64
|
232
221
|
else
|
233
222
|
raise "Unknown mach-o cputype: #{cputype}"
|
@@ -250,7 +239,6 @@ class OraConf
|
|
250
239
|
def self.get
|
251
240
|
original_CFLAGS = $CFLAGS
|
252
241
|
original_defs = $defs
|
253
|
-
ic_dir = nil
|
254
242
|
begin
|
255
243
|
# check Oracle instant client
|
256
244
|
if with_config('instant-client')
|
@@ -262,11 +250,17 @@ class OraConf
|
|
262
250
|
=======================================================
|
263
251
|
EOS
|
264
252
|
end
|
265
|
-
|
266
|
-
if
|
267
|
-
OraConfIC.new(
|
253
|
+
inc, lib = dir_config('instant-client')
|
254
|
+
if inc && lib
|
255
|
+
OraConfIC.new(inc, lib)
|
268
256
|
else
|
269
|
-
|
257
|
+
base = guess_ic_dir
|
258
|
+
if base
|
259
|
+
inc, lib = guess_dirs_from_ic_base(base)
|
260
|
+
OraConfIC.new(inc, lib)
|
261
|
+
else
|
262
|
+
OraConfFC.new
|
263
|
+
end
|
270
264
|
end
|
271
265
|
rescue
|
272
266
|
case ENV['LANG']
|
@@ -298,6 +292,44 @@ EOS
|
|
298
292
|
end
|
299
293
|
end
|
300
294
|
|
295
|
+
# Guess the include and directory paths from
|
296
|
+
def self.guess_dirs_from_ic_base(ic_dir)
|
297
|
+
if ic_dir =~ /^\/usr\/lib(?:64)?\/oracle\/(\d+(?:\.\d+)*)\/client(64)?\/lib(?:64)?/
|
298
|
+
# rpm package
|
299
|
+
# x86 rpms after 11.1.0.7.0:
|
300
|
+
# library: /usr/lib/oracle/X.X/client/lib/
|
301
|
+
# include: /usr/include/oracle/X.X/client/
|
302
|
+
#
|
303
|
+
# x86_64 rpms after 11.1.0.7.0:
|
304
|
+
# library: /usr/lib/oracle/X.X/client64/lib/
|
305
|
+
# include: /usr/include/oracle/X.X/client64/
|
306
|
+
#
|
307
|
+
# x86 rpms before 11.1.0.6.0:
|
308
|
+
# library: /usr/lib/oracle/X.X.X.X/client/lib/
|
309
|
+
# include: /usr/include/oracle/X.X.X.X/client/
|
310
|
+
#
|
311
|
+
# x86_64 rpms before 11.1.0.6.0:
|
312
|
+
# library: /usr/lib/oracle/X.X.X.X/client64/lib/
|
313
|
+
# include: /usr/include/oracle/X.X.X.X/client64/
|
314
|
+
#
|
315
|
+
# third-party x86_64 rpms(*1):
|
316
|
+
# library: /usr/lib64/oracle/X.X.X.X/client/lib/
|
317
|
+
# or /usr/lib64/oracle/X.X.X.X/client/lib64/
|
318
|
+
# include: /usr/include/oracle/X.X.X.X/client/
|
319
|
+
#
|
320
|
+
# *1 These had been used before Oracle released official x86_64 rpms.
|
321
|
+
#
|
322
|
+
lib_dir = ic_dir
|
323
|
+
inc_dir = "/usr/include/oracle/#{$1}/client#{$2}"
|
324
|
+
else
|
325
|
+
# zip package
|
326
|
+
lib_dir = ic_dir
|
327
|
+
inc_dir = "#{ic_dir}/sdk/include"
|
328
|
+
end
|
329
|
+
|
330
|
+
[inc_dir, lib_dir]
|
331
|
+
end
|
332
|
+
|
301
333
|
def self.ld_envs
|
302
334
|
@@ld_envs
|
303
335
|
end
|
@@ -316,8 +348,9 @@ EOS
|
|
316
348
|
end
|
317
349
|
end
|
318
350
|
|
319
|
-
def self.
|
320
|
-
puts "
|
351
|
+
def self.guess_ic_dir
|
352
|
+
puts "attempting to locate oracle-instantclient..."
|
353
|
+
puts "checking load library path... "
|
321
354
|
STDOUT.flush
|
322
355
|
|
323
356
|
# get library load path names
|
@@ -339,7 +372,7 @@ EOS
|
|
339
372
|
is_32bit = size_of_pointer == 4
|
340
373
|
is_big_endian = "\x01\x02".unpack('s')[0] == 0x0102
|
341
374
|
case RUBY_PLATFORM
|
342
|
-
when /mswin32|mswin64|cygwin|
|
375
|
+
when /mswin32|mswin64|cygwin|mingw/
|
343
376
|
oci_basename = 'oci'
|
344
377
|
oci_glob_postfix = ''
|
345
378
|
nls_data_basename = ['oraociei*', 'oraociicus*']
|
@@ -382,20 +415,13 @@ EOS
|
|
382
415
|
end
|
383
416
|
so_ext = 'sl'
|
384
417
|
when /darwin/
|
385
|
-
@@ld_envs = %w[
|
418
|
+
@@ld_envs = %w[OCI_DIR]
|
386
419
|
so_ext = 'dylib'
|
387
420
|
if is_32bit
|
388
|
-
|
389
|
-
this_cpu = :ppc # 32-bit big-endian
|
390
|
-
else
|
391
|
-
this_cpu = :i386 # 32-bit little-endian
|
392
|
-
end
|
421
|
+
this_cpu = :i386 # 32-bit little-endian
|
393
422
|
else
|
394
|
-
|
395
|
-
|
396
|
-
else
|
397
|
-
this_cpu = :x86_64 # 64-bit little-endian
|
398
|
-
end
|
423
|
+
require 'etc'
|
424
|
+
this_cpu = Etc.uname[:machine].to_sym
|
399
425
|
end
|
400
426
|
check_proc = Proc.new do |file|
|
401
427
|
so = MiniSOReader.new(file)
|
@@ -469,49 +495,6 @@ EOS
|
|
469
495
|
end
|
470
496
|
end
|
471
497
|
when /darwin/
|
472
|
-
fallback_path = ENV['DYLD_FALLBACK_LIBRARY_PATH']
|
473
|
-
if fallback_path.nil?
|
474
|
-
puts " DYLD_FALLBACK_LIBRARY_PATH is not set."
|
475
|
-
else
|
476
|
-
puts " checking DYLD_FALLBACK_LIBRARY_PATH..."
|
477
|
-
ld_path, file = check_lib_in_path(fallback_path, glob_name, check_proc)
|
478
|
-
end
|
479
|
-
if ld_path.nil?
|
480
|
-
puts " checking OCI_DIR..."
|
481
|
-
ld_path, file = check_lib_in_path(ENV['OCI_DIR'], glob_name, check_proc)
|
482
|
-
if ld_path
|
483
|
-
puts " checking dependent shared libraries in #{file}..."
|
484
|
-
open("|otool -L #{file}") do |f|
|
485
|
-
f.gets # discard the first line
|
486
|
-
while line = f.gets
|
487
|
-
line =~ /^\s+(\S+)/
|
488
|
-
libname = $1
|
489
|
-
case libname
|
490
|
-
when /^@rpath\/libclntsh\.dylib/, /^@rpath\/libnnz\d\d\.dylib/, /^@loader_path\/libnnz\d\d\.dylib/
|
491
|
-
# No need to check the real path.
|
492
|
-
# The current instant client doesn't use @rpath or @loader_path.
|
493
|
-
when /\/libclntsh\.dylib/, /\/libnnz\d\d.dylib/
|
494
|
-
raise <<EOS unless File.exists?(libname)
|
495
|
-
The output of "otool -L #{file}" is:
|
496
|
-
| #{IO.readlines("|otool -L #{file}").join(' | ')}
|
497
|
-
Ruby-oci8 doesn't work without DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH
|
498
|
-
because the dependent file "#{libname}" doesn't exist.
|
499
|
-
|
500
|
-
If you need to use ruby-oci8 without DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH,
|
501
|
-
download "fix_oralib.rb" in https://github.com/kubo/fix_oralib_osx
|
502
|
-
and execute it in the directory "#{File.dirname(file)}" as follows to fix the path.
|
503
|
-
|
504
|
-
cd #{File.dirname(file)}
|
505
|
-
curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
|
506
|
-
ruby fix_oralib.rb
|
507
|
-
|
508
|
-
Note: DYLD_* environment variables are unavailable for security reasons on OS X 10.11 El Capitan.
|
509
|
-
EOS
|
510
|
-
end
|
511
|
-
end
|
512
|
-
end
|
513
|
-
end
|
514
|
-
end
|
515
498
|
if ld_path.nil?
|
516
499
|
fallback_path = ENV['DYLD_FALLBACK_LIBRARY_PATH']
|
517
500
|
if fallback_path.nil?
|
@@ -522,17 +505,8 @@ EOS
|
|
522
505
|
end
|
523
506
|
if ld_path.nil?
|
524
507
|
raise <<EOS
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
If DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH is set, the environment
|
529
|
-
variable must be set at runtime also.
|
530
|
-
|
531
|
-
If OCI_DIR is set, dependent shared library paths are checked. If the checking
|
532
|
-
is passed, ruby-oci8 works without DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH.
|
533
|
-
|
534
|
-
Note: OCI_DIR should be absolute path.
|
535
|
-
Note: DYLD_* environment variables are unavailable for security reasons on OS X 10.11 El Capitan.
|
508
|
+
Oracle instant client is not found.
|
509
|
+
You need to install Oracle instant client.
|
536
510
|
EOS
|
537
511
|
end
|
538
512
|
end
|
@@ -556,8 +530,8 @@ EOS
|
|
556
530
|
paths.split(File::PATH_SEPARATOR).each do |path|
|
557
531
|
next if path.nil? or path == ''
|
558
532
|
print " checking #{path}... "
|
559
|
-
path.gsub!(/\\/, '/') if /mswin32|mswin64|cygwin|
|
560
|
-
files = Dir.glob(File.join(path, glob_name))
|
533
|
+
path.gsub!(/\\/, '/') if /mswin32|mswin64|cygwin|mingw/ =~ RUBY_PLATFORM
|
534
|
+
files = Dir.glob(File.join(path, glob_name)).sort.reverse
|
561
535
|
if files.empty?
|
562
536
|
puts "no"
|
563
537
|
next
|
@@ -584,7 +558,7 @@ EOS
|
|
584
558
|
if try_run("int main() { return 0; }")
|
585
559
|
puts "ok"
|
586
560
|
else
|
587
|
-
puts "
|
561
|
+
puts "failed"
|
588
562
|
raise "C compiler doesn't work correctly."
|
589
563
|
end
|
590
564
|
end # check_cc
|
@@ -630,21 +604,11 @@ EOS
|
|
630
604
|
STDOUT.flush
|
631
605
|
rubyhdrdir = RbConfig::CONFIG["rubyhdrdir"] || RbConfig::CONFIG['archdir']
|
632
606
|
unless File.exist?(rubyhdrdir + '/ruby.h')
|
633
|
-
puts "
|
634
|
-
|
635
|
-
raise <<EOS
|
636
|
-
#{RbConfig::CONFIG['archdir']}/ruby.h doesn't exist.
|
637
|
-
Run the following commands to fix the problem.
|
638
|
-
|
639
|
-
cd #{RbConfig::CONFIG['archdir']}
|
640
|
-
sudo ln -s ../universal-darwin8.0/* ./
|
641
|
-
EOS
|
642
|
-
else
|
643
|
-
raise <<EOS
|
607
|
+
puts "failed"
|
608
|
+
raise <<EOS
|
644
609
|
#{RbConfig::CONFIG['archdir']}/ruby.h doesn't exist.
|
645
610
|
Install the ruby development library.
|
646
611
|
EOS
|
647
|
-
end
|
648
612
|
end
|
649
613
|
puts "ok"
|
650
614
|
$stdout.flush
|
@@ -660,11 +624,11 @@ EOS
|
|
660
624
|
end
|
661
625
|
end
|
662
626
|
|
663
|
-
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|
|
627
|
+
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw/ # when Windows
|
664
628
|
|
665
629
|
def get_libs(lib_dir)
|
666
630
|
case RUBY_PLATFORM
|
667
|
-
when /cygwin
|
631
|
+
when /cygwin/
|
668
632
|
regex = ([nil].pack('P').size == 8) ? / T (OCI\w+)/ : / T _(OCI\w+)/
|
669
633
|
oci_funcs = YAML.load(open(File.dirname(__FILE__) + '/apiwrap.yml')).keys.collect do |func|
|
670
634
|
func =~ /_nb$/ ? $` : func
|
@@ -683,22 +647,6 @@ EOS
|
|
683
647
|
system(command)
|
684
648
|
puts("done")
|
685
649
|
"-L. -lOCI"
|
686
|
-
when /bccwin32/
|
687
|
-
# replace '/' to '\\' because bcc linker misunderstands
|
688
|
-
# 'C:/foo/bar/OCI.LIB' as unknown option.
|
689
|
-
lib = "#{lib_dir}/BORLAND/OCI.LIB"
|
690
|
-
return lib.tr('/', '\\') if File.exist?(lib)
|
691
|
-
raise <<EOS
|
692
|
-
#{lib} does not exist.
|
693
|
-
|
694
|
-
Your Oracle may not support Borland C++.
|
695
|
-
If you want to run this module, run the following command at your own risk.
|
696
|
-
cd #{lib_dir.tr('/', '\\')}
|
697
|
-
mkdir Borland
|
698
|
-
cd Borland
|
699
|
-
coff2omf ..\\MSVC\\OCI.LIB OCI.LIB
|
700
|
-
EOS
|
701
|
-
exit 1
|
702
650
|
else
|
703
651
|
"\"#{lib_dir}/MSVC/OCI.LIB\""
|
704
652
|
end
|
@@ -742,7 +690,7 @@ class OraConfFC < OraConf
|
|
742
690
|
use_lib32 = false
|
743
691
|
end
|
744
692
|
|
745
|
-
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|
|
693
|
+
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw/
|
746
694
|
lib_dir = "#{@oracle_home}/oci/lib"
|
747
695
|
elsif use_lib32
|
748
696
|
lib_dir = "#{@oracle_home}/lib32"
|
@@ -761,7 +709,7 @@ class OraConfFC < OraConf
|
|
761
709
|
print("Get the version of Oracle from SQL*Plus... ")
|
762
710
|
STDOUT.flush
|
763
711
|
version = nil
|
764
|
-
dev_null = RUBY_PLATFORM =~ /mswin32|mswin64|
|
712
|
+
dev_null = RUBY_PLATFORM =~ /mswin32|mswin64|mingw/ ? "nul" : "/dev/null"
|
765
713
|
if File.exist?("#{@oracle_home}/bin/plus80.exe")
|
766
714
|
sqlplus = "plus80.exe"
|
767
715
|
else
|
@@ -786,7 +734,7 @@ class OraConfFC < OraConf
|
|
786
734
|
version
|
787
735
|
end # get_version
|
788
736
|
|
789
|
-
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|
|
737
|
+
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw/ # when Windows
|
790
738
|
|
791
739
|
def is_valid_home?(oracle_home)
|
792
740
|
return false if oracle_home.nil?
|
@@ -868,7 +816,7 @@ EOS
|
|
868
816
|
unless File.exist?("#{@oracle_home}/OCI/INCLUDE/OCI.H")
|
869
817
|
raise "'#{@oracle_home}/OCI/INCLUDE/OCI.H' does not exists. Please install 'Oracle Call Interface'."
|
870
818
|
end
|
871
|
-
if RUBY_PLATFORM =~ /cygwin|
|
819
|
+
if RUBY_PLATFORM =~ /cygwin|mingw/
|
872
820
|
" \"-I#{@oracle_home}/OCI/INCLUDE\" -D_int64=\"long long\""
|
873
821
|
else
|
874
822
|
" \"-I#{@oracle_home}/OCI/INCLUDE\""
|
@@ -947,56 +895,25 @@ end
|
|
947
895
|
|
948
896
|
# OraConf for Instant Client
|
949
897
|
class OraConfIC < OraConf
|
950
|
-
def initialize(
|
898
|
+
def initialize(inc_dir, lib_dir)
|
951
899
|
init
|
952
900
|
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
# library: /usr/lib/oracle/X.X/client64/lib/
|
961
|
-
# include: /usr/include/oracle/X.X/client64/
|
962
|
-
#
|
963
|
-
# x86 rpms before 11.1.0.6.0:
|
964
|
-
# library: /usr/lib/oracle/X.X.X.X/client/lib/
|
965
|
-
# include: /usr/include/oracle/X.X.X.X/client/
|
966
|
-
#
|
967
|
-
# x86_64 rpms before 11.1.0.6.0:
|
968
|
-
# library: /usr/lib/oracle/X.X.X.X/client64/lib/
|
969
|
-
# include: /usr/include/oracle/X.X.X.X/client64/
|
970
|
-
#
|
971
|
-
# third-party x86_64 rpms(*1):
|
972
|
-
# library: /usr/lib64/oracle/X.X.X.X/client/lib/
|
973
|
-
# or /usr/lib64/oracle/X.X.X.X/client/lib64/
|
974
|
-
# include: /usr/include/oracle/X.X.X.X/client/
|
975
|
-
#
|
976
|
-
# *1 These had been used before Oracle released official x86_64 rpms.
|
977
|
-
#
|
978
|
-
lib_dir = ic_dir
|
979
|
-
inc_dir = "/usr/include/oracle/#{$1}/client#{$2}"
|
980
|
-
else
|
981
|
-
# zip package
|
982
|
-
lib_dir = ic_dir
|
983
|
-
inc_dir = "#{ic_dir}/sdk/include"
|
984
|
-
end
|
985
|
-
|
986
|
-
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw32|bccwin32/ # when Windows
|
987
|
-
unless File.exist?("#{ic_dir}/sdk/lib/msvc/oci.lib")
|
901
|
+
# check lib_dir
|
902
|
+
lib_dirs = lib_dir.split(File::PATH_SEPARATOR)
|
903
|
+
if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw/ # when Windows
|
904
|
+
ocilib = lib_dirs.find do |dir|
|
905
|
+
File.exist?("#{dir}/sdk/lib/msvc/oci.lib")
|
906
|
+
end
|
907
|
+
unless ocilib
|
988
908
|
raise <<EOS
|
989
909
|
Could not compile with Oracle instant client.
|
990
|
-
|
910
|
+
"sdk/lib/msvc/oci.lib" could not be found in: #{lib_dirs.join(' ')}
|
911
|
+
Did you install instantclient-basic?
|
991
912
|
EOS
|
992
|
-
raise 'failed'
|
993
913
|
end
|
994
|
-
@
|
995
|
-
@cflags += " -D_int64=\"long long\"" if RUBY_PLATFORM =~ /cygwin|mingw32/
|
996
|
-
@libs = get_libs("#{ic_dir}/sdk/lib")
|
914
|
+
@libs = get_libs("#{ocilib}/sdk/lib")
|
997
915
|
ld_path = nil
|
998
916
|
else
|
999
|
-
@cflags = " -I#{inc_dir}"
|
1000
917
|
# set ld_path and so_ext
|
1001
918
|
case RUBY_PLATFORM
|
1002
919
|
when /aix/
|
@@ -1017,34 +934,53 @@ EOS
|
|
1017
934
|
so_ext = 'so'
|
1018
935
|
end
|
1019
936
|
# check Oracle client library.
|
1020
|
-
|
1021
|
-
|
937
|
+
ocilib = lib_dirs.find do |dir|
|
938
|
+
File.exist?("#{dir}/libclntsh.#{so_ext}")
|
939
|
+
end
|
940
|
+
unless ocilib
|
941
|
+
files = lib_dirs.map do |dir|
|
942
|
+
Dir.glob("#{dir}/libclntsh.#{so_ext}.*")
|
943
|
+
end.flatten
|
1022
944
|
if files.empty?
|
1023
945
|
raise <<EOS
|
1024
946
|
Could not compile with Oracle instant client.
|
1025
|
-
|
947
|
+
"libclntsh.#{so_ext}" could not be found in: #{lib_dirs.join(' ')}
|
1026
948
|
Did you install instantclient-basic?
|
1027
949
|
EOS
|
1028
950
|
else
|
1029
|
-
file =
|
951
|
+
file = files.sort[-1]
|
1030
952
|
raise <<EOS
|
1031
953
|
Could not compile with Oracle instant client.
|
1032
|
-
|
954
|
+
"libclntsh.#{so_ext}" could not be found in: #{lib_dirs.join(' ')}
|
1033
955
|
You may need to make a symbolic link.
|
1034
|
-
cd #{
|
1035
|
-
ln -s #{file} libclntsh.#{so_ext}
|
956
|
+
cd #{File.dirname(file)}
|
957
|
+
ln -s #{File.basename(file)} libclntsh.#{so_ext}
|
1036
958
|
EOS
|
1037
959
|
end
|
1038
960
|
raise 'failed'
|
1039
961
|
end
|
1040
962
|
@libs = get_libs(lib_dir)
|
1041
963
|
end
|
1042
|
-
|
964
|
+
|
965
|
+
# check inc_dir
|
966
|
+
inc_dirs = inc_dir.split(File::PATH_SEPARATOR)
|
967
|
+
ociinc = inc_dirs.find do |dir|
|
968
|
+
File.exist?("#{dir}/oci.h")
|
969
|
+
end
|
970
|
+
unless ociinc
|
1043
971
|
raise <<EOS
|
1044
|
-
|
972
|
+
"oci.h" could not be found in: #{inc_dirs.join(' ')}
|
1045
973
|
Install 'Instant Client SDK'.
|
1046
974
|
EOS
|
1047
975
|
end
|
976
|
+
if ociinc.include?(' ')
|
977
|
+
@cflags = " \"-I#{ociinc}\""
|
978
|
+
else
|
979
|
+
@cflags = " -I#{ociinc}"
|
980
|
+
end
|
981
|
+
@cflags += " -D_int64=\"long long\"" if RUBY_PLATFORM =~ /cygwin|mingw/
|
982
|
+
|
983
|
+
# check link
|
1048
984
|
$CFLAGS += @cflags
|
1049
985
|
if try_link_oci()
|
1050
986
|
major = try_constant("OCI_MAJOR_VERSION", "oci.h")
|
@@ -1054,73 +990,10 @@ EOS
|
|
1054
990
|
else
|
1055
991
|
# 10.1.0 doesn't have OCI_MAJOR_VERSION and OCI_MINOR_VERSION in oci.h.
|
1056
992
|
@version = "1010"
|
1057
|
-
if RUBY_PLATFORM =~ /darwin/ and 1.size == 8 and `sw_vers -productVersion`.chomp == "10.7"
|
1058
|
-
$stderr.print <<EOS
|
1059
|
-
WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN!
|
1060
|
-
|
1061
|
-
64-bit Oracle instant client doesn't work on OS X Lion.
|
1062
|
-
See: https://forums.oracle.com/forums/thread.jspa?threadID=2187558
|
1063
|
-
|
1064
|
-
The compilation is continued because the issue may be fixed in future.
|
1065
|
-
|
1066
|
-
WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN! WARN!
|
1067
|
-
EOS
|
1068
|
-
end
|
1069
993
|
end
|
1070
994
|
return
|
1071
995
|
end
|
1072
996
|
|
1073
|
-
if RUBY_PLATFORM =~ /darwin/
|
1074
|
-
open('mkmf.log', 'r') do |f|
|
1075
|
-
while line = f.gets
|
1076
|
-
if line.include? '/libclntsh.dylib load command 8 unknown cmd field'
|
1077
|
-
raise <<EOS
|
1078
|
-
Intel mac instant client is for Mac OS X 10.5.
|
1079
|
-
It doesn't work on Mac OS X 10.4 or before.
|
1080
|
-
|
1081
|
-
You have three workarounds.
|
1082
|
-
1. Compile ruby as ppc binary and use it with ppc instant client.
|
1083
|
-
2. Use JRuby and JDBC
|
1084
|
-
3. Use a third-party ODBC driver and ruby-odbc.
|
1085
|
-
EOS
|
1086
|
-
# '
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
case line
|
1090
|
-
when /cputype \(\d+, architecture \w+\) does not match cputype \(\d+\) for specified -arch flag: (\w+)/
|
1091
|
-
missing_arch = $1
|
1092
|
-
when /Undefined symbols for architecture (\w+)/
|
1093
|
-
missing_arch = $1
|
1094
|
-
when /missing required architecture (\w+) in file/
|
1095
|
-
missing_arch = $1
|
1096
|
-
end
|
1097
|
-
|
1098
|
-
if missing_arch
|
1099
|
-
if [nil].pack('p').size == 8
|
1100
|
-
my_arch = 'x86_64'
|
1101
|
-
elsif "\x01\x02".unpack('s')[0] == 0x0201
|
1102
|
-
my_arch = 'i386'
|
1103
|
-
else
|
1104
|
-
my_arch = 'ppc'
|
1105
|
-
end
|
1106
|
-
raise <<EOS
|
1107
|
-
Could not compile with Oracle instant client.
|
1108
|
-
You may need to set the environment variable RC_ARCHS or ARCHFLAGS as follows:
|
1109
|
-
|
1110
|
-
RC_ARCHS=#{my_arch}
|
1111
|
-
export RC_ARCHS
|
1112
|
-
or
|
1113
|
-
ARCHFLAGS='-arch #{my_arch}'
|
1114
|
-
export RC_ARCHS
|
1115
|
-
|
1116
|
-
If it does not fix the problem, delete all '-arch #{missing_arch}'
|
1117
|
-
in '#{RbConfig::CONFIG['archdir']}/rbconfig.rb'.
|
1118
|
-
EOS
|
1119
|
-
end
|
1120
|
-
end
|
1121
|
-
end
|
1122
|
-
end
|
1123
|
-
|
1124
997
|
unless ld_path.nil?
|
1125
998
|
raise <<EOS
|
1126
999
|
Could not compile with Oracle instant client.
|
data/ext/oci8/oradate.c
CHANGED
@@ -198,7 +198,7 @@ static VALUE ora_date_initialize_copy(VALUE lhs, VALUE rhs)
|
|
198
198
|
*
|
199
199
|
* @return [OraDate]
|
200
200
|
*/
|
201
|
-
static VALUE ora_date_s_now(
|
201
|
+
static VALUE ora_date_s_now(VALUE klass)
|
202
202
|
{
|
203
203
|
VALUE obj = ora_date_s_allocate(klass);
|
204
204
|
ora_date_t *od = check_oradate(obj);
|