ruby-oci8 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,38 @@
1
+ 2008-08-10 KUBO Takehiro <kubo@jiubao.org>
2
+ * NEWS: add changes between 1.0.2 and 1.0.3.
3
+ * VERSION: change version to 1.0.3.
4
+ * ext/oci8/lob.c: add workaround code for a losing character problem
5
+ when reading CLOB. The problem is happened at the following condition.
6
+ 1. Oracle client version is 10.2.0.4 or 11.1.0.6.
7
+ (It doesn't depend on Oracle server version.)
8
+ 2. The character set is a variable-length one (e.g. AL32UTF8).
9
+ (This probmem was reported by Efren Yevale and Thomas Witt and
10
+ fixed with Thomas Witt's help.)
11
+
12
+ 2008-08-09 KUBO Takehiro <kubo@jiubao.org>
13
+ * ext/oci8/lob.c: fix OCILobLocator#getLength for a lob over 1GB,
14
+ which affect OCI8::LOB#size and OCI8::LOB#read. fix
15
+ OCILobLocator#read and OCILobLocator#write to set offset over 2BG,
16
+ which affect OCI8::LOB#read and OCI8::LOB#write.
17
+ (This probmem was reported by Jonathan Hadders.)
18
+
19
+ 2008-07-12 KUBO Takehiro <kubo@jiubao.org>
20
+ * lib/oci8.rb.in: (1) add #to_json to OraDate too.
21
+ (2) fix a bug when using Oracle 8i and dbd. OCI_ATTR_FSPRECISION
22
+ is for TIMESTAMP data type which is new in Oracle 9i.
23
+ (This probmem was reported by Glauco Magnelli.)
24
+
25
+ 2008-07-07 KUBO Takehiro <kubo@jiubao.org>
26
+ * lib/oci8.rb.in: fix the problem that OraNumber#to_json returns
27
+ "{}" when using Rails. (This issue is reported by Alex Moore)
28
+ Object#to_json is added by active_support. But active_support
29
+ doesn't know what OraNumber is.
30
+ * ext/oci8/oraconf.rb: merge chages in ruby-oci8 trunk.
31
+
32
+ 2008-07-05 KUBO Takehiro <kubo@jiubao.org>
33
+ * ext/oci8/oraconf.rb: prints more information on checking
34
+ LD_LIBRARY_PATH.
35
+
1
36
  2008-06-26 KUBO Takehiro <kubo@jiubao.org>
2
37
  * NEWS: add changes between 1.0.1 and 1.0.2.
3
38
  * VERSION: change version to 1.0.2.
data/NEWS CHANGED
@@ -1,3 +1,29 @@
1
+ 1.0.3:
2
+
3
+ 1. add workaround code for a losing character problem when reading CLOB.
4
+ (reported by Efren Yevale and Thomas Witt and fixed with Thomas Witt's help.)
5
+
6
+ The problem is happened at the following condition.
7
+
8
+ (a) Oracle client version is 10.2.0.4 or 11.1.0.6.
9
+ It doesn't happend when using 10.2.0.3 client or lower.
10
+ It doesn't depend on Oracle server version.
11
+
12
+ (b) The character set is a variable-length one.
13
+ e.g. AL32UTF8
14
+
15
+ 2. fix a problem when reading BLOB/CLOB over 1GB.
16
+ (reported by Jonathan Hadders.)
17
+
18
+ 3. [rails] fix a problem that OraNumber#to_json returns "{}" when using Rails.
19
+ (reported by Alex Moore)
20
+
21
+ Rails add to_json method. But it doesn't know what OraNumber is.
22
+ OraNumber#to_json is added for Rails.
23
+
24
+ 4. [dbi] fix a problem when using Oracle 8i and ruby-dbi.
25
+ (reported by Glauco MagnelliRemi Gagnon.)
26
+
1
27
  1.0.2:
2
28
 
3
29
  1. add a gemspec file.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
@@ -55,7 +55,7 @@ static VALUE oci8_lob_get_length(VALUE self, VALUE vsvc)
55
55
  rv = OCILobGetLength(svch->hp, h->errhp, h->hp, &len);
56
56
  if (rv != OCI_SUCCESS)
57
57
  oci8_raise(h->errhp, rv, NULL);
58
- return INT2FIX(len);
58
+ return UINT2NUM(len);
59
59
  }
60
60
 
61
61
  #ifdef HAVE_OCILOBGETCHUNKSIZE
@@ -72,7 +72,7 @@ static VALUE oci8_lob_get_chunk_size(VALUE self, VALUE vsvc)
72
72
  rv = OCILobGetChunkSize(svch->hp, h->errhp, h->hp, &len);
73
73
  if (rv != OCI_SUCCESS)
74
74
  oci8_raise(h->errhp, rv, NULL);
75
- return INT2FIX(len);
75
+ return UINT2NUM(len);
76
76
  }
77
77
  #endif
78
78
 
@@ -101,7 +101,7 @@ static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
101
101
  ub1 csfrm;
102
102
  ub4 amt;
103
103
  sword rv;
104
- char buf[4096];
104
+ char buf[8192]; /* 8192 is chunk size in a platform. */
105
105
  #ifndef OCI8_USE_CALLBACK_LOB_READ
106
106
  size_t buf_size_in_char;
107
107
  #endif
@@ -110,8 +110,8 @@ static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
110
110
  rb_scan_args(argc, argv, "32", &vsvc, &voffset, &vamt, &vcsid, &vcsfrm);
111
111
  Get_Handle(self, h); /* 0 */
112
112
  Check_Handle(vsvc, OCISvcCtx, svch); /* 1 */
113
- offset = NUM2INT(voffset); /* 2 */
114
- amt = NUM2INT(vamt); /* 3 */
113
+ offset = NUM2UINT(voffset); /* 2 */
114
+ amt = NUM2UINT(vamt); /* 3 */
115
115
  csid = NIL_P(vcsid) ? 0 : NUM2INT(vcsid); /* 4 */
116
116
  csfrm = NIL_P(vcsfrm) ? SQLCS_IMPLICIT : NUM2INT(vcsfrm); /* 5 */
117
117
 
@@ -137,9 +137,22 @@ static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
137
137
  */
138
138
  buf_size_in_char = sizeof(buf) / h->u.lob_locator.char_width;
139
139
  do {
140
+ /* initialize buf in zeros everytime to check a nul characters. */
141
+ memset(buf, 0, sizeof(buf));
140
142
  rv = OCILobRead(svch->hp, h->errhp, h->hp, &amt, offset, buf, sizeof(buf), NULL, NULL, csid, csfrm);
141
143
  if (rv != OCI_SUCCESS && rv != OCI_NEED_DATA)
142
144
  oci8_raise(h->errhp, rv, NULL);
145
+
146
+ /* Workaround when using Oracle 10.2.0.4 or 11.1.0.6 client and
147
+ * variable-length character set (e.g. AL32UTF8).
148
+ *
149
+ * When the above mentioned condition, amt may be shorter. So
150
+ * amt is increaded until a nul character to know the actually
151
+ * read size.
152
+ */
153
+ while (amt < sizeof(buf) && buf[amt] != '\0') {
154
+ amt++;
155
+ }
143
156
  if (amt == 0)
144
157
  break;
145
158
  /* for fixed size charset, amt is the number of characters stored in buf. */
@@ -170,7 +183,7 @@ static VALUE oci8_lob_write(int argc, VALUE *argv, VALUE self)
170
183
  rb_scan_args(argc, argv, "32", &vsvc, &voffset, &vbuf, &vcsid, &vcsfrm);
171
184
  Get_Handle(self, h); /* 0 */
172
185
  Check_Handle(vsvc, OCISvcCtx, svch); /* 1 */
173
- offset = NUM2INT(voffset); /* 2 */
186
+ offset = NUM2UINT(voffset); /* 2 */
174
187
  Get_String(vbuf, buf); /* 3 */
175
188
  csid = NIL_P(vcsid) ? 0 : NUM2INT(vcsid); /* 4 */
176
189
  csfrm = NIL_P(vcsfrm) ? SQLCS_IMPLICIT : NUM2INT(vcsfrm); /* 5 */
@@ -247,7 +247,7 @@ EOS
247
247
  print <<EOS
248
248
  ---------------------------------------------------
249
249
  error messages:
250
- #{$!.to_str}
250
+ #{$!.to_s}
251
251
  ---------------------------------------------------
252
252
  See:
253
253
  * http://ruby-oci8.rubyforge.org/#{lang}/HowToInstall.html
@@ -270,7 +270,7 @@ EOS
270
270
  private
271
271
 
272
272
  def self.check_ic_dir
273
- print "checking for load library path... "
273
+ puts "checking for load library path... "
274
274
  STDOUT.flush
275
275
 
276
276
  # get library load path names
@@ -340,24 +340,34 @@ EOS
340
340
  glob_name = "#{oci_basename}.#{so_ext}#{oci_glob_postfix}"
341
341
  ld_path = nil
342
342
  file = nil
343
- @@ld_envs.collect do |env|
344
- puts "(#{env})... "
345
- ENV[env] && ENV[env].split(File::PATH_SEPARATOR)
346
- end.flatten.each do |path|
347
- next if path.nil? or path == ''
348
- path.gsub!(/\\/, '/') if /mswin32|cygwin|mingw32|bccwin32/ =~ RUBY_PLATFORM
349
- files = Dir.glob(File.join(path, glob_name))
350
- next if files.empty?
351
- STDOUT.flush
352
- next if (check_proc && !check_proc.call(files[0]))
353
- file = files[0]
354
- ld_path = path
343
+ @@ld_envs.each do |env|
344
+ if ENV[env].nil?
345
+ puts " #{env} is not set."
346
+ next
347
+ end
348
+ puts " #{env}... "
349
+ ENV[env].split(File::PATH_SEPARATOR).each do |path|
350
+ next if path.nil? or path == ''
351
+ print " checking #{path}... "
352
+ path.gsub!(/\\/, '/') if /mswin32|cygwin|mingw32|bccwin32/ =~ RUBY_PLATFORM
353
+ files = Dir.glob(File.join(path, glob_name))
354
+ if files.empty?
355
+ puts "no"
356
+ next
357
+ end
358
+ STDOUT.flush
359
+ next if (check_proc && !check_proc.call(files[0]))
360
+ file = files[0]
361
+ ld_path = path
362
+ puts "yes"
363
+ break
364
+ end
355
365
  break
356
366
  end
357
367
 
358
368
  if ld_path.nil? and RUBY_PLATFORM =~ /linux/
359
369
  open("|/sbin/ldconfig -p") do |f|
360
- print "(ld.so.conf)... "
370
+ print " checking ld.so.conf... "
361
371
  STDOUT.flush
362
372
  while line = f.gets
363
373
  if line =~ /libclntsh\.so\..* => (\/.*)\/libclntsh\.so\.(.*)/
@@ -365,22 +375,22 @@ EOS
365
375
  path = $1
366
376
  next if (check_proc && !check_proc.call(file))
367
377
  ld_path = path
378
+ puts "yes"
368
379
  break
369
380
  end
370
381
  end
382
+ puts "no"
371
383
  end
372
384
  end
373
385
 
374
386
  if ld_path
375
387
  ocidata_basename.each do |basename|
376
388
  if File.exist?(File.join(ld_path, "#{basename}.#{so_ext}"))
377
- puts " found: #{file} looks like an instant client."
389
+ puts " #{file} looks like an instant client."
378
390
  return ld_path
379
391
  end
380
392
  end
381
- puts " found: #{file} looks like a full client."
382
- else
383
- puts " not found"
393
+ puts " #{file} looks like a full client."
384
394
  end
385
395
  nil
386
396
  end
@@ -433,7 +443,8 @@ EOS
433
443
  def check_ruby_header
434
444
  print "checking for ruby header... "
435
445
  STDOUT.flush
436
- unless File.exist?("#{Config::CONFIG['archdir']}/ruby.h")
446
+ rubyhdrdir = Config::CONFIG["rubyhdrdir"] || Config::CONFIG['archdir']
447
+ unless File.exist?(rubyhdrdir + '/ruby.h')
437
448
  puts "ng"
438
449
  if RUBY_PLATFORM =~ /darwin/ and File.exist?("#{Config::CONFIG['archdir']}/../universal-darwin8.0/ruby.h")
439
450
  raise <<EOS
@@ -1293,6 +1293,10 @@ class OraDate
1293
1293
  out.scalar(taguri, self.to_s, :plain)
1294
1294
  end
1295
1295
  end
1296
+
1297
+ def to_json(options=nil) # :nodoc:
1298
+ to_datetime.to_json(options)
1299
+ end
1296
1300
  end
1297
1301
 
1298
1302
  class OraNumber
@@ -1305,6 +1309,10 @@ class OraNumber
1305
1309
  out.scalar(taguri, self.to_s, :plain)
1306
1310
  end
1307
1311
  end
1312
+
1313
+ def to_json(options=nil) # :nodoc:
1314
+ to_s
1315
+ end
1308
1316
  end
1309
1317
 
1310
1318
 
@@ -1564,6 +1572,12 @@ class OCI8
1564
1572
  attr_reader :scale
1565
1573
 
1566
1574
  # interval
1575
+ if defined? OCI_ATTR_FSPRECISION and defined? OCI_ATTR_LFPRECISION
1576
+ # Oracle 8i or upper has OCI_ATTR_FSPRECISION and OCI_ATTR_LFPRECISION
1577
+ @@is_fsprecision_available = true
1578
+ else
1579
+ @@is_fsprecision_available = false
1580
+ end
1567
1581
  attr_reader :fsprecision
1568
1582
  attr_reader :lfprecision
1569
1583
 
@@ -1588,8 +1602,22 @@ class OCI8
1588
1602
  when 5; :lit_null
1589
1603
  else raise "unknown charset_form #{param.attrGet(OCI_ATTR_CHARSET_FORM)}"
1590
1604
  end
1591
- @fsprecision = param.attrGet(OCI_ATTR_FSPRECISION)
1592
- @lfprecision = param.attrGet(OCI_ATTR_LFPRECISION)
1605
+
1606
+ @fsprecision = nil
1607
+ @lfprecision = nil
1608
+ if @@is_fsprecision_available
1609
+ begin
1610
+ @fsprecision = param.attrGet(OCI_ATTR_FSPRECISION)
1611
+ @lfprecision = param.attrGet(OCI_ATTR_LFPRECISION)
1612
+ rescue OCIError
1613
+ raise if $!.code != 24316 # ORA-24316: illegal handle type
1614
+ # Oracle 8i could not use OCI_ATTR_FSPRECISION and
1615
+ # OCI_ATTR_LFPRECISION even though it defines these
1616
+ # constants in oci.h.
1617
+ @@is_fsprecision_available = false
1618
+ end
1619
+ end
1620
+
1593
1621
  @type_string = __type_string(param)
1594
1622
  end
1595
1623
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Summary: ruby interface for Oracle using OCI8 API
5
5
  Name: ruby-oci8
6
- Version: 1.0.2
6
+ Version: 1.0.3
7
7
  Release: 1%{?dist}
8
8
  Group: Development/Libraries
9
9
  License: Ruby License
metadata CHANGED
@@ -1,33 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: ruby-oci8
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2008-06-26 00:00:00 +09:00
8
- summary: Ruby interface for Oracle using OCI8 API
9
- require_paths:
10
- - lib
11
- email: kubo@jiubao.org
12
- homepage: http://ruby-oci8.rubyforge.org
13
- rubyforge_project: ruby-oci8
14
- description: ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle8, Oracle8i, Oracle9i, Oracle10g and Oracle Instant Client.
15
- autorequire: oci8
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 1.8.0
24
- version:
4
+ version: 1.0.3
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - KUBO Takehiro
8
+ autorequire: oci8
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-10 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle8, Oracle8i, Oracle9i, Oracle10g and Oracle Instant Client.
17
+ email: kubo@jiubao.org
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/oci8/extconf.rb
22
+ extra_rdoc_files:
23
+ - README
31
24
  files:
32
25
  - NEWS
33
26
  - ChangeLog
@@ -99,20 +92,34 @@ files:
99
92
  - test/test_oradate.rb
100
93
  - test/test_oranumber.rb
101
94
  - test/test_metadata.rb
102
- test_files:
103
- - test/test_all.rb
95
+ has_rdoc: true
96
+ homepage: http://ruby-oci8.rubyforge.org
97
+ post_install_message:
104
98
  rdoc_options:
105
99
  - --main
106
100
  - README
107
101
  - --exclude
108
102
  - ext/*
109
- extra_rdoc_files:
110
- - README
111
- executables: []
112
-
113
- extensions:
114
- - ext/oci8/extconf.rb
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.0
110
+ version:
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ version:
115
117
  requirements: []
116
118
 
117
- dependencies: []
118
-
119
+ rubyforge_project: ruby-oci8
120
+ rubygems_version: 1.1.1
121
+ signing_key:
122
+ specification_version: 2
123
+ summary: Ruby interface for Oracle using OCI8 API
124
+ test_files:
125
+ - test/test_all.rb