ruby-oci8 1.0.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/ChangeLog +1254 -390
  2. data/Makefile +10 -13
  3. data/README +56 -385
  4. data/VERSION +1 -1
  5. data/dist-files +26 -27
  6. data/ext/oci8/.document +1 -0
  7. data/ext/oci8/MANIFEST +0 -4
  8. data/ext/oci8/apiwrap.c.tmpl +172 -0
  9. data/ext/oci8/apiwrap.h.tmpl +61 -0
  10. data/ext/oci8/apiwrap.rb +91 -0
  11. data/ext/oci8/apiwrap.yml +1243 -0
  12. data/ext/oci8/attr.c +124 -384
  13. data/ext/oci8/bind.c +472 -164
  14. data/ext/oci8/encoding.c +196 -0
  15. data/ext/oci8/env.c +84 -253
  16. data/ext/oci8/error.c +196 -127
  17. data/ext/oci8/extconf.rb +82 -59
  18. data/ext/oci8/lob.c +710 -370
  19. data/ext/oci8/metadata.c +359 -0
  20. data/ext/oci8/object.c +622 -0
  21. data/ext/oci8/oci8.c +577 -161
  22. data/ext/oci8/oci8.h +354 -258
  23. data/ext/oci8/oci8lib.c +493 -0
  24. data/ext/oci8/ocidatetime.c +473 -0
  25. data/ext/oci8/ocinumber.c +1123 -24
  26. data/ext/oci8/oraconf.rb +72 -106
  27. data/ext/oci8/oradate.c +511 -321
  28. data/ext/oci8/stmt.c +752 -572
  29. data/ext/oci8/win32.c +131 -0
  30. data/ext/oci8/xmldb.c +383 -0
  31. data/lib/.document +2 -0
  32. data/lib/dbd/OCI8.rb +2 -17
  33. data/lib/oci8.rb.in +41 -1622
  34. data/lib/oci8/.document +5 -0
  35. data/lib/oci8/compat.rb +108 -0
  36. data/lib/oci8/datetime.rb +489 -0
  37. data/lib/oci8/encoding-init.rb +40 -0
  38. data/lib/oci8/encoding.yml +537 -0
  39. data/lib/oci8/metadata.rb +2077 -0
  40. data/lib/oci8/object.rb +548 -0
  41. data/lib/oci8/oci8.rb +773 -0
  42. data/lib/oci8/oracle_version.rb +144 -0
  43. data/metaconfig +3 -3
  44. data/ruby-oci8.gemspec +5 -5
  45. data/setup.rb +4 -4
  46. data/test/config.rb +64 -84
  47. data/test/test_all.rb +14 -21
  48. data/test/test_array_dml.rb +317 -0
  49. data/test/test_bind_raw.rb +18 -25
  50. data/test/test_bind_time.rb +78 -91
  51. data/test/test_break.rb +37 -35
  52. data/test/test_clob.rb +33 -89
  53. data/test/test_connstr.rb +5 -4
  54. data/test/test_datetime.rb +469 -0
  55. data/test/test_dbi.rb +99 -60
  56. data/test/test_dbi_clob.rb +3 -8
  57. data/test/test_metadata.rb +65 -51
  58. data/test/test_oci8.rb +151 -55
  59. data/test/test_oracle_version.rb +70 -0
  60. data/test/test_oradate.rb +76 -83
  61. data/test/test_oranumber.rb +405 -71
  62. data/test/test_rowid.rb +6 -11
  63. metadata +31 -32
  64. data/NEWS +0 -420
  65. data/ext/oci8/const.c +0 -165
  66. data/ext/oci8/define.c +0 -53
  67. data/ext/oci8/describe.c +0 -81
  68. data/ext/oci8/descriptor.c +0 -39
  69. data/ext/oci8/handle.c +0 -273
  70. data/ext/oci8/oranumber.c +0 -445
  71. data/ext/oci8/param.c +0 -37
  72. data/ext/oci8/server.c +0 -182
  73. data/ext/oci8/session.c +0 -99
  74. data/ext/oci8/svcctx.c +0 -238
  75. data/ruby-oci8.spec +0 -62
  76. data/support/README +0 -4
  77. data/support/runit/assert.rb +0 -281
  78. data/support/runit/cui/testrunner.rb +0 -101
  79. data/support/runit/error.rb +0 -4
  80. data/support/runit/method_mappable.rb +0 -20
  81. data/support/runit/robserver.rb +0 -25
  82. data/support/runit/setuppable.rb +0 -15
  83. data/support/runit/teardownable.rb +0 -16
  84. data/support/runit/testcase.rb +0 -113
  85. data/support/runit/testfailure.rb +0 -25
  86. data/support/runit/testresult.rb +0 -121
  87. data/support/runit/testsuite.rb +0 -43
  88. data/support/runit/version.rb +0 -3
  89. data/test/test_describe.rb +0 -137
@@ -1,4 +0,0 @@
1
- module RUNIT
2
- class AssertionFailedError < StandardError
3
- end
4
- end
@@ -1,20 +0,0 @@
1
- module RUNIT
2
- module MethodMappable
3
- def attach_method(hash, method, *methods)
4
- methods.each do |m|
5
- hash[self.to_s + m.to_s] = method
6
- end
7
- end
8
- private :attach_method
9
-
10
- def invoke_method(hash, m)
11
- if hash[self.to_s + m.to_s]
12
- send hash[self.to_s + m.to_s]
13
- elsif hash[self.class.to_s + m.to_s]
14
- send hash[self.class.to_s + m.to_s]
15
- end
16
- end
17
- private :invoke_method
18
- end
19
- end
20
-
@@ -1,25 +0,0 @@
1
- module RUNIT
2
- module RObserver
3
- ADD_ERROR = :add_error
4
- ADD_FAILURE = :add_failure
5
- START_TEST = :start_test
6
- END_TEST = :end_test
7
-
8
- def add_error(*arg)
9
- end
10
-
11
- def add_failure(*arg)
12
- end
13
-
14
- def start_test(*arg)
15
- end
16
-
17
- def end_test(*arg)
18
- end
19
-
20
- def update(ev, *arg)
21
- send(ev, *arg)
22
- end
23
-
24
- end
25
- end
@@ -1,15 +0,0 @@
1
- require 'runit/method_mappable'
2
- module RUNIT
3
- module Setuppable
4
- include MethodMappable
5
- @@setups = {}
6
- def attach_setup(setup_method, *methods)
7
- attach_method(@@setups, setup_method, *methods)
8
- end
9
- private :attach_setup
10
- def invoke_setup(m)
11
- invoke_method(@@setups, m)
12
- end
13
- private :invoke_setup
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- require 'runit/method_mappable'
2
- module RUNIT
3
- module Teardownable
4
- include MethodMappable
5
- @@teardowns = {}
6
- def attach_teardown(teardown_method, *methods)
7
- attach_method(@@teardowns, teardown_method, *methods)
8
- end
9
- private :attach_teardown
10
- def invoke_teardown(m)
11
- invoke_method(@@teardowns, m)
12
- end
13
- private :invoke_teardown
14
- end
15
- end
16
-
@@ -1,113 +0,0 @@
1
- require 'observer'
2
- require 'runit/testsuite'
3
- require 'runit/robserver'
4
- require 'runit/error'
5
- require 'runit/assert'
6
- require 'runit/setuppable'
7
- require 'runit/teardownable'
8
-
9
- module RUNIT
10
- class TestCase
11
- alias_method :extend_test, :extend
12
-
13
- include Assert
14
- include Observable
15
-
16
- include Setuppable
17
- extend Setuppable
18
- include Teardownable
19
- extend Teardownable
20
-
21
- @@test_classes = []
22
-
23
- def initialize(method, name=self.class.name)
24
- @method = method
25
- @name = name
26
- end
27
-
28
- def setup
29
- end
30
- private :setup
31
-
32
- def teardown
33
- end
34
- private :teardown
35
-
36
- def name
37
- @name + "#" + @method
38
- end
39
-
40
- def method_name
41
- @method
42
- end
43
-
44
- def count_test_cases
45
- 1
46
- end
47
-
48
- def run(result)
49
- result.start_test(self)
50
- begin
51
- run_bare
52
- rescue AssertionFailedError
53
- result.add_failure($@, $!, self.class)
54
- rescue StandardError, ScriptError
55
- result.add_error($@, $!, self.class)
56
- end
57
- result.end_test(self)
58
- end
59
-
60
- def run_bare
61
- setup
62
- invoke_setup(@method)
63
- begin
64
- send(@method)
65
- ensure
66
- begin
67
- invoke_teardown(@method)
68
- teardown
69
- rescue
70
- changed
71
- notify_observers(RObserver::ADD_ERROR, $@, $!, self.class)
72
- end
73
- end
74
- end
75
-
76
- def ==(other)
77
- other.class == self.class && other.method_name && self.method_name
78
- end
79
-
80
- def TestCase.suite
81
- TestSuite.new(self_test_cases)
82
- end
83
-
84
- def TestCase.inherited(sub)
85
- @@test_classes.push sub
86
- end
87
-
88
- def TestCase.self_test_cases
89
- instance_methods(true).sort.collect {|m|
90
- new(m, name) if /^test/ =~ m
91
- }.compact
92
- end
93
-
94
- def TestCase.test_cases
95
- if self == TestCase
96
- TestSuite.new(*@@test_classes)
97
- else
98
- suite
99
- end
100
- end
101
-
102
-
103
- class<<TestCase
104
- alias test_methods test_cases
105
- alias all_suite test_cases
106
- private :self_test_cases
107
- end
108
-
109
- def TestCase.test_classes
110
- @@test_classes
111
- end
112
- end
113
- end
@@ -1,25 +0,0 @@
1
- module RUNIT
2
- SKIP_FILES = $:.collect{|path| /#{path}\/runit\//}.push /\/rubyunit\.rb:/
3
-
4
- class TestFailure
5
- attr_reader :at, :err
6
- def initialize(at, err, testclass)
7
- skip_trace = at.reject{|i|
8
- SKIP_FILES.find {|pat|
9
- pat =~ i
10
- }
11
- }
12
- @at = insert_class_name(skip_trace, testclass)
13
- @err = err
14
- end
15
- def to_s
16
- "#{@at[0]} #{@err}(#{@err.type})"
17
- end
18
- def insert_class_name(last_exception_backtrace, testclass)
19
- tns = testclass.inspect.split("::")
20
- last_exception_backtrace[0] += "(" + tns[tns.length-1] + ")"
21
- last_exception_backtrace
22
- end
23
- private :insert_class_name
24
- end
25
- end
@@ -1,121 +0,0 @@
1
- require 'observer'
2
- require 'runit/error'
3
- require 'runit/robserver'
4
- require 'runit/testfailure'
5
-
6
- module RUNIT
7
- class TestResultItem
8
- attr_reader :name
9
- attr_reader :failures
10
- attr_reader :errors
11
- attr_accessor :run_asserts
12
-
13
- def initialize(name)
14
- @failures = []
15
- @errors = []
16
- @name = name
17
- @run_asserts = 0
18
- end
19
-
20
- def add_failure(failure)
21
- @failures.push failure
22
- end
23
-
24
- def add_error(error)
25
- @errors.push error
26
- end
27
- end
28
-
29
- class TestResult
30
- include Observable
31
- include RObserver
32
-
33
- def initialize
34
- @result = nil
35
- @results = []
36
- @test_start_time = nil
37
- @test_end_time = nil
38
- @start_assert_size = 0
39
- end
40
-
41
- def items
42
- @results
43
- end
44
-
45
- def run_tests
46
- @results.size
47
- end
48
-
49
- def add_failure(at, err, testclass)
50
- fail = TestFailure.new(at, err, testclass)
51
- @result.add_failure(fail)
52
- changed
53
- notify_observers(RObserver::ADD_FAILURE, at, err)
54
- end
55
-
56
- def add_error(at, err, testclass)
57
- error = TestFailure.new(at, err, testclass)
58
- @result.add_error(error)
59
- changed
60
- notify_observers(RObserver::ADD_ERROR, at, err)
61
- end
62
-
63
- def assert_size
64
- size = 0
65
- @results.each do |i|
66
- size += i.run_asserts
67
- end
68
- size
69
- end
70
- alias run_asserts assert_size
71
-
72
- def failure_size
73
- failures.size
74
- end
75
-
76
- def error_size
77
- errors.size
78
- end
79
-
80
- def failures
81
- @results.collect{|r|
82
- r.failures
83
- }.flatten
84
- end
85
-
86
- def errors
87
- @results.collect{|r|
88
- r.errors
89
- }.flatten
90
- end
91
-
92
- def succeed?
93
- failure_size == 0 && error_size == 0
94
- end
95
-
96
- def running_time
97
- if @test_end_time && @test_start_time
98
- @test_end_time - @test_start_time
99
- else
100
- 0
101
- end
102
- end
103
-
104
- def start_test(testcase)
105
- testcase.add_observer(self)
106
- @result = TestResultItem.new(testcase.name)
107
- @results.push @result
108
- @start_assert_size = Assert.run_asserts
109
- @test_start_time = Time.now if !@test_start_time
110
- changed
111
- notify_observers(RObserver::START_TEST, testcase)
112
- end
113
-
114
- def end_test(testcase)
115
- changed
116
- notify_observers(RObserver::END_TEST, testcase)
117
- @test_end_time = Time.now
118
- @result.run_asserts = Assert.run_asserts - @start_assert_size
119
- end
120
- end
121
- end
@@ -1,43 +0,0 @@
1
- module RUNIT
2
- class TestSuite < Array
3
-
4
- def initialize(*test_classes)
5
- test_classes.each do |k|
6
- if k.kind_of?(Array)
7
- concat k
8
- else
9
- concat k.suite
10
- end
11
- end
12
- end
13
-
14
- def run(result)
15
- each do |t|
16
- t.run(result)
17
- end
18
- end
19
-
20
- def count_test_cases
21
- sum = 0
22
- each do |test|
23
- sum += test.count_test_cases
24
- end
25
- sum
26
- end
27
-
28
- def add(test)
29
- if test.kind_of?(Array)
30
- concat test
31
- else
32
- push test
33
- end
34
- end
35
- alias add_test add
36
-
37
- def extend_test(*mod)
38
- each do |t|
39
- t.extend_test(*mod)
40
- end
41
- end
42
- end
43
- end
@@ -1,3 +0,0 @@
1
- module RUNIT
2
- VERSION = '0.5.2'
3
- end
@@ -1,137 +0,0 @@
1
- # Low-level API
2
- require 'oci8'
3
- require 'runit/testcase'
4
- require 'runit/cui/testrunner'
5
- require File.dirname(__FILE__) + '/config'
6
-
7
- class TestDescribe < RUNIT::TestCase
8
-
9
- def setup
10
- # initialize oracle as object mode.
11
- # This is workaround to use OCIDescribeAny in Oracle 8.0.5 on Linux.
12
- # This bug was fixed in 8.0.6 and 8i.
13
- @env, @svc, @stmt = setup_lowapi()
14
- @desc = @env.alloc(OCIDescribe)
15
- end
16
-
17
- def test_describe_sequence
18
- begin
19
- @stmt.prepare("DROP SEQUENCE test_sequence").execute(@svc)
20
- rescue OCIError
21
- raise if $!.code != 2289 # sequence does not exist
22
- end
23
- minvalue = 1
24
- maxvalue = 1234567890123456789012345678 # bignum
25
- incr = 777
26
- sql = <<-EOS
27
- CREATE SEQUENCE test_sequence
28
- MINVALUE #{minvalue}
29
- MAXVALUE #{maxvalue}
30
- INCREMENT BY #{incr}
31
- ORDER
32
- EOS
33
- @stmt.prepare(sql).execute(@svc)
34
- @desc.describeAny(@svc, "test_sequence", OCI_PTYPE_SEQ)
35
- parm = @desc.attrGet(OCI_ATTR_PARAM)
36
- # common part
37
- assert_equal(OCI_PTYPE_SEQ, parm.attrGet(OCI_ATTR_PTYPE))
38
- # specific part
39
- assert_instance_of(Fixnum, parm.attrGet(OCI_ATTR_OBJID))
40
- assert_equal(minvalue, parm.attrGet(OCI_ATTR_MIN))
41
- assert_equal(maxvalue, parm.attrGet(OCI_ATTR_MAX))
42
- assert_equal(incr, parm.attrGet(OCI_ATTR_INCR))
43
- assert_kind_of(Integer, parm.attrGet(OCI_ATTR_CACHE))
44
- assert_equal(true, parm.attrGet(OCI_ATTR_ORDER))
45
- assert_kind_of(Integer, parm.attrGet(OCI_ATTR_HW_MARK))
46
- @stmt.prepare("DROP SEQUENCE test_sequence").execute(@svc)
47
- end
48
-
49
- def test_describe_synonym
50
- begin
51
- @stmt.prepare("DROP SYNONYM test_synonym").execute(@svc)
52
- rescue OCIError
53
- raise if $!.code != 1434 # private synonym to be dropped does not exist
54
- end
55
- @stmt.prepare("CREATE SYNONYM test_synonym FOR foo.bar@baz").execute(@svc)
56
- @desc.describeAny(@svc, "test_synonym", OCI_PTYPE_SYN)
57
- parm = @desc.attrGet(OCI_ATTR_PARAM)
58
- # common part
59
- assert_equal(OCI_PTYPE_SYN, parm.attrGet(OCI_ATTR_PTYPE))
60
- # specific part
61
- assert_instance_of(Fixnum, parm.attrGet(OCI_ATTR_OBJID))
62
- assert_equal("FOO", parm.attrGet(OCI_ATTR_SCHEMA_NAME))
63
- assert_equal("BAR", parm.attrGet(OCI_ATTR_NAME))
64
- assert_equal("BAZ", parm.attrGet(OCI_ATTR_LINK))
65
- @stmt.prepare("DROP SYNONYM test_synonym").execute(@svc)
66
- end
67
-
68
- def test_describe_table_and_columns
69
- drop_table('test_table')
70
- sql = <<-EOS
71
- CREATE TABLE test_table
72
- (C CHAR(10) NOT NULL,
73
- V VARCHAR2(20),
74
- N NUMBER(10, 2),
75
- D DATE)
76
- STORAGE (
77
- INITIAL 4k
78
- NEXT 4k
79
- MINEXTENTS 1
80
- MAXEXTENTS UNLIMITED
81
- PCTINCREASE 0)
82
- EOS
83
- @stmt.prepare(sql).execute(@svc)
84
- @desc.describeAny(@svc, "test_table", OCI_PTYPE_TABLE)
85
- tab_parm = @desc.attrGet(OCI_ATTR_PARAM)
86
- col_list = tab_parm.attrGet(OCI_ATTR_LIST_COLUMNS)
87
- num_cols = tab_parm.attrGet(OCI_ATTR_NUM_COLS)
88
- # common part for table
89
- assert_equal(OCI_PTYPE_TABLE, tab_parm.attrGet(OCI_ATTR_PTYPE))
90
- # specific part for table
91
- assert_instance_of(Fixnum, tab_parm.attrGet(OCI_ATTR_OBJID))
92
- assert_equal(4, num_cols)
93
- # common part for column list
94
- assert_equal(OCI_PTYPE_LIST, col_list.attrGet(OCI_ATTR_PTYPE))
95
-
96
- col = Array.new(num_cols)
97
- 1.upto(num_cols) do |i|
98
- col[i] = col_list.paramGet(i)
99
- assert_equal(OCI_PTYPE_COL, col[1].attrGet(OCI_ATTR_PTYPE))
100
- end
101
- assert_equal(10, col[1].attrGet(OCI_ATTR_DATA_SIZE))
102
- assert_equal(20, col[2].attrGet(OCI_ATTR_DATA_SIZE))
103
- assert_equal(22, col[3].attrGet(OCI_ATTR_DATA_SIZE))
104
- assert_equal(7, col[4].attrGet(OCI_ATTR_DATA_SIZE))
105
- assert_equal(OCI_TYPECODE_CHAR, col[1].attrGet(OCI_ATTR_DATA_TYPE))
106
- assert_equal(OCI_TYPECODE_VARCHAR, col[2].attrGet(OCI_ATTR_DATA_TYPE))
107
- assert_equal(OCI_TYPECODE_NUMBER, col[3].attrGet(OCI_ATTR_DATA_TYPE))
108
- assert_equal(OCI_TYPECODE_DATE, col[4].attrGet(OCI_ATTR_DATA_TYPE))
109
- assert_equal("C", col[1].attrGet(OCI_ATTR_NAME))
110
- assert_equal("V", col[2].attrGet(OCI_ATTR_NAME))
111
- assert_equal("N", col[3].attrGet(OCI_ATTR_NAME))
112
- assert_equal("D", col[4].attrGet(OCI_ATTR_NAME))
113
- assert_equal(0, col[1].attrGet(OCI_ATTR_PRECISION))
114
- assert_equal(0, col[2].attrGet(OCI_ATTR_PRECISION))
115
- assert_equal(10, col[3].attrGet(OCI_ATTR_PRECISION))
116
- assert_equal(0, col[4].attrGet(OCI_ATTR_PRECISION))
117
- assert_equal(0, col[1].attrGet(OCI_ATTR_SCALE))
118
- assert_equal(0, col[2].attrGet(OCI_ATTR_SCALE))
119
- assert_equal(2, col[3].attrGet(OCI_ATTR_SCALE))
120
- assert_equal(0, col[4].attrGet(OCI_ATTR_SCALE))
121
- assert_equal(false, col[1].attrGet(OCI_ATTR_IS_NULL))
122
- assert_equal(true, col[2].attrGet(OCI_ATTR_IS_NULL))
123
- assert_equal(true, col[3].attrGet(OCI_ATTR_IS_NULL))
124
- assert_equal(true, col[4].attrGet(OCI_ATTR_IS_NULL))
125
- drop_table('test_table')
126
- end
127
-
128
- def teardown
129
- @stmt.free()
130
- @svc.logoff()
131
- @env.free()
132
- end
133
- end
134
-
135
- if $0 == __FILE__
136
- RUNIT::CUI::TestRunner.run(TestDescribe.suite())
137
- end