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.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +14 -0
  3. data/COPYING +30 -0
  4. data/COPYING_old +64 -0
  5. data/ChangeLog +3826 -0
  6. data/Makefile +92 -0
  7. data/NEWS +1209 -0
  8. data/README.md +66 -0
  9. data/dist-files +112 -0
  10. data/docs/bind-array-to-in_cond.md +38 -0
  11. data/docs/conflicts-local-connections-and-processes.md +98 -0
  12. data/docs/hanging-after-inactivity.md +63 -0
  13. data/docs/install-binary-package.md +44 -0
  14. data/docs/install-full-client.md +111 -0
  15. data/docs/install-instant-client.md +194 -0
  16. data/docs/install-on-osx.md +46 -0
  17. data/docs/ldap-auth-and-function-interposition.md +123 -0
  18. data/docs/number-type-mapping.md +79 -0
  19. data/docs/platform-specific-issues.md +164 -0
  20. data/docs/report-installation-issue.md +50 -0
  21. data/docs/timeout-parameters.md +94 -0
  22. data/lib/.document +1 -0
  23. data/lib/dbd/OCI8.rb +591 -0
  24. data/lib/oci8/.document +8 -0
  25. data/lib/oci8/bindtype.rb +333 -0
  26. data/lib/oci8/check_load_error.rb +146 -0
  27. data/lib/oci8/compat.rb +117 -0
  28. data/lib/oci8/connection_pool.rb +179 -0
  29. data/lib/oci8/cursor.rb +605 -0
  30. data/lib/oci8/datetime.rb +605 -0
  31. data/lib/oci8/encoding-init.rb +45 -0
  32. data/lib/oci8/encoding.yml +537 -0
  33. data/lib/oci8/metadata.rb +2148 -0
  34. data/lib/oci8/object.rb +641 -0
  35. data/lib/oci8/oci8.rb +756 -0
  36. data/lib/oci8/ocihandle.rb +591 -0
  37. data/lib/oci8/oracle_version.rb +153 -0
  38. data/lib/oci8/properties.rb +196 -0
  39. data/lib/oci8/version.rb +3 -0
  40. data/lib/oci8.rb +190 -0
  41. data/lib/oci8lib_310.so +0 -0
  42. data/lib/ruby-oci8.rb +1 -0
  43. data/metaconfig +142 -0
  44. data/pre-distclean.rb +7 -0
  45. data/ruby-oci8.gemspec +85 -0
  46. data/setup.rb +1342 -0
  47. data/test/README.md +37 -0
  48. data/test/config.rb +201 -0
  49. data/test/setup_test_object.sql +199 -0
  50. data/test/setup_test_package.sql +59 -0
  51. data/test/test_all.rb +56 -0
  52. data/test/test_appinfo.rb +62 -0
  53. data/test/test_array_dml.rb +332 -0
  54. data/test/test_bind_array.rb +70 -0
  55. data/test/test_bind_boolean.rb +99 -0
  56. data/test/test_bind_integer.rb +47 -0
  57. data/test/test_bind_raw.rb +45 -0
  58. data/test/test_bind_string.rb +105 -0
  59. data/test/test_bind_time.rb +177 -0
  60. data/test/test_break.rb +125 -0
  61. data/test/test_clob.rb +85 -0
  62. data/test/test_connection_pool.rb +124 -0
  63. data/test/test_connstr.rb +220 -0
  64. data/test/test_datetime.rb +585 -0
  65. data/test/test_dbi.rb +365 -0
  66. data/test/test_dbi_clob.rb +53 -0
  67. data/test/test_encoding.rb +103 -0
  68. data/test/test_error.rb +87 -0
  69. data/test/test_metadata.rb +2674 -0
  70. data/test/test_object.rb +546 -0
  71. data/test/test_oci8.rb +624 -0
  72. data/test/test_oracle_version.rb +68 -0
  73. data/test/test_oradate.rb +255 -0
  74. data/test/test_oranumber.rb +792 -0
  75. data/test/test_package_type.rb +981 -0
  76. data/test/test_properties.rb +17 -0
  77. data/test/test_rowid.rb +32 -0
  78. metadata +123 -0
@@ -0,0 +1,153 @@
1
+ # oracle_version.rb implements OCI8::OracleVersion.
2
+ #
3
+ # Copyright (C) 2009-2013 Kubo Takehiro <kubo@jiubao.org>
4
+
5
+ #
6
+ class OCI8
7
+
8
+ # The data class, representing Oracle version.
9
+ #
10
+ # Oracle version is represented by five numbers:
11
+ # *major*, *minor*, *update*, *patch* and *port_update*.
12
+ #
13
+ # @see OCI8.oracle_client_version
14
+ # @see OCI8#oracle_server_version
15
+ class OracleVersion
16
+ include Comparable
17
+
18
+ # The first part of the Oracle version.
19
+ attr_reader :major
20
+ # The second part of the Oracle version.
21
+ attr_reader :minor
22
+ # The third part of the Oracle version.
23
+ attr_reader :update
24
+ # The fourth part of the Oracle version.
25
+ attr_reader :patch
26
+ # The fifth part of the Oracle version.
27
+ attr_reader :port_update
28
+
29
+ # Creates an OCI8::OracleVersion object.
30
+ #
31
+ # If the first argument _arg_ is a String, it is parsed as dotted
32
+ # version string. If it is bigger than 0x08000000, it is parsed as
33
+ # a number contains 5-digit Oracle version. Otherwise, it is used
34
+ # as a major version and the rest arguments are minor, update,
35
+ # patch and port_update. Unspecified version numbers are zeros by
36
+ # default.
37
+ #
38
+ # @example
39
+ # # When the first argument is a String,
40
+ # oraver = OCI8::OracleVersion.new('11.2.0.3')
41
+ # oraver.major # => 11
42
+ # oraver.minor # => 2
43
+ # oraver.update # => 0
44
+ # oraver.patch # => 3
45
+ # oraver.port_update # => 0
46
+ #
47
+ # # When the first argument is bigger than 0x08000000,
48
+ # oraver = OCI8::OracleVersion.new(0x0b200300)
49
+ # oraver.major # => 11
50
+ # oraver.minor # => 2
51
+ # oraver.update # => 0
52
+ # oraver.patch # => 3
53
+ # oraver.port_update # => 0
54
+ #
55
+ # # Otherwise,
56
+ # oraver = OCI8::OracleVersion.new(11, 2, 0, 3)
57
+ # oraver.major # => 11
58
+ # oraver.minor # => 2
59
+ # oraver.update # => 0
60
+ # oraver.patch # => 3
61
+ # oraver.port_update # => 0
62
+ #
63
+ # @return [OCI8::OracleVersion]
64
+ def initialize(arg, minor = nil, update = nil, patch = nil, port_update = nil)
65
+ if arg.is_a? String
66
+ major, minor, update, patch, port_update = arg.split('.').collect do |v|
67
+ v.to_i
68
+ end
69
+ elsif arg >= 0x12000000
70
+ major = (arg & 0xFF000000) >> 24
71
+ minor = (arg & 0x00FF0000) >> 16
72
+ update = (arg & 0x0000F000) >> 12
73
+ patch = (arg & 0x00000FF0) >> 4
74
+ port_update = (arg & 0x0000000F)
75
+ elsif arg >= 0x08000000
76
+ major = (arg & 0xFF000000) >> 24
77
+ minor = (arg & 0x00F00000) >> 20
78
+ update = (arg & 0x000FF000) >> 12
79
+ patch = (arg & 0x00000F00) >> 8
80
+ port_update = (arg & 0x000000FF)
81
+ else
82
+ major = arg
83
+ end
84
+ @major = major
85
+ @minor = minor || 0
86
+ @update = update || 0
87
+ @patch = patch || 0
88
+ @port_update = port_update || 0
89
+ @vernum = if @major >= 18
90
+ (@major << 24) | (@minor << 16) | (@update << 12) | (@patch << 4) | @port_update
91
+ else
92
+ (@major << 24) | (@minor << 20) | (@update << 12) | (@patch << 8) | @port_update
93
+ end
94
+ end
95
+
96
+ # Compares +self+ and +other+.
97
+ #
98
+ # <=> is the basis for the methods <, <=, ==, >, >=, and between?,
99
+ # included from the Comparable module.
100
+ #
101
+ # @return [-1, 0, +1]
102
+ def <=>(other)
103
+ @vernum <=> other.to_i
104
+ end
105
+
106
+ # Returns an integer number contains 5-digit Oracle version.
107
+ #
108
+ # If the hexadecimal notation is 0xAABCCDEE, *major*, *minor*,
109
+ # *update*, *patch* and *port_update* are 0xAA, 0xB, 0xCC, 0xD and
110
+ # 0xEE respectively.
111
+ #
112
+ # @example
113
+ # oraver = OCI8::OracleVersion.new('11.2.0.3')
114
+ # oraver.to_i # => 186647296
115
+ # '%08x' % oraver.to_i # => "0b200300"
116
+ #
117
+ # @return [Integer]
118
+ def to_i
119
+ @vernum
120
+ end
121
+
122
+ # Returns a dotted version string of the Oracle version.
123
+ #
124
+ # @example
125
+ # oraver = OCI8::OracleVersion.new('11.2.0.3')
126
+ # oraver.to_s # => '11.2.0.3.0'
127
+ #
128
+ # @return [String]
129
+ def to_s
130
+ format('%d.%d.%d.%d.%d', @major, @minor, @update, @patch, @port_update)
131
+ end
132
+
133
+ # Returns true if +self+ and +other+ are the same type and have
134
+ # equal values.
135
+ #
136
+ # @return [true or false]
137
+ def eql?(other)
138
+ other.is_a? OCI8::OracleVersion and (self <=> other) == 0
139
+ end
140
+
141
+ # Returns a hash based on the value of +self+.
142
+ #
143
+ # @return [Integer]
144
+ def hash
145
+ @vernum
146
+ end
147
+
148
+ # @private
149
+ def inspect
150
+ "#<#{self.class.to_s}: #{self.to_s}>"
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,196 @@
1
+ # properties.rb -- implements OCI8.properties
2
+ #
3
+ # Copyright (C) 2010-2015 Kubo Takehiro <kubo@jiubao.org>
4
+
5
+ #
6
+ class OCI8
7
+
8
+ # @private
9
+ @@properties = {
10
+ :length_semantics => :byte,
11
+ :bind_string_as_nchar => false,
12
+ :float_conversion_type => OCI8.__get_prop(1) ? :ruby : :oracle,
13
+ :statement_cache_size => 0,
14
+ :events_mode => ((OCI8.__get_prop(2) & 4) != 0), # 4 <- OCI_EVENTS in oci.h
15
+ :cancel_read_at_exit => false,
16
+ :tcp_connect_timeout => nil,
17
+ :connect_timeout => nil,
18
+ :send_timeout => nil,
19
+ :recv_timeout => nil,
20
+ :tcp_keepalive => false,
21
+ :tcp_keepalive_time => nil,
22
+ }
23
+
24
+ # @private
25
+ def @@properties.[](name)
26
+ raise IndexError, "No such property name: #{name}" unless @@properties.has_key?(name)
27
+ super(name)
28
+ end
29
+
30
+ # @private
31
+ def @@properties.[]=(name, val)
32
+ raise IndexError, "No such property name: #{name}" unless @@properties.has_key?(name)
33
+ case name
34
+ when :length_semantic
35
+ if val != :byte and val != :char
36
+ raise ArgumentError, "Invalid property value #{val} for :length_semantics."
37
+ end
38
+ when :bind_string_as_nchar
39
+ val = val ? true : false
40
+ when :float_conversion_type
41
+ case val
42
+ when :ruby
43
+ OCI8.__set_prop(1, true)
44
+ when :oracle
45
+ OCI8.__set_prop(1, false)
46
+ else
47
+ raise ArgumentError, "float_conversion_type's value should be either :ruby or :oracle."
48
+ end
49
+ when :statement_cache_size
50
+ val = val.to_i
51
+ raise ArgumentError, "The property value for :statement_cache_size must not be negative." if val < 0
52
+ when :events_mode
53
+ val = val ? true : false
54
+ if val
55
+ OCI8.__set_prop(2, OCI8.__get_prop(2) | 4) # set OCI_EVENTS
56
+ else
57
+ OCI8.__set_prop(2, OCI8.__get_prop(2) & ~4) # unset OCI_EVENTS
58
+ end
59
+ when :cancel_read_at_exit
60
+ val = val ? true : false
61
+ OCI8.__set_prop(3, val)
62
+ when :tcp_connect_timeout, :connect_timeout, :send_timeout, :recv_timeout
63
+ if !val.nil?
64
+ val = val.to_i
65
+ raise ArgumentError, "The property value for :#{name} must be nil or a positive integer." if val <= 0
66
+ end
67
+ when :tcp_keepalive
68
+ val = val ? true : false
69
+ when :tcp_keepalive_time
70
+ if !val.nil?
71
+ val = val.to_i
72
+ raise ArgumentError, "The property value for :#{name} must be nil or a positive integer." if val <= 0
73
+ end
74
+ OCI8.__set_prop(4, val)
75
+ end
76
+ super(name, val)
77
+ end
78
+
79
+ # Returns a Hash which ruby-oci8 global settings.
80
+ # The hash's setter and getter methods are customized to check
81
+ # property names and values.
82
+ #
83
+ # # get properties
84
+ # OCI8.properties[:bind_string_as_nchar] # => false
85
+ # OCI8.properties[:invalid_property_name] # raises an IndexError
86
+ #
87
+ # # set properties
88
+ # OCI8.properties[:bind_string_as_nchar] = true
89
+ # OCI8.properties[:invalid_property_name] = true # raises an IndexError
90
+ #
91
+ # Supported properties are listed below:
92
+ #
93
+ # [:length_semantics]
94
+ #
95
+ # +:char+ when Oracle character length is counted by the number of characters.
96
+ # +:byte+ when it is counted by the number of bytes.
97
+ # The default setting is +:byte+ because +:char+ causes unexpected behaviour on
98
+ # Oracle 9i.
99
+ #
100
+ # *Since:* 2.1.0
101
+ #
102
+ # [:bind_string_as_nchar]
103
+ #
104
+ # +true+ when string bind variables are bound as NCHAR,
105
+ # otherwise +false+. The default value is +false+.
106
+ #
107
+ # [:float_conversion_type]
108
+ #
109
+ # +:ruby+ when Oracle decimal numbers are converted to ruby Float values
110
+ # same as Float#to_s does. (default)
111
+ # +:oracle:+ when they are done by Oracle OCI functions.
112
+ #
113
+ # From ruby 1.9.2, a float value converted from Oracle number 15.7 by
114
+ # the Oracle function OCINumberToReal() makes a string representation
115
+ # 15.700000000000001 by Float#to_s.
116
+ # See: https://web.archive.org/web/20140521195004/https://rubyforge.org/forum/forum.php?thread_id=50030&forum_id=1078
117
+ #
118
+ # *Since:* 2.1.0
119
+ #
120
+ # [:statement_cache_size]
121
+ #
122
+ # The statement cache size per each session. The default size is 0, which
123
+ # means no statement cache, since 2.1.2. It was 20 in 2.1.1.
124
+ # See: http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci09adv.htm#i471377
125
+ #
126
+ # *Since:* 2.1.1
127
+ #
128
+ # [:events_mode]
129
+ #
130
+ # +true+ when Fast Application Notification (FAN) Support is enabled.
131
+ # +false+ when it is disabled. The default value is +false+.
132
+ # This corresponds to {http://php.net/manual/en/oci8.configuration.php#ini.oci8.events +oci8.events+ in PHP}.
133
+ #
134
+ # This parameter can be changed only when no OCI methods are called.
135
+ #
136
+ # require 'oci8'
137
+ # OCI8.properties[:events_mode] = true # works fine.
138
+ # # ... call some OCI methods ...
139
+ # OCI8.properties[:events_mode] = true # raises a runtime error.
140
+ #
141
+ # *Since:* 2.1.4
142
+ #
143
+ # [:cancel_read_at_exit]
144
+ #
145
+ # +true+ when read system calls are canceled at exit. Otherwise, +false+.
146
+ # The default value is +false+ because it uses unusual technique which
147
+ # hooks read system calls issued by Oracle client library and it works
148
+ # only on Linux, OSX and Windows.
149
+ # This feature is added not to block ruby process termination when
150
+ # network quality is poor and packets are lost irregularly.
151
+ #
152
+ # *Since:* 2.1.8
153
+ #
154
+ # [:tcp_connect_timeout]
155
+ #
156
+ # See {file:docs/timeout-parameters.md}
157
+ #
158
+ # *Since:* 2.2.2
159
+ #
160
+ # [:connect_timeout]
161
+ #
162
+ # See {file:docs/timeout-parameters.md}
163
+ #
164
+ # *Since:* 2.2.2
165
+ #
166
+ # [:send_timeout]
167
+ #
168
+ # See {file:docs/timeout-parameters.md}
169
+ #
170
+ # *Since:* 2.2.2
171
+ #
172
+ # [:recv_timeout]
173
+ #
174
+ # See {file:docs/timeout-parameters.md}
175
+ #
176
+ # *Since:* 2.2.2
177
+ #
178
+ # [:tcp_keepalive]
179
+ #
180
+ # See {file:docs/hanging-after-inactivity.md}
181
+ #
182
+ # *Since:* 2.2.4
183
+ #
184
+ # [:tcp_keepalive_time]
185
+ #
186
+ # See {file:docs/hanging-after-inactivity.md}
187
+ #
188
+ # *Since:* 2.2.4
189
+ #
190
+ # @return [a customized Hash]
191
+ # @since 2.0.5
192
+ #
193
+ def self.properties
194
+ @@properties
195
+ end
196
+ end
@@ -0,0 +1,3 @@
1
+ class OCI8
2
+ VERSION = "2.2.10"
3
+ end
data/lib/oci8.rb ADDED
@@ -0,0 +1,190 @@
1
+ # --*- ruby -*--
2
+ # This is based on yoshidam's oracle.rb.
3
+ #
4
+ # sample one liner:
5
+ # ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
6
+ # # select all data from emp and print them as CVS format.
7
+
8
+ ENV['ORA_SDTZ'] = ENV['TZ'] unless ENV['ORA_SDTZ']
9
+
10
+ if RUBY_PLATFORM =~ /cygwin/
11
+ # Cygwin manages environment variables by itself.
12
+ # They don't synchroize with Win32's ones.
13
+ # This set some Oracle's environment variables to win32's enviroment.
14
+ require 'fiddle'
15
+ win32setenv = Fiddle::Function.new( Fiddle.dlopen('Kernel32.dll')['SetEnvironmentVariableA'],
16
+ [Fiddle::TYPE_VOIDP,Fiddle::TYPE_VOIDP],
17
+ Fiddle::TYPE_INT )
18
+
19
+ ['NLS_LANG', 'TNS_ADMIN', 'LOCAL'].each do |name|
20
+ val = ENV[name]
21
+ win32setenv.call(name, val && val.dup)
22
+ end
23
+ ENV.each do |name, val|
24
+ win32setenv.call(name, val && val.dup) if name =~ /^ORA/
25
+ end
26
+ end
27
+
28
+ ruby_engine = (defined? RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
29
+
30
+ so_basename = 'oci8lib_'
31
+ case ruby_engine
32
+ when 'ruby'
33
+ # The extension library name includes the ruby ABI (application binary interface)
34
+ # version. It is for binary gems which contain more than one extension library
35
+ # and use correct one depending on the ABI version.
36
+ #
37
+ # ruby version | ABI version
38
+ # --------------+--------------
39
+ # 1.8.6 | 1.8
40
+ # 1.8.7 | 1.8
41
+ # --------------+--------------
42
+ # 1.9.0 | 1.9.0
43
+ # 1.9.1 | 1.9.1
44
+ # 1.9.2 | 1.9.1
45
+ # 1.9.3 | 1.9.1
46
+ # --------------+--------------
47
+ # 2.0.0 | 2.0.0
48
+ # --------------+--------------
49
+ # 2.1.0 | 2.1.0
50
+ # ... | ...
51
+ #
52
+ # The ABI version of ruby 2.1.1 will be 2.1.0.
53
+ # See "ABI Compatibility" in <URL:http://www.ruby-lang.org/en/news/2013/12/21/semantic-versioning-after-2-1-0/>.
54
+ #
55
+ case RUBY_VERSION
56
+ when /^1\.9\.0/
57
+ raise 'unsupported ruby version: 1.9.0'
58
+ when /^1\.9/
59
+ so_basename += '191'
60
+ when /^1\.8/
61
+ so_basename += '18'
62
+ else
63
+ so_basename += RUBY_VERSION.gsub(/(\d+)\.(\d+).(.*)/, '\1\20')
64
+ end
65
+ when 'rbx'
66
+ so_basename += 'rbx'
67
+ when 'jruby'
68
+ raise "Ruby-oci8 doesn't support jruby because its C extension support is in development in jruby 1.6 and deprecated in jruby 1.7."
69
+ when 'truffleruby'
70
+ so_basename += 'truffleruby'
71
+ else
72
+ raise 'unsupported ruby engine: ' + RUBY_ENGINE
73
+ end
74
+
75
+ dll_dir = nil
76
+ begin
77
+ require 'ruby_installer/runtime' # RubyInstaller2 for Windows
78
+
79
+ dll_arch = proc do |file|
80
+ begin
81
+ File.open(file, 'rb') do |f|
82
+ if f.read(2) == 'MZ' # IMAGE_DOS_HEADER.e_magic
83
+ f.seek(60, IO::SEEK_SET)
84
+ pe_offset = f.read(4).unpack('V')[0] # IMAGE_DOS_HEADER.e_lfanew
85
+ f.seek(pe_offset)
86
+ if f.read(4) == "PE\000\000" # IMAGE_NT_HEADERS.Signature
87
+ case f.read(2).unpack('v')[0] # IMAGE_FILE_HEADER.Machine
88
+ when 0x014c # IMAGE_FILE_MACHINE_I386
89
+ :x86
90
+ when 0x8664 # IMAGE_FILE_MACHINE_AMD64
91
+ :x64
92
+ end
93
+ end
94
+ end
95
+ end
96
+ rescue
97
+ nil
98
+ end
99
+ end
100
+
101
+ ruby_arch = [nil].pack('P').size == 8 ? :x64 : :x86
102
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
103
+ if !path.empty? && dll_arch.call(File.join(path, 'OCI.DLL')) == ruby_arch
104
+ dll_dir = RubyInstaller::Runtime.add_dll_directory(path)
105
+ break
106
+ end
107
+ end
108
+ rescue LoadError
109
+ end
110
+
111
+ begin
112
+ require so_basename
113
+ rescue LoadError
114
+ require 'oci8/check_load_error'
115
+ OCI8::Util::check_load_error($!)
116
+ raise
117
+ ensure
118
+ dll_dir.remove if dll_dir
119
+ end
120
+
121
+ require 'oci8/version.rb'
122
+ if OCI8::VERSION != OCI8::LIB_VERSION
123
+ require 'rbconfig'
124
+ so_name = so_basename + "." + RbConfig::CONFIG['DLEXT']
125
+ raise "VERSION MISMATCH! #{so_name} version is #{OCI8::LIB_VERSION}, but oci8.rb version is #{OCI8::VERSION}."
126
+ end
127
+
128
+ require 'oci8/encoding-init.rb'
129
+ require 'oci8/oracle_version.rb'
130
+
131
+ class OCI8
132
+ # @private
133
+ ORAVER_8_0 = OCI8::OracleVersion.new(8, 0)
134
+ # @private
135
+ ORAVER_8_1 = OCI8::OracleVersion.new(8, 1)
136
+ # @private
137
+ ORAVER_9_0 = OCI8::OracleVersion.new(9, 0)
138
+ # @private
139
+ ORAVER_9_2 = OCI8::OracleVersion.new(9, 2)
140
+ # @private
141
+ ORAVER_10_1 = OCI8::OracleVersion.new(10, 1)
142
+ # @private
143
+ ORAVER_10_2 = OCI8::OracleVersion.new(10, 2)
144
+ # @private
145
+ ORAVER_11_1 = OCI8::OracleVersion.new(11, 1)
146
+ # @private
147
+ ORAVER_12_1 = OCI8::OracleVersion.new(12, 1)
148
+ # @private
149
+ ORAVER_18 = OCI8::OracleVersion.new(18)
150
+
151
+ # @private
152
+ @@oracle_client_version = OCI8::OracleVersion.new(self.oracle_client_vernum)
153
+
154
+ # Returns an OCI8::OracleVersion of the Oracle client version.
155
+ #
156
+ # If this library is configured without '--with-runtime-check',
157
+ # and compiled for Oracle 10.1 or lower, the major and minor
158
+ # numbers are determined at compile-time. The rests are zeros.
159
+ #
160
+ # If this library is configured with '--with-runtime-check'
161
+ # and the runtime Oracle library is Oracle 10.1 or lower, the
162
+ # major and minor numbers are determined at run-time. The
163
+ # rests are zeros.
164
+ #
165
+ # Otherwise, it is the version retrieved from an OCI function
166
+ # OCIClientVersion().
167
+ #
168
+ # @return [OCI8::OracleVersion] Oracle client version
169
+ # @see OCI8#oracle_server_version
170
+ def self.oracle_client_version
171
+ @@oracle_client_version
172
+ end
173
+
174
+ # defined for backward compatibility.
175
+ # @private
176
+ CLIENT_VERSION = @@oracle_client_version.major.to_s +
177
+ @@oracle_client_version.minor.to_s +
178
+ @@oracle_client_version.update.to_s
179
+ end
180
+
181
+ require 'oci8/ocihandle.rb'
182
+ require 'oci8/datetime.rb'
183
+ require 'oci8/oci8.rb'
184
+ require 'oci8/cursor.rb'
185
+ require 'oci8/bindtype.rb'
186
+ require 'oci8/metadata.rb'
187
+ require 'oci8/compat.rb'
188
+ require 'oci8/object.rb'
189
+ require 'oci8/connection_pool.rb'
190
+ require 'oci8/properties.rb'
Binary file
data/lib/ruby-oci8.rb ADDED
@@ -0,0 +1 @@
1
+ require 'oci8'
data/metaconfig ADDED
@@ -0,0 +1,142 @@
1
+ # --*- ruby -*--
2
+
3
+ ToplevelInstaller::TASKS.push ['test', 'run test.']
4
+ ToplevelInstaller::TASKS.push ['distbin', 'make binary package.']
5
+ ToplevelInstaller.module_eval {
6
+ alias parsearg_test parsearg_no_options
7
+ alias parsearg_distbin parsearg_no_options
8
+
9
+ def exec_test
10
+ old = Dir.pwd
11
+ @installer.mkdir_p "#{objdir_root}/test"
12
+ Dir.chdir "#{objdir_root}/test"
13
+ @installer.ruby("-w -I#{srcdir_root}/ext/oci8 -I#{srcdir_root}/lib -I#{srcdir_root}/support -I#{srcdir_root}/test #{srcdir_root}/test/test_all.rb")
14
+ Dir.chdir old
15
+ end
16
+
17
+ def get_zcontent(file)
18
+ require 'base64'
19
+ require 'zlib'
20
+ File.open(file, 'rb') do |f|
21
+ Base64.encode64(Zlib::Deflate::deflate(f.read))
22
+ end
23
+ end
24
+
25
+ def exec_distbin
26
+ File.open("ruby-oci8-#{RUBY_PLATFORM}.rb", 'w') do |f|
27
+ f.write <<-EOT
28
+ # ruby-oci8 binary installer for #{RUBY_PLATFORM}
29
+ require 'rbconfig'
30
+ require 'base64'
31
+ require 'ftools'
32
+ require 'zlib'
33
+
34
+ def msg_error(msg)
35
+ puts "ERROR: "
36
+ puts msg
37
+ exit 1
38
+ end
39
+
40
+ def msg_ok(msg)
41
+ puts msg
42
+ end
43
+
44
+ def msg_ask(msg)
45
+ puts msg
46
+ $stdout.print "Enter Yes/No: "
47
+ $stdout.flush
48
+ ret = gets().chomp.downcase
49
+ if ret == 'y' || ret == 'ye' || ret == 'yes'
50
+ return
51
+ else
52
+ exit 1
53
+ end
54
+ end
55
+
56
+ if '#{RUBY_PLATFORM}' != RUBY_PLATFORM
57
+ msg_ask "This package is for #{RUBY_PLATFORM}\\ninstall anyway?"
58
+ end
59
+
60
+ class Installer
61
+ @@log = ""
62
+ def initialize(install_files)
63
+ @files = []
64
+ install_files.each do |file, content|
65
+ basename = File.basename(file)
66
+ dirname = File.dirname(file)
67
+ if dirname == '.'
68
+ dirname = ''
69
+ else
70
+ dirname = '/' + dirname
71
+ end
72
+ case basename
73
+ when /\.so$/
74
+ dirname = "\#{Config::CONFIG['sitearchdir']}\#{dirname}"
75
+ else
76
+ dirname = "\#{Config::CONFIG['sitelibdir']}\#{dirname}"
77
+ end
78
+ @files << [basename, dirname, content]
79
+ end
80
+ @files.sort! do |x, y| x[0] <=> y[0] end
81
+ end
82
+
83
+ def confirm
84
+ msg = ""
85
+ @files.each do |f|
86
+ basename, dirname, content = f
87
+ msg << "Copy \#{basename} to \#{dirname}\\n"
88
+ end
89
+ msg << "OK?\\n"
90
+ msg_ask(msg)
91
+ end
92
+
93
+ def install
94
+ @@log = ""
95
+ @files.each do |f|
96
+ basename, dirname, content = f
97
+ @@log << "Copying \#{basename} to \#{dirname} ... "
98
+ if not FileTest.directory?(dirname)
99
+ File.makedirs(dirname)
100
+ end
101
+ File.open("\#{dirname}/\#{basename}", "wb") do |f|
102
+ f.write(Zlib::Inflate::inflate(Base64.decode64(content)))
103
+ end
104
+ @@log << "done\\n"
105
+ end
106
+ @@log << "OK\\n"
107
+ msg_ok(@@log)
108
+ end
109
+
110
+ def self.log
111
+ @@log
112
+ end
113
+ end
114
+
115
+ install_files = {}
116
+
117
+ install_files['oci8lib.so'] = <<-EOS
118
+ #{get_zcontent('ext/oci8/oci8lib.so')}EOS
119
+
120
+ install_files['oci8.rb'] = <<-EOS
121
+ #{get_zcontent('lib/oci8.rb')}EOS
122
+
123
+ install_files['DBD/OCI8/OCI8.rb'] = <<-EOS
124
+ #{get_zcontent('lib/DBD/OCI8/OCI8.rb')}EOS
125
+
126
+ begin
127
+ installer = Installer.new(install_files)
128
+ installer.confirm
129
+ installer.install
130
+ rescue
131
+ msg_error(Installer.log + "\\n" + $!.to_s)
132
+ end
133
+ EOT
134
+ end
135
+ end
136
+ }
137
+
138
+
139
+ ConfigTable.add_entry('oracle_version', ['',
140
+ 'name',
141
+ 'Oracle version name',
142
+ 'NONE' ])
data/pre-distclean.rb ADDED
@@ -0,0 +1,7 @@
1
+ rm_f "#{curr_objdir}/lib/oci8.rb"
2
+ rm_f "#{curr_objdir}/ext/oci8/oci8lib_18.map"
3
+ rm_f "#{curr_objdir}/ext/oci8/oci8lib_191.map"
4
+ if RUBY_PLATFORM =~ /cygwin/
5
+ rm_f "#{curr_objdir}/ext/oci8/OCI.def"
6
+ rm_f "#{curr_objdir}/ext/oci8/libOCI.a"
7
+ end