ruby-oci8 1.0.7-x86-mswin32-60 → 2.0.1-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/ChangeLog +1289 -383
  2. data/Makefile +48 -12
  3. data/NEWS +5 -419
  4. data/README +56 -385
  5. data/VERSION +1 -1
  6. data/dist-files +27 -27
  7. data/lib/.document +2 -0
  8. data/lib/dbd/OCI8.rb +2 -17
  9. data/lib/oci8.rb +48 -1622
  10. data/lib/oci8.rb.in +48 -1622
  11. data/lib/oci8/.document +5 -0
  12. data/lib/oci8/compat.rb +108 -0
  13. data/lib/oci8/datetime.rb +491 -0
  14. data/lib/oci8/encoding-init.rb +40 -0
  15. data/lib/oci8/encoding.yml +537 -0
  16. data/lib/oci8/metadata.rb +2077 -0
  17. data/lib/oci8/object.rb +548 -0
  18. data/lib/oci8/oci8.rb +798 -0
  19. data/lib/oci8/oracle_version.rb +144 -0
  20. data/lib/oci8lib_18.so +0 -0
  21. data/lib/oci8lib_191.so +0 -0
  22. data/metaconfig +3 -3
  23. data/ruby-oci8.gemspec +24 -15
  24. data/setup.rb +4 -4
  25. data/test/config.rb +64 -84
  26. data/test/test_all.rb +14 -21
  27. data/test/test_array_dml.rb +333 -0
  28. data/test/test_bind_raw.rb +18 -25
  29. data/test/test_bind_time.rb +78 -91
  30. data/test/test_break.rb +37 -35
  31. data/test/test_clob.rb +33 -89
  32. data/test/test_connstr.rb +5 -4
  33. data/test/test_datetime.rb +469 -0
  34. data/test/test_dbi.rb +99 -60
  35. data/test/test_dbi_clob.rb +3 -8
  36. data/test/test_metadata.rb +65 -51
  37. data/test/test_oci8.rb +151 -55
  38. data/test/test_oracle_version.rb +70 -0
  39. data/test/test_oradate.rb +76 -83
  40. data/test/test_oranumber.rb +405 -71
  41. data/test/test_rowid.rb +6 -11
  42. metadata +21 -25
  43. data/ext/oci8/oci8lib.so +0 -0
  44. data/ruby-oci8.spec +0 -62
  45. data/support/README +0 -4
  46. data/support/runit/assert.rb +0 -281
  47. data/support/runit/cui/testrunner.rb +0 -101
  48. data/support/runit/error.rb +0 -4
  49. data/support/runit/method_mappable.rb +0 -20
  50. data/support/runit/robserver.rb +0 -25
  51. data/support/runit/setuppable.rb +0 -15
  52. data/support/runit/teardownable.rb +0 -16
  53. data/support/runit/testcase.rb +0 -113
  54. data/support/runit/testfailure.rb +0 -25
  55. data/support/runit/testresult.rb +0 -121
  56. data/support/runit/testsuite.rb +0 -43
  57. data/support/runit/version.rb +0 -3
  58. data/test/test_describe.rb +0 -137
@@ -0,0 +1,144 @@
1
+ # oracle_version.rb implements OCI8::OracleVersion.
2
+ #
3
+ # Copyright (C) 2009 KUBO Takehiro <kubo@jiubao.org>
4
+
5
+ #--
6
+
7
+ class OCI8
8
+
9
+ # A data class, representing Oracle version.
10
+ #
11
+ # Oracle version is represented by five numbers:
12
+ # *major*, *minor*, *update*, *patch* and *port_update*.
13
+ class OracleVersion
14
+ include Comparable
15
+
16
+ # The first part of the Oracle version.
17
+ attr_reader :major
18
+ # The second part of the Oracle version.
19
+ attr_reader :minor
20
+ # The third part of the Oracle version.
21
+ attr_reader :update
22
+ # The fifth part of the Oracle version.
23
+ attr_reader :patch
24
+ # The fourth part of the Oracle version.
25
+ attr_reader :port_update
26
+
27
+ # Creates a OCI8::OracleVersion object.
28
+ #
29
+ # If the first argument _arg_ is a String, it is parsed as dotted
30
+ # version string. If it is bigger than 0x08000000, it is parsed as
31
+ # a number contains 5-digit Oracle version. Otherwise, it is used
32
+ # as a major version and the rest arguments are minor, update,
33
+ # patch and port_update. Unspecified version numbers are zeros by
34
+ # default.
35
+ #
36
+ # == Example
37
+ # oraver = OCI8::OracleVersion.new('10.2.0.4')
38
+ # oraver.major # => 10
39
+ # oraver.minor # => 2
40
+ # oraver.update # => 0
41
+ # oraver.patch # => 4
42
+ # oraver.port_update # => 0
43
+ #
44
+ # oraver = OCI8::OracleVersion.new(0x0a200400)
45
+ # oraver.major # => 10
46
+ # oraver.minor # => 2
47
+ # oraver.update # => 0
48
+ # oraver.patch # => 4
49
+ # oraver.port_update # => 0
50
+ def initialize(arg, minor = nil, update = nil, patch = nil, port_update = nil)
51
+ if arg.is_a? String
52
+ major, minor, update, patch, port_update = arg.split('.').collect do |v|
53
+ v.to_i
54
+ end
55
+ elsif arg >= 0x08000000
56
+ major = (arg & 0xFF000000) >> 24
57
+ minor = (arg & 0x00F00000) >> 20
58
+ update = (arg & 0x000FF000) >> 12
59
+ patch = (arg & 0x00000F00) >> 8
60
+ port_update = (arg & 0x000000FF)
61
+ else
62
+ major = arg
63
+ end
64
+ @major = major
65
+ @minor = minor || 0
66
+ @update = update || 0
67
+ @patch = patch || 0
68
+ @port_update = port_update || 0
69
+ end
70
+
71
+ # :call-seq:
72
+ # oraver <=> other_oraver -> -1, 0, +1
73
+ #
74
+ # Compares +oraver+ and +other_oraver+.
75
+ #
76
+ # <=> is the basis for the methods <, <=, ==, >, >=, and between?,
77
+ # included from module Comparable.
78
+ def <=>(other)
79
+ cmp = @major <=> other.major
80
+ return cmp if cmp != 0
81
+ cmp = @minor <=> other.minor
82
+ return cmp if cmp != 0
83
+ cmp = @update <=> other.update
84
+ return cmp if cmp != 0
85
+ cmp = @patch <=> other.patch
86
+ return cmp if cmp != 0
87
+ @port_update <=> other.port_update
88
+ end
89
+
90
+ # :call-seq:
91
+ # oraver.to_i -> integer
92
+ #
93
+ # Returns an integer number contains 5-digit Oracle version.
94
+ #
95
+ # If the hexadecimal notation is 0xAABCCDEE, *major*, *minor*,
96
+ # *update*, *patch* and *port_update* are 0xAA, 0xB, 0xCC, 0xD and
97
+ # 0xEE respectively.
98
+ #
99
+ # == Example
100
+ # oraver = OCI8::OracleVersion.new('10.2.0.4')
101
+ # oraver.to_i # => 169870336
102
+ # '%08x' % oraver.to_i # => "0a200400"
103
+ def to_i
104
+ (@major << 24) | (@minor << 20) | (@update << 12) | (@patch << 8) | @port_update
105
+ end
106
+
107
+ # :call-seq:
108
+ # oraver.to_s -> string
109
+ #
110
+ # Returns a dotted version string of the Oracle version.
111
+ #
112
+ # == Example
113
+ # oraver = OCI8::OracleVersion.new('10.2.0.4')
114
+ # oraver.to_s # => '10.2.0.4.0'
115
+ def to_s
116
+ format('%d.%d.%d.%d.%d', @major, @minor, @update, @patch, @port_update)
117
+ end
118
+
119
+ # :call-seq:
120
+ # oraver.eql? other -> true or false
121
+ #
122
+ # Returns true if +oraver+ and +other+ are the same type and have
123
+ # equal values.
124
+ #--
125
+ # This is for class Hash to test members for equality.
126
+ def eql?(other)
127
+ other.is_a? OCI8::OracleVersion and (self <=> other) == 0
128
+ end
129
+
130
+ # :call-seq:
131
+ # oraver.hash -> integer
132
+ #
133
+ # Returns a hash based on the value of +oraver+.
134
+ #--
135
+ # This is for class Hash.
136
+ def hash
137
+ to_i
138
+ end
139
+
140
+ def inspect # :nodoc:
141
+ "#<#{self.class.to_s}: #{self.to_s}>"
142
+ end
143
+ end
144
+ end
Binary file
Binary file
data/metaconfig CHANGED
@@ -10,7 +10,7 @@ ToplevelInstaller.module_eval {
10
10
  old = Dir.pwd
11
11
  @installer.mkdir_p "#{objdir_root}/test"
12
12
  Dir.chdir "#{objdir_root}/test"
13
- @installer.ruby("-I#{srcdir_root}/ext/oci8 -I#{srcdir_root}/lib -I#{srcdir_root}/support -I#{srcdir_root}/test #{srcdir_root}/test/test_all.rb")
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
14
  Dir.chdir old
15
15
  end
16
16
 
@@ -120,8 +120,8 @@ install_files['oci8lib.so'] = <<-EOS
120
120
  install_files['oci8.rb'] = <<-EOS
121
121
  #{get_zcontent('lib/oci8.rb')}EOS
122
122
 
123
- install_files['dbd/OCI8.rb'] = <<-EOS
124
- #{get_zcontent('lib/dbd/OCI8.rb')}EOS
123
+ install_files['DBD/OCI8/OCI8.rb'] = <<-EOS
124
+ #{get_zcontent('lib/DBD/OCI8/OCI8.rb')}EOS
125
125
 
126
126
  begin
127
127
  installer = Installer.new(install_files)
@@ -6,6 +6,7 @@
6
6
  # To make a binary gems package:
7
7
  # gem build ruby-oci8.gemspec -- current
8
8
  #
9
+ require 'fileutils'
9
10
 
10
11
  if ARGV.size > 3
11
12
  gem_platform = ARGV[3]
@@ -23,32 +24,40 @@ spec = Gem::Specification.new do |s|
23
24
  s.description = <<EOS
24
25
  ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle8, Oracle8i, Oracle9i, Oracle10g and Oracle Instant Client.
25
26
  EOS
26
- s.autorequire = 'oci8'
27
27
  s.has_rdoc = true
28
- s.required_ruby_version = '~> 1.8.0'
29
28
  s.authors = ['KUBO Takehiro']
30
29
  s.platform = gem_platform
31
30
  files = File.read('dist-files').split("\n")
32
31
  if gem_platform == Gem::Platform::RUBY
33
- s.require_paths = ['lib']
34
32
  s.extensions << 'ext/oci8/extconf.rb'
33
+ s.required_ruby_version = '>= 1.8.0'
35
34
  else
36
- s.require_paths = ['lib', 'ext/oci8']
37
- # exclude C source files.
38
- files.delete_if do |file|
39
- file[0, 4] == 'ext/'
35
+ so_files = Dir.glob('ext/oci8/oci8lib_*.so')
36
+ has_1_8 = so_files.include? 'ext/oci8/oci8lib_18.so'
37
+ has_1_9_1 = so_files.include? 'ext/oci8/oci8lib_191.so'
38
+ if has_1_8 and has_1_9_1
39
+ puts 'Binary gem for ruby 1.8 and 1.9.1'
40
+ s.required_ruby_version = '>= 1.8.0'
41
+ elsif has_1_8 and !has_1_9_1
42
+ puts 'Binary gem for ruby 1.8'
43
+ s.required_ruby_version = '~> 1.8.0'
44
+ elsif !has_1_8 and has_1_9_1
45
+ puts 'Binary gem for ruby 1.9.1'
46
+ s.required_ruby_version = '~> 1.9.1'
47
+ else
48
+ raise "No compiled binary are found. Run make in advance."
40
49
  end
41
- # check files created by a make command.
42
- ['ext/oci8/oci8lib.so', 'lib/oci8.rb'].each do |file|
43
- raise <<EOS unless File.exist?(file)
44
- #{file} doesn't exist. Run make in advance.
45
- EOS
46
- #'
47
- files << file
50
+ FileUtils.copy so_files, 'lib', :preserve => true
51
+ files.reject! do |fname|
52
+ fname =~ /^ext/
53
+ end
54
+ so_files.each do |fname|
55
+ files << 'lib/' + File.basename(fname)
48
56
  end
57
+ files << 'lib/oci8.rb'
49
58
  end
50
59
  s.files = files
51
60
  s.test_files = 'test/test_all.rb'
52
- s.rdoc_options = ['--main', 'README', '--exclude', 'ext/*']
61
+ s.rdoc_options = ['--main', 'README']
53
62
  s.extra_rdoc_files = ['README']
54
63
  end
data/setup.rb CHANGED
@@ -91,7 +91,7 @@ end
91
91
  # Config
92
92
  #
93
93
 
94
- if arg = ARGV.detect{|arg| /\A--rbconfig=/ =~ arg }
94
+ if arg = ARGV.detect{|a| /\A--rbconfig=/ =~ a }
95
95
  ARGV.delete(arg)
96
96
  require arg.split(/=/, 2)[1]
97
97
  $".push 'rbconfig.rb'
@@ -145,7 +145,7 @@ class ConfigTable
145
145
  sodir = "$site-ruby/#{c['arch']}"
146
146
  end
147
147
 
148
- if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
148
+ if arg = c['configure_args'].split.detect {|a| /--with-make-prog=/ =~ a }
149
149
  makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
150
150
  else
151
151
  makeprog = 'make'
@@ -495,7 +495,7 @@ module FileOperations
495
495
  end
496
496
 
497
497
  REJECT_DIRS = %w(
498
- CVS SCCS RCS CVS.adm
498
+ CVS SCCS RCS CVS.adm .svn .git
499
499
  )
500
500
 
501
501
  def all_dirs_in(dirname)
@@ -1163,7 +1163,7 @@ class Installer
1163
1163
  end
1164
1164
 
1165
1165
  def ruby_scripts
1166
- collect_filenames_auto().select {|n| /\.rb\z/ =~ n }
1166
+ collect_filenames_auto().select {|n| /\.(rb|yml)\z/ =~ n }
1167
1167
  end
1168
1168
 
1169
1169
  # picked up many entries from cvs-1.11.1/src/ignore.c
@@ -24,106 +24,86 @@ $lobreadnum = 256 # counts in charactors
24
24
  # $oracle_client_version: Oracle client library version for which oci8 is compiled.
25
25
  # $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
26
26
  conn = OCI8.new($dbuser, $dbpass, $dbname)
27
- conn.exec('select value from database_compatible_level') do |row|
28
- ver = row[0].split('.')
29
- $oracle_server_version = (ver[0] + ver[1] + ver[2]).to_i
27
+ begin
28
+ conn.exec('select value from database_compatible_level') do |row|
29
+ $oracle_server_version = OCI8::OracleVersion.new(row[0])
30
+ end
31
+ rescue OCIError
32
+ raise if $!.code != 942 # ORA-00942: table or view does not exist
33
+ $oracle_server_version = OCI8::ORAVER_8_0
30
34
  end
31
35
  conn.logoff
32
- $oracle_client_version = OCI8::CLIENT_VERSION.to_i
33
- if $oracle_server_version < $oracle_client_version
36
+
37
+ if $oracle_server_version < OCI8.oracle_client_version
34
38
  $oracle_version = $oracle_server_version
35
39
  else
36
- $oracle_version = $oracle_client_version
40
+ $oracle_version = OCI8.oracle_client_version
37
41
  end
38
42
 
39
- if $oracle_version <= 805
40
- $describe_need_object_mode = true
41
- $test_clob = false
42
- elsif $oracle_version < 810
43
- $describe_need_object_mode = false
43
+ if $oracle_version < OCI8::ORAVER_8_1
44
44
  $test_clob = false
45
45
  else
46
- $describe_need_object_mode = false
47
46
  $test_clob = true
48
47
  end
49
48
 
50
- def do_connect ()
51
- begin
52
- yield
53
- rescue OCIError
54
- raise if $!.code != 12516 && $!.code != 12520
55
- # sleep a few seconds and try again if
56
- # the error code is ORA-12516 or ORA-12520.
57
- #
58
- # ORA-12516 - TNS:listener could not find available handler with
59
- # matching protocol stack
60
- # ORA-12520 - TNS:listener could not find available handler for
61
- # requested type of server
62
- #
63
- # Thanks to Christopher Jones.
64
- #
65
- # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
66
- # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
67
- #
68
- sleep(5)
69
- yield
70
- end
71
- end
72
-
73
- $env_is_initialized = false
74
- def setup_lowapi()
75
- if ! $env_is_initialized
76
- if $describe_need_object_mode
77
- OCIEnv.initialise(OCI_OBJECT)
78
- else
79
- OCIEnv.initialise(OCI_DEFAULT)
80
- end
81
- $env_is_initialized = true
82
- end
83
- env = OCIEnv.init()
84
- svc = do_connect { env.logon($dbuser, $dbpass, $dbname) }
85
- stmt = env.alloc(OCIStmt)
86
- return env, svc, stmt
87
- end
88
-
89
- def get_oci_connection()
90
- do_connect { OCI8.new($dbuser, $dbpass, $dbname) }
91
- end
49
+ module Test
50
+ module Unit
51
+ class TestCase
92
52
 
93
- def get_dbi_connection()
94
- do_connect { DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) }
95
- end
53
+ def get_oci8_connection()
54
+ OCI8.new($dbuser, $dbpass, $dbname)
55
+ rescue OCIError
56
+ raise if $!.code != 12516 && $!.code != 12520
57
+ # sleep a few second and try again if
58
+ # the error code is ORA-12516 or ORA-12520.
59
+ #
60
+ # ORA-12516 - TNS:listener could not find available handler with
61
+ # matching protocol stack
62
+ # ORA-12520 - TNS:listener could not find available handler for
63
+ # requested type of server
64
+ #
65
+ # Thanks to Christopher Jones.
66
+ #
67
+ # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
68
+ # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
69
+ #
70
+ sleep(5)
71
+ OCI8.new($dbuser, $dbpass, $dbname)
72
+ end
96
73
 
97
- module RUNIT
98
- class TestCase
99
- def drop_table(table_name)
100
- if $oracle_server_version < 1000
101
- # Oracle 8 - 9i
102
- sql = "DROP TABLE #{table_name}"
103
- else
104
- # Oracle 10g -
105
- sql = "DROP TABLE #{table_name} PURGE"
74
+ def get_dbi_connection()
75
+ DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
76
+ rescue DBI::DatabaseError
77
+ raise if $!.err != 12516 && $!.err != 12520
78
+ # same as get_oci8_connection()
79
+ sleep(5)
80
+ DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
106
81
  end
107
82
 
108
- if defined? @conn
109
- begin
110
- @conn.exec(sql)
111
- rescue OCIError
112
- raise if $!.code != 942 # table or view does not exist
113
- end
114
- elsif defined? @dbh
115
- begin
116
- @dbh.do(sql)
117
- rescue DBI::DatabaseError
118
- raise if $!.err != 942 # table or view does not exist
83
+ def drop_table(table_name)
84
+ if $oracle_server_version < OCI8::ORAVER_10_1
85
+ # Oracle 8 - 9i
86
+ sql = "DROP TABLE #{table_name}"
87
+ else
88
+ # Oracle 10g -
89
+ sql = "DROP TABLE #{table_name} PURGE"
119
90
  end
120
- elsif defined? @stmt
121
- begin
122
- @stmt.prepare(sql).execute(@svc)
123
- rescue OCIError
124
- raise if $!.code != 942 # table or view does not exist
91
+
92
+ if defined? @conn
93
+ begin
94
+ @conn.exec(sql)
95
+ rescue OCIError
96
+ raise if $!.code != 942 # table or view does not exist
97
+ end
98
+ elsif instance_variable_get(:@dbh)
99
+ begin
100
+ @dbh.do(sql)
101
+ rescue DBI::DatabaseError
102
+ raise if $!.err != 942 # table or view does not exist
103
+ end
125
104
  end
126
- end
127
- end # drop_table
105
+ end # drop_table
106
+ end
128
107
  end
129
108
  end
109
+
@@ -1,48 +1,41 @@
1
- require 'runit/testsuite'
2
- require 'runit/cui/testrunner'
3
-
4
1
  srcdir = File.dirname(__FILE__)
5
2
 
6
- # Low-level API
3
+ require 'oci8'
4
+ require 'test/unit'
5
+ require "#{srcdir}/config"
6
+
7
7
  require "#{srcdir}/test_oradate"
8
8
  require "#{srcdir}/test_oranumber"
9
- require "#{srcdir}/test_describe"
10
9
  require "#{srcdir}/test_bind_time"
11
10
  require "#{srcdir}/test_bind_raw"
12
11
  if $test_clob
13
12
  require "#{srcdir}/test_clob"
14
13
  end
15
14
 
16
- # High-level API
17
15
  require "#{srcdir}/test_break"
18
16
  require "#{srcdir}/test_oci8"
17
+ require "#{srcdir}/test_datetime"
19
18
  require "#{srcdir}/test_connstr"
20
19
  require "#{srcdir}/test_metadata"
20
+ require "#{srcdir}/test_array_dml"
21
21
  require "#{srcdir}/test_rowid"
22
+ require "#{srcdir}/test_oracle_version"
22
23
 
23
24
  # Ruby/DBI
24
25
  begin
25
26
  require 'dbi'
27
+ is_dbi_loaded = true
26
28
  rescue LoadError
27
- begin
28
- require 'rubygems'
29
- require 'dbi'
30
- rescue LoadError
31
- dbi_not_found = false
32
- end
29
+ is_dbi_loaded = false
33
30
  end
34
- unless dbi_not_found
31
+ if is_dbi_loaded
35
32
  require "#{srcdir}/test_dbi"
36
33
  if $test_clob
37
34
  require "#{srcdir}/test_dbi_clob"
38
35
  end
39
36
  end
40
37
 
41
- suite = RUNIT::TestSuite.new
42
- ObjectSpace.each_object(Class) { |klass|
43
- if klass.ancestors.include?(RUNIT::TestCase)
44
- suite.add_test(klass.suite)
45
- end
46
- }
47
- #RUNIT::CUI::TestRunner.quiet_mode = true
48
- RUNIT::CUI::TestRunner.run(suite)
38
+ #Test::Unit::AutoRunner.run(true, true)
39
+ if defined? Test::Unit::AutoRunner
40
+ Test::Unit::AutoRunner.run()
41
+ end