ruby-oci8 1.0.3-i386-mswin32 → 1.0.4-i386-mswin32

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 CHANGED
@@ -1,3 +1,60 @@
1
+ 2009-02-08 KUBO Takehiro <kubo@jiubao.org>
2
+ * NEWS: add changes between 1.0.3 and 1.0.4.
3
+ * VERSION: change version to 1.0.4.
4
+ * dist-files: add newly added file names which must be included
5
+ in gem or tar.gz packages.
6
+
7
+ 2009-02-01 KUBO Takehiro <kubo@jiubao.org>
8
+ * lib/dbd/OCI8.rb: add code for ruby-dbi 0.4 type conversion.
9
+ * test/test_dbi.rb: suppress deprecated warnings while running
10
+ test_bind_dbi_data_type.
11
+ * test/test_dbi_clob.rb: fix a problem when running this
12
+ file directly.
13
+
14
+ 2009-01-31 KUBO Takehiro <kubo@jiubao.org>
15
+ * ext/oci8/oraconf.rb: fix for Oracle 11.1.0.7.0 instant
16
+ client rpm package. The directory tree is a bit different
17
+ with that of 11.1.0.6.0 or earlier.
18
+ (reported by Luis Parravicini.)
19
+
20
+ 2009-01-31 KUBO Takehiro <kubo@jiubao.org>
21
+ * lib/DBD/OCI8/OCI8.rb: renamed to lib/dbd/OCI8.rb.
22
+ * lib/dbd/OCI8.rb: 1. renamed from lib/DBD/OCI8/OCI8.rb
23
+ 2. fix USED_DBD_VERSION from 0.2 to 0.4.
24
+ 3. add DBI::DBD::OCI8.driver_name
25
+ (changes for ruby-dbi 0.4 contributed by James Cao.)
26
+
27
+ 2008-12-30 KUBO Takehiro <kubo@jiubao.org>
28
+ * ext/oci8/handle.c, ext/oci8/oci8.h, ext/oci8/svcctx.c: add
29
+ OCISvcCtx.pid, which returns id of the process where the
30
+ OCISvcCtx is created.
31
+ * lib/oci8.rb.in: add check code to ensure that the process id
32
+ is not changed.
33
+
34
+ 2008-12-30 KUBO Takehiro <kubo@jiubao.org>
35
+ * ext/oci8/const.c, ext/oci8/handle.c: suppress compilation warnings.
36
+ (contributed by Daniel Berger)
37
+
38
+ 2008-12-30 KUBO Takehiro <kubo@jiubao.org>
39
+ * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X
40
+ libclntsh.dylib.
41
+
42
+ 2008-12-14 KUBO Takehiro <kubo@jiubao.org>
43
+ * lib/oci8.rb.in:
44
+ 1. fix to fetch a rowid column as s String.
45
+ 2. change the return type of OCI8::Cursor#rowid from OCIRowid
46
+ to String. It is a local call on Oracle 9.0 or upper.
47
+ But on Oracle 8.x client, it needs one network roundtrip
48
+ to convert OCIRowid to String on server side.
49
+ 3. fix OCI8#describe_table to prevent OCIStillExecuting when
50
+ non-blocking mode is enabled and it needs a time to
51
+ retrieve table information.
52
+ * ext/oci8/extconf.rb, ext/oci8/oci8.c: add OCIRowid#to_s
53
+ when OCIRowidToChar() is available.
54
+ * test/test_all.rb, test/test_rowid.rb: add a rowid test case.
55
+ * test/test_dbi_clob.rb: fix to pass tests when the test directory
56
+ path is too long.
57
+
1
58
  2008-08-10 KUBO Takehiro <kubo@jiubao.org>
2
59
  * NEWS: add changes between 1.0.2 and 1.0.3.
3
60
  * VERSION: change version to 1.0.3.
@@ -12,7 +69,7 @@
12
69
  2008-08-09 KUBO Takehiro <kubo@jiubao.org>
13
70
  * ext/oci8/lob.c: fix OCILobLocator#getLength for a lob over 1GB,
14
71
  which affect OCI8::LOB#size and OCI8::LOB#read. fix
15
- OCILobLocator#read and OCILobLocator#write to set offset over 2BG,
72
+ OCILobLocator#read and OCILobLocator#write to set offset over 2GB,
16
73
  which affect OCI8::LOB#read and OCI8::LOB#write.
17
74
  (This probmem was reported by Jonathan Hadders.)
18
75
 
data/NEWS CHANGED
@@ -1,3 +1,41 @@
1
+ 1.0.4:
2
+
3
+ 1. [dbi] support ruby-dbi 0.4
4
+ (Thanks to James Cao and Peter Zingg.)
5
+
6
+ Ruby-dbi 0.4 is supported by DBD::OCI8 after 6 months from the
7
+ release of 0.4.
8
+
9
+ If you are using ruby-dbi 0.1.1, you need to copy dbd/OCI8.rb
10
+ to DBD/OCI8/OCI8.rb. The file itself works fine with ruby-dbi
11
+ 0.1.1, but the dbi cannot find the file by default.
12
+
13
+ 2. Rowid column data are fetched as a String by default.
14
+
15
+ 3. The return type of OCI8::Cursor#rowid is changed from OCIRowid
16
+ to String.
17
+
18
+ Note: It needs one network roundtrip to convert OCIRowid to
19
+ String on server side when using Oracle 8.x client.
20
+ On Oracle 9.0 or upper it is converted in the client side.
21
+
22
+ 4. An exception is raised if a connection is used in a process which is
23
+ different with a process to establish the connection.
24
+
25
+ If you encounter an exception "The connection cannot be reused in the
26
+ forked process," see the following link.
27
+
28
+ http://groups.google.com/group/phusion-passenger/browse_thread/thread/b00d4770bc1d00b8
29
+
30
+ 5. fix for 11.1.0.7.0 instant rpm package.
31
+ (reported by Luis Parravicini.)
32
+
33
+ The directory tree is a bit different with that of 11.1.0.6.0
34
+ or earlier.
35
+
36
+ 6. suppress compilation warnings.
37
+ (contributed by Daniel Berger)
38
+
1
39
  1.0.3:
2
40
 
3
41
  1. add workaround code for a losing character problem when reading CLOB.
@@ -22,7 +60,7 @@
22
60
  OraNumber#to_json is added for Rails.
23
61
 
24
62
  4. [dbi] fix a problem when using Oracle 8i and ruby-dbi.
25
- (reported by Glauco MagnelliRemi Gagnon.)
63
+ (reported by Glauco Magnelli.)
26
64
 
27
65
  1.0.2:
28
66
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
data/dist-files CHANGED
@@ -39,7 +39,7 @@ ext/oci8/session.c
39
39
  ext/oci8/stmt.c
40
40
  ext/oci8/svcctx.c
41
41
  lib/oci8.rb.in
42
- lib/DBD/OCI8/OCI8.rb
42
+ lib/dbd/OCI8.rb
43
43
  support/README
44
44
  support/runit/assert.rb
45
45
  support/runit/cui/testrunner.rb
@@ -68,3 +68,4 @@ test/test_oci8.rb
68
68
  test/test_oradate.rb
69
69
  test/test_oranumber.rb
70
70
  test/test_metadata.rb
71
+ test/test_rowid.rb
Binary file
@@ -42,7 +42,32 @@ module DBD # :nodoc:
42
42
  module OCI8
43
43
 
44
44
  VERSION = "0.1"
45
- USED_DBD_VERSION = "0.2"
45
+ USED_DBD_VERSION = "0.4"
46
+
47
+ def self.driver_name
48
+ "OCI8"
49
+ end
50
+
51
+ # type converstion handler to bind values. (ruby-dbi 0.4)
52
+ if DBI.const_defined?(:TypeUtil)
53
+ DBI::TypeUtil.register_conversion("OCI8") do |obj|
54
+ case obj
55
+ when ::TrueClass
56
+ ['1', false]
57
+ when ::FalseClass
58
+ ['0', false]
59
+ else
60
+ [obj, false]
61
+ end
62
+ end
63
+ end
64
+
65
+ # no type converstion is required for result set. (ruby-dbi 0.4)
66
+ class NoTypeConversion
67
+ def self.parse(obj)
68
+ obj
69
+ end
70
+ end
46
71
 
47
72
  module Util
48
73
 
@@ -134,6 +159,7 @@ module Util
134
159
  'nullable' => col.nullable?,
135
160
  'precision' => precision,
136
161
  'scale' => scale,
162
+ 'dbi_type' => NoTypeConversion,
137
163
  }
138
164
  end
139
165
  private :column_metadata_to_column_info
@@ -55,7 +55,7 @@ class OCI8
55
55
  @@error_in_initialization = $!
56
56
  end
57
57
 
58
- VERSION = '1.0.3'
58
+ VERSION = '1.0.4'
59
59
  CLIENT_VERSION = '1020'
60
60
  # :stopdoc:
61
61
  RAW = OCI_TYPECODE_RAW
@@ -351,7 +351,7 @@ class OCI8
351
351
  def describe_table(table_name)
352
352
  desc = @@env.alloc(OCIDescribe)
353
353
  desc.attrSet(OCI_ATTR_DESC_PUBLIC, -1)
354
- desc.describeAny(@svc, table_name.to_s, OCI_PTYPE_UNK)
354
+ do_ocicall(@ctx) { desc.describeAny(@svc, table_name.to_s, OCI_PTYPE_UNK) }
355
355
  param = desc.attrGet(OCI_ATTR_PARAM)
356
356
 
357
357
  case param.attrGet(OCI_ATTR_PTYPE)
@@ -679,6 +679,9 @@ class OCI8
679
679
  end
680
680
 
681
681
  def initialize(env, svc, ctx, stmt = nil)
682
+ if Process.pid != svc.pid
683
+ raise "The connection cannot be reused in the forked process."
684
+ end
682
685
  @env = env
683
686
  @svc = svc
684
687
  @ctx = ctx
@@ -811,8 +814,25 @@ class OCI8
811
814
  @stmttype = nil
812
815
  end # close
813
816
 
817
+ # Get the rowid of the last inserted/updated/deleted row.
814
818
  def rowid
815
- @stmt.attrGet(OCI_ATTR_ROWID)
819
+ # get the binary rowid
820
+ rid = @stmt.attrGet(OCI_ATTR_ROWID)
821
+ # convert it to a string rowid.
822
+ if rid.respond_to? :to_s
823
+ # (Oracle 9.0 or upper)
824
+ rid.to_s
825
+ else
826
+ # (Oracle 8.1 or lower)
827
+ stmt = @env.alloc(OCIStmt)
828
+ stmt.prepare('begin :1 := :2; end;')
829
+ b = stmt.bindByPos(1, OCI8::SQLT_CHR, 64)
830
+ stmt.bindByPos(2, OCI8::SQLT_RDD, rid)
831
+ do_ocicall(@ctx) { stmt.execute(@svc, 1, OCI_DEFAULT) }
832
+ str_rid = b.get()
833
+ stmt.free()
834
+ str_rid
835
+ end
816
836
  end
817
837
 
818
838
  def prefetch_rows=(rows)
@@ -899,6 +919,8 @@ class OCI8
899
919
  datatype = :nclob if p.attrGet(OCI_ATTR_CHARSET_FORM) == SQLCS_NCHAR
900
920
  when SQLT_BIN
901
921
  datasize *= 2 if OCI8::BindType::Mapping[datatype] == OCI8::BindType::String
922
+ when SQLT_RDD
923
+ datasize = 64
902
924
  end
903
925
 
904
926
  bind_or_define(:define, i, nil, datatype, datasize, precision, scale, true)
@@ -1210,7 +1232,7 @@ class OCI8
1210
1232
  # datatype type size prec scale
1211
1233
  # -------------------------------------------------
1212
1234
  # ROWID SQLT_RDD 4 0 0
1213
- BindType::Mapping[OCI8::SQLT_RDD] = BindType::OCIRowid
1235
+ BindType::Mapping[OCI8::SQLT_RDD] = BindType::String
1214
1236
 
1215
1237
  # datatype type size prec scale
1216
1238
  # -----------------------------------------------------
@@ -351,7 +351,7 @@ class OCI8
351
351
  def describe_table(table_name)
352
352
  desc = @@env.alloc(OCIDescribe)
353
353
  desc.attrSet(OCI_ATTR_DESC_PUBLIC, -1)
354
- desc.describeAny(@svc, table_name.to_s, OCI_PTYPE_UNK)
354
+ do_ocicall(@ctx) { desc.describeAny(@svc, table_name.to_s, OCI_PTYPE_UNK) }
355
355
  param = desc.attrGet(OCI_ATTR_PARAM)
356
356
 
357
357
  case param.attrGet(OCI_ATTR_PTYPE)
@@ -679,6 +679,9 @@ class OCI8
679
679
  end
680
680
 
681
681
  def initialize(env, svc, ctx, stmt = nil)
682
+ if Process.pid != svc.pid
683
+ raise "The connection cannot be reused in the forked process."
684
+ end
682
685
  @env = env
683
686
  @svc = svc
684
687
  @ctx = ctx
@@ -811,8 +814,25 @@ class OCI8
811
814
  @stmttype = nil
812
815
  end # close
813
816
 
817
+ # Get the rowid of the last inserted/updated/deleted row.
814
818
  def rowid
815
- @stmt.attrGet(OCI_ATTR_ROWID)
819
+ # get the binary rowid
820
+ rid = @stmt.attrGet(OCI_ATTR_ROWID)
821
+ # convert it to a string rowid.
822
+ if rid.respond_to? :to_s
823
+ # (Oracle 9.0 or upper)
824
+ rid.to_s
825
+ else
826
+ # (Oracle 8.1 or lower)
827
+ stmt = @env.alloc(OCIStmt)
828
+ stmt.prepare('begin :1 := :2; end;')
829
+ b = stmt.bindByPos(1, OCI8::SQLT_CHR, 64)
830
+ stmt.bindByPos(2, OCI8::SQLT_RDD, rid)
831
+ do_ocicall(@ctx) { stmt.execute(@svc, 1, OCI_DEFAULT) }
832
+ str_rid = b.get()
833
+ stmt.free()
834
+ str_rid
835
+ end
816
836
  end
817
837
 
818
838
  def prefetch_rows=(rows)
@@ -899,6 +919,8 @@ class OCI8
899
919
  datatype = :nclob if p.attrGet(OCI_ATTR_CHARSET_FORM) == SQLCS_NCHAR
900
920
  when SQLT_BIN
901
921
  datasize *= 2 if OCI8::BindType::Mapping[datatype] == OCI8::BindType::String
922
+ when SQLT_RDD
923
+ datasize = 64
902
924
  end
903
925
 
904
926
  bind_or_define(:define, i, nil, datatype, datasize, precision, scale, true)
@@ -1210,7 +1232,7 @@ class OCI8
1210
1232
  # datatype type size prec scale
1211
1233
  # -------------------------------------------------
1212
1234
  # ROWID SQLT_RDD 4 0 0
1213
- BindType::Mapping[OCI8::SQLT_RDD] = BindType::OCIRowid
1235
+ BindType::Mapping[OCI8::SQLT_RDD] = BindType::String
1214
1236
 
1215
1237
  # datatype type size prec scale
1216
1238
  # -----------------------------------------------------
data/metaconfig CHANGED
@@ -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/OCI8.rb'] = <<-EOS
124
- #{get_zcontent('lib/DBD/OCI8/OCI8.rb')}EOS
123
+ install_files['dbd/OCI8.rb'] = <<-EOS
124
+ #{get_zcontent('lib/dbd/OCI8.rb')}EOS
125
125
 
126
126
  begin
127
127
  installer = Installer.new(install_files)
@@ -18,6 +18,7 @@ require "#{srcdir}/test_break"
18
18
  require "#{srcdir}/test_oci8"
19
19
  require "#{srcdir}/test_connstr"
20
20
  require "#{srcdir}/test_metadata"
21
+ require "#{srcdir}/test_rowid"
21
22
 
22
23
  # Ruby/DBI
23
24
  begin
@@ -146,17 +146,27 @@ EOS
146
146
  end
147
147
 
148
148
  def test_bind_dbi_data_type
149
- inval = DBI::Date.new(2004, 3, 20)
150
- sth = @dbh.execute("BEGIN ? := ?; END;", DBI::Date, inval)
151
- outval = sth.func(:bind_value, 1)
152
- assert_instance_of(DBI::Date, outval)
153
- assert_equal(inval.to_time, outval.to_time)
149
+ begin
150
+ if DBI::VERSION >= '0.4.0'
151
+ # suppress deprecated warnings while running this test.
152
+ saved_action = Deprecated.action
153
+ Deprecated.set_action(Proc.new {})
154
+ end
155
+
156
+ inval = DBI::Date.new(2004, 3, 20)
157
+ sth = @dbh.execute("BEGIN ? := ?; END;", DBI::Date, inval)
158
+ outval = sth.func(:bind_value, 1)
159
+ assert_instance_of(DBI::Date, outval)
160
+ assert_equal(inval.to_time, outval.to_time)
154
161
 
155
- inval = DBI::Timestamp.new(2004, 3, 20, 18, 26, 33)
156
- sth = @dbh.execute("BEGIN ? := ?; END;", DBI::Timestamp, inval)
157
- outval = sth.func(:bind_value, 1)
158
- assert_instance_of(DBI::Timestamp, outval)
159
- assert_equal(inval.to_time, outval.to_time)
162
+ inval = DBI::Timestamp.new(2004, 3, 20, 18, 26, 33)
163
+ sth = @dbh.execute("BEGIN ? := ?; END;", DBI::Timestamp, inval)
164
+ outval = sth.func(:bind_value, 1)
165
+ assert_instance_of(DBI::Timestamp, outval)
166
+ assert_equal(inval.to_time, outval.to_time)
167
+ ensure
168
+ Deprecated.set_action(saved_action) if saved_action
169
+ end
160
170
  end
161
171
 
162
172
  def test_column_info
@@ -11,13 +11,14 @@ class TestDbiCLob < RUNIT::TestCase
11
11
  end
12
12
 
13
13
  def test_insert
14
- @dbh.do("DELETE FROM test_clob WHERE filename = :1", $lobfile)
14
+ filename = File.basename($lobfile)
15
+ @dbh.do("DELETE FROM test_clob WHERE filename = :1", filename)
15
16
 
16
17
  # insert an empty clob and get the rowid.
17
- rowid = @dbh.execute("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", $lobfile) do |sth|
18
+ rowid = @dbh.execute("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", filename) do |sth|
18
19
  sth.func(:rowid)
19
20
  end
20
- lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", $lobfile)[0]
21
+ lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)[0]
21
22
  begin
22
23
  open($lobfile) do |f|
23
24
  while f.gets()
@@ -30,8 +31,9 @@ class TestDbiCLob < RUNIT::TestCase
30
31
  end
31
32
 
32
33
  def test_read
34
+ filename = File.basename($lobfile)
33
35
  test_insert() # first insert data.
34
- lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", $lobfile)[0]
36
+ lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)[0]
35
37
  begin
36
38
  open($lobfile) do |f|
37
39
  while buf = lob.read($lobreadnum)
@@ -52,5 +54,5 @@ class TestDbiCLob < RUNIT::TestCase
52
54
  end
53
55
 
54
56
  if $0 == __FILE__
55
- RUNIT::CUI::TestRunner.run(TestCLob.suite())
57
+ RUNIT::CUI::TestRunner.run(TestDbiCLob.suite())
56
58
  end
@@ -0,0 +1,38 @@
1
+ require 'oci8'
2
+ require 'runit/testcase'
3
+ require 'runit/cui/testrunner'
4
+ require File.dirname(__FILE__) + '/config'
5
+
6
+ class TestRowid < RUNIT::TestCase
7
+
8
+ def setup
9
+ @conn = get_oci_connection()
10
+ end
11
+
12
+ def teardown
13
+ @conn.logoff
14
+ end
15
+
16
+ def test_rowid
17
+ drop_table('test_table')
18
+ sql = <<-EOS
19
+ CREATE TABLE test_table (N NUMBER(38))
20
+ EOS
21
+ @conn.exec(sql)
22
+ cursor = @conn.parse("INSERT INTO test_table values(1)");
23
+ cursor.exec
24
+ rid1 = cursor.rowid
25
+ assert_instance_of(String, rid1)
26
+ cursor.close
27
+ rid2 = nil
28
+ @conn.exec('select rowid from test_table where rowid = :1', rid1) do |row|
29
+ rid2 = row[0]
30
+ end
31
+ assert_equal(rid2, rid1)
32
+ drop_table('test_table')
33
+ end
34
+ end # TestRowid
35
+
36
+ if $0 == __FILE__
37
+ RUNIT::CUI::TestRunner.run(TestRowid.suite())
38
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ruby-oci8
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.3
7
- date: 2008-08-10 00:00:00 +09:00
6
+ version: 1.0.4
7
+ date: 2009-02-08 00:00:00 +09:00
8
8
  summary: Ruby interface for Oracle using OCI8 API
9
9
  require_paths:
10
10
  - lib
@@ -47,7 +47,7 @@ files:
47
47
  - doc/api.ja.rd
48
48
  - doc/manual.css
49
49
  - lib/oci8.rb.in
50
- - lib/DBD/OCI8/OCI8.rb
50
+ - lib/dbd/OCI8.rb
51
51
  - support/README
52
52
  - support/runit/assert.rb
53
53
  - support/runit/cui/testrunner.rb
@@ -76,6 +76,7 @@ files:
76
76
  - test/test_oradate.rb
77
77
  - test/test_oranumber.rb
78
78
  - test/test_metadata.rb
79
+ - test/test_rowid.rb
79
80
  - ext/oci8/oci8lib.so
80
81
  - lib/oci8.rb
81
82
  test_files: