ruby-oci8 1.0.5 → 1.0.6
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.
- data/ChangeLog +23 -0
- data/NEWS +14 -0
- data/VERSION +1 -1
- data/ext/oci8/extconf.rb +2 -0
- data/ext/oci8/oci8.h +4 -0
- data/ext/oci8/oraconf.rb +64 -63
- data/lib/dbd/OCI8.rb +27 -11
- data/ruby-oci8.spec +1 -1
- data/test/test_all.rb +7 -3
- metadata +3 -3
data/ChangeLog
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
2009-05-17 KUBO Takehiro <kubo@jiubao.org>
|
2
|
+
* NEWS: add changes between 1.0.5 and 1.0.6.
|
3
|
+
* VERSION: change version to 1.0.6.
|
4
|
+
|
5
|
+
2009-04-14 KUBO Takehiro <kubo@jiubao.org>
|
6
|
+
* ext/oci8/oraconf.rb: Gets ORACLE_HOME from the Windows regitry
|
7
|
+
by enumerating subkeys of \\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE.
|
8
|
+
|
9
|
+
2009-04-12 KUBO Takehiro <kubo@jiubao.org>
|
10
|
+
* lib/dbd/OCI8.rb: A data dictionary all_constraints doesn't have
|
11
|
+
index_name column on Oracle 8i or lower. Rewrite
|
12
|
+
DBI::DBD::OCI8::Database#column by using all_cons_columns.
|
13
|
+
(backport from ruby-oci8 trunk)
|
14
|
+
|
15
|
+
2009-04-12 KUBO Takehiro <kubo@jiubao.org>
|
16
|
+
* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oraconf.rb:
|
17
|
+
fix a problem when compiling for Oracle 8.0.
|
18
|
+
(reported by Axel Reinhold as a ruby-oci8 2.0 issue)
|
19
|
+
* lib/dbd/OCI8.rb: fix DBI::DBD::OCI8::BindType::DBIStatementHandle
|
20
|
+
to pass a newly added sanity check in dbi 0.4.1.
|
21
|
+
(reported by Dirk Herzhauser as a ruby-oci8 2.0 issue)
|
22
|
+
* test/test_all.rb: fix to use dbi installed as a rubygem.
|
23
|
+
|
1
24
|
2009-03-17 KUBO Takehiro <kubo@jiubao.org>
|
2
25
|
* NEWS: add changes between 1.0.4 and 1.0.5.
|
3
26
|
* VERSION: change version to 1.0.5.
|
data/NEWS
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
1.0.6:
|
2
|
+
|
3
|
+
* fix a problem when compiling for Oracle 8.0.
|
4
|
+
(reported by Axel Reinhold as a ruby-oci8 2.0 issue)
|
5
|
+
|
6
|
+
* [dbi] fix to pass a newly added sanity check in dbi 0.4.1.
|
7
|
+
(reported by Dirk Herzhauser as a ruby-oci8 2.0 issue)
|
8
|
+
|
9
|
+
* [dbi] fix dbh#columns for Oracle 8.1 or lower.
|
10
|
+
The data dictionary all_constraints doesn't have index_name
|
11
|
+
column on Oracle 8i. Rewrite DBI::DBD::OCI8::Database#columns
|
12
|
+
by using all_cons_columns.
|
13
|
+
(backport from ruby-oci8 trunk)
|
14
|
+
|
1
15
|
1.0.5:
|
2
16
|
|
3
17
|
No changes except who try to install on Mac OS X ppc.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
data/ext/oci8/extconf.rb
CHANGED
data/ext/oci8/oci8.h
CHANGED
@@ -52,6 +52,10 @@ extern "C" {
|
|
52
52
|
#define RARRAY_LEN(obj) RARRAY(obj)->len
|
53
53
|
#endif
|
54
54
|
|
55
|
+
#ifndef HAVE_TYPE_ORATEXT
|
56
|
+
typedef unsigned char oratext;
|
57
|
+
#endif
|
58
|
+
|
55
59
|
#define IS_OCI_ERROR(v) (((v) != OCI_SUCCESS) && ((v) != OCI_SUCCESS_WITH_INFO))
|
56
60
|
|
57
61
|
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
data/ext/oci8/oraconf.rb
CHANGED
@@ -48,48 +48,69 @@ module MiniRegistry
|
|
48
48
|
# copy the minimum code and reorganize it.
|
49
49
|
ERROR_SUCCESS = 0
|
50
50
|
ERROR_FILE_NOT_FOUND = 2
|
51
|
+
ERROR_NO_MORE_ITEMS = 259
|
51
52
|
|
52
53
|
HKEY_LOCAL_MACHINE = 0x80000002
|
54
|
+
KEY_ENUMERATE_SUB_KEYS = 0x0008
|
55
|
+
KEY_QUERY_VALUE = 0x0001
|
53
56
|
RegOpenKeyExA = Win32API.new('advapi32', 'RegOpenKeyExA', 'LPLLP', 'L')
|
57
|
+
RegEnumKeyExA = Win32API.new('advapi32', 'RegEnumKeyExA', 'LLPPPPPP', 'L')
|
54
58
|
RegQueryValueExA = Win32API.new('advapi32','RegQueryValueExA','LPPPPP','L')
|
55
59
|
RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L')
|
56
60
|
|
57
|
-
def
|
58
|
-
|
59
|
-
code =
|
61
|
+
def self.get_str_value(hKey, name)
|
62
|
+
lpcbData = [0].pack('L')
|
63
|
+
code = RegQueryValueExA.call(hKey, name, nil, nil, nil, lpcbData)
|
64
|
+
if code == ERROR_FILE_NOT_FOUND
|
65
|
+
return nil
|
66
|
+
elsif code != ERROR_SUCCESS
|
67
|
+
raise MiniRegistryError.new("Win32::RegQueryValueExA",code)
|
68
|
+
end
|
69
|
+
len = lpcbData.unpack('L')[0]
|
70
|
+
lpType = [0].pack('L')
|
71
|
+
lpData = "\0"*len
|
72
|
+
lpcbData = [len].pack('L')
|
73
|
+
code = RegQueryValueExA.call(hKey, name, nil, lpType, lpData, lpcbData)
|
74
|
+
if code != ERROR_SUCCESS
|
75
|
+
raise MiniRegistryError.new("Win32::RegQueryValueExA",code)
|
76
|
+
end
|
77
|
+
lpData.unpack('Z*')[0]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.enum_homes
|
81
|
+
phkResult = [0].pack('L')
|
82
|
+
code = RegOpenKeyExA.call(HKEY_LOCAL_MACHINE, 'SOFTWARE\ORACLE', 0, 0x20019, phkResult)
|
60
83
|
if code != ERROR_SUCCESS
|
61
84
|
raise MiniRegistryError.new("Win32::RegOpenKeyExA", code)
|
62
85
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
86
|
+
hKey = phkResult.unpack('L')[0]
|
87
|
+
idx = 0
|
88
|
+
maxkeylen = 256
|
89
|
+
loop do
|
90
|
+
lpName = "\0" * maxkeylen
|
91
|
+
lpcName = [maxkeylen].pack('L')
|
92
|
+
code = RegEnumKeyExA.call(hKey, idx, lpName, lpcName, nil, nil, nil, nil);
|
93
|
+
break if code == ERROR_NO_MORE_ITEMS
|
94
|
+
if code != ERROR_SUCCESS
|
95
|
+
RegCloseKey.call(hKey)
|
96
|
+
raise MiniRegistryError.new("Win32::RegEnumKeyEx", code)
|
71
97
|
end
|
72
|
-
|
73
|
-
lpType = "\0\0\0\0"
|
74
|
-
lpData = "\0"*len
|
75
|
-
lpcbData = [len].pack('L')
|
76
|
-
code = RegQueryValueExA.call(hkey, name, nil, lpType, lpData, lpcbData)
|
98
|
+
code = RegOpenKeyExA.call(hKey, lpName, 0, KEY_QUERY_VALUE, phkResult)
|
77
99
|
if code != ERROR_SUCCESS
|
78
|
-
|
100
|
+
RegCloseKey.call(hKey)
|
101
|
+
raise MiniRegistryError.new("Win32::RegEnumKeyEx", code)
|
79
102
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
103
|
+
hSubkey = phkResult.unpack('L')[0]
|
104
|
+
|
105
|
+
name = get_str_value(hSubkey, 'ORACLE_HOME_NAME')
|
106
|
+
path = get_str_value(hSubkey, 'ORACLE_HOME')
|
107
|
+
yield name, path
|
108
|
+
RegCloseKey.call(hSubkey)
|
109
|
+
idx += 1
|
83
110
|
end
|
111
|
+
RegCloseKey.call(hKey)
|
84
112
|
end
|
85
|
-
|
86
|
-
get_reg_value(HKEY_LOCAL_MACHINE, subkey, name)
|
87
|
-
end
|
88
|
-
else
|
89
|
-
# UNIX
|
90
|
-
def get_local_registry(subkey, name)
|
91
|
-
nil
|
92
|
-
end
|
113
|
+
|
93
114
|
end
|
94
115
|
end # module MiniRegistry
|
95
116
|
|
@@ -293,8 +314,6 @@ class MiniSOReader
|
|
293
314
|
end
|
294
315
|
|
295
316
|
class OraConf
|
296
|
-
include MiniRegistry
|
297
|
-
|
298
317
|
attr_reader :cc_is_gcc
|
299
318
|
attr_reader :version
|
300
319
|
attr_reader :cflags
|
@@ -717,6 +736,7 @@ class OraConfFC < OraConf
|
|
717
736
|
sqlplus = "sqlplus"
|
718
737
|
end
|
719
738
|
Logging::open do
|
739
|
+
ENV['NLS_LANG'] = 'american_america.us7ascii'
|
720
740
|
open("|#{@oracle_home}/bin/#{sqlplus} < #{dev_null}") do |f|
|
721
741
|
while line = f.gets
|
722
742
|
print line
|
@@ -755,26 +775,10 @@ class OraConfFC < OraConf
|
|
755
775
|
if oracle_home.nil?
|
756
776
|
struct = Struct.new("OracleHome", :name, :path)
|
757
777
|
oracle_homes = []
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
oracle_homes << "HOME#{id}"
|
762
|
-
end
|
763
|
-
rescue MiniRegistryError
|
764
|
-
end
|
765
|
-
oracle_homes << "KEY_XE"
|
766
|
-
oracle_homes << "KEY_XEClient"
|
767
|
-
oracle_homes.collect! do |home|
|
768
|
-
begin
|
769
|
-
name = get_local_registry("SOFTWARE\\ORACLE\\#{home}", 'ORACLE_HOME_NAME')
|
770
|
-
path = get_local_registry("SOFTWARE\\ORACLE\\#{home}", 'ORACLE_HOME')
|
771
|
-
path.chomp!("\\")
|
772
|
-
struct.new(name, path) if is_valid_home?(path)
|
773
|
-
rescue MiniRegistryError
|
774
|
-
nil
|
775
|
-
end
|
778
|
+
MiniRegistry.enum_homes do |name, path|
|
779
|
+
path.chomp!("\\") if path
|
780
|
+
oracle_homes << struct.new(name, path) if is_valid_home?(path)
|
776
781
|
end
|
777
|
-
oracle_homes.compact!
|
778
782
|
if oracle_homes.empty?
|
779
783
|
raise <<EOS
|
780
784
|
Set the environment variable ORACLE_HOME if Oracle Full Client.
|
@@ -944,21 +948,18 @@ EOS
|
|
944
948
|
end
|
945
949
|
end
|
946
950
|
|
947
|
-
#
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
command = Config::CONFIG["AR"] + " cru oracle_objs.a " + objs.join(" ")
|
958
|
-
puts command
|
959
|
-
system(command)
|
960
|
-
libs = "oracle_objs.a " + libs
|
951
|
+
# check whether object files are included.
|
952
|
+
if /\S+\.o\b/ =~ libs
|
953
|
+
|
954
|
+
# monkey patching!
|
955
|
+
Object.module_eval do
|
956
|
+
alias :orig_link_command :link_command
|
957
|
+
def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
|
958
|
+
opt = "" if opt == $libs
|
959
|
+
orig_link_command(ldflags, opt, libpath)
|
960
|
+
end
|
961
961
|
end
|
962
|
+
|
962
963
|
end
|
963
964
|
libs
|
964
965
|
end # get_libs
|
data/lib/dbd/OCI8.rb
CHANGED
@@ -245,19 +245,21 @@ class Database < DBI::BaseDatabase
|
|
245
245
|
|
246
246
|
dbh = DBI::DatabaseHandle.new(self)
|
247
247
|
|
248
|
-
|
248
|
+
primaries = {}
|
249
249
|
dbh.select_all(<<EOS, tab.obj_schema, tab.obj_name) do |row|
|
250
|
-
select
|
251
|
-
from all_constraints
|
252
|
-
where
|
253
|
-
and
|
254
|
-
and table_name =
|
250
|
+
select column_name
|
251
|
+
from all_cons_columns a, all_constraints b
|
252
|
+
where a.owner = b.owner
|
253
|
+
and a.constraint_name = b.constraint_name
|
254
|
+
and a.table_name = b.table_name
|
255
|
+
and b.constraint_type = 'P'
|
256
|
+
and b.owner = :1
|
257
|
+
and b.table_name = :2
|
255
258
|
EOS
|
256
|
-
|
259
|
+
primaries[row[0]] = true
|
257
260
|
end
|
258
261
|
|
259
262
|
indices = {}
|
260
|
-
primaries = {}
|
261
263
|
uniques = {}
|
262
264
|
dbh.select_all(<<EOS, tab.obj_schema, tab.obj_name) do |row|
|
263
265
|
select a.column_name, a.index_name, b.uniqueness
|
@@ -269,7 +271,6 @@ select a.column_name, a.index_name, b.uniqueness
|
|
269
271
|
EOS
|
270
272
|
col_name, index_name, uniqueness = row
|
271
273
|
indices[col_name] = true
|
272
|
-
primaries[col_name] = true if index_name == pk_index_name
|
273
274
|
uniques[col_name] = true if uniqueness == 'UNIQUE'
|
274
275
|
end
|
275
276
|
|
@@ -401,6 +402,21 @@ class Statement < DBI::BaseStatement
|
|
401
402
|
end
|
402
403
|
end
|
403
404
|
|
405
|
+
# DBI_STMT_NEW_ARGS is DBI::StatementHandle.new's arguments except +handle+.
|
406
|
+
#
|
407
|
+
# FYI: DBI::StatementHandle.new method signatures are follows:
|
408
|
+
# 0.2.2: handle, fetchable=false, prepared=true
|
409
|
+
# 0.4.0: handle, fetchable=false, prepared=true, convert_types=true
|
410
|
+
# 0.4.1: handle, fetchable=false, prepared=true, convert_types=true, executed=false
|
411
|
+
begin
|
412
|
+
DBI::StatementHandle.new(nil, false, true, true, true)
|
413
|
+
# dbi 0.4.1
|
414
|
+
DBI_STMT_NEW_ARGS = [true, true, true, true] # :nodoc:
|
415
|
+
rescue ArgumentError
|
416
|
+
# dbi 0.4.0 or lower
|
417
|
+
DBI_STMT_NEW_ARGS = [true] # :nodoc:
|
418
|
+
end
|
419
|
+
|
404
420
|
if defined? ::OCI8::BindType::Base
|
405
421
|
##
|
406
422
|
## ruby-oci8 2.0 bind classes.
|
@@ -490,7 +506,7 @@ if defined? ::OCI8::BindType::Base
|
|
490
506
|
val = super
|
491
507
|
return nil if val.nil?
|
492
508
|
stmt = DBI::DBD::OCI8::Statement.new(val)
|
493
|
-
DBI::StatementHandle.new(stmt,
|
509
|
+
DBI::StatementHandle.new(stmt, *DBI_STMT_NEW_ARGS)
|
494
510
|
end
|
495
511
|
end
|
496
512
|
end # BindType
|
@@ -559,7 +575,7 @@ else
|
|
559
575
|
return val if val.nil?
|
560
576
|
cur = ::OCI8::Cursor.new(@env, @svc, @ctx, val)
|
561
577
|
stmt = DBI::DBD::OCI8::Statement.new(cur)
|
562
|
-
DBI::StatementHandle.new(stmt,
|
578
|
+
DBI::StatementHandle.new(stmt, *DBI_STMT_NEW_ARGS)
|
563
579
|
end
|
564
580
|
end
|
565
581
|
end
|
data/ruby-oci8.spec
CHANGED
data/test/test_all.rb
CHANGED
@@ -23,11 +23,15 @@ require "#{srcdir}/test_rowid"
|
|
23
23
|
# Ruby/DBI
|
24
24
|
begin
|
25
25
|
require 'dbi'
|
26
|
-
is_dbi_loaded = true
|
27
26
|
rescue LoadError
|
28
|
-
|
27
|
+
begin
|
28
|
+
require 'rubygems'
|
29
|
+
require 'dbi'
|
30
|
+
rescue LoadError
|
31
|
+
dbi_not_found = false
|
32
|
+
end
|
29
33
|
end
|
30
|
-
|
34
|
+
unless dbi_not_found
|
31
35
|
require "#{srcdir}/test_dbi"
|
32
36
|
if $test_clob
|
33
37
|
require "#{srcdir}/test_dbi_clob"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-oci8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KUBO Takehiro
|
@@ -9,7 +9,7 @@ autorequire: oci8
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-17 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
requirements: []
|
119
119
|
|
120
120
|
rubyforge_project: ruby-oci8
|
121
|
-
rubygems_version: 1.
|
121
|
+
rubygems_version: 1.3.1
|
122
122
|
signing_key:
|
123
123
|
specification_version: 2
|
124
124
|
summary: Ruby interface for Oracle using OCI8 API
|