ruby-oci8 2.0.2 → 2.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,124 @@
1
+ 2009-10-21 KUBO Takehiro <kubo@jiubao.org>
2
+ * NEWS: add changes between 2.0.2 and 2.0.3.
3
+ * VERSION, Makefile: change the version to 2.0.3.
4
+ * ext/oci8/oci8.c: fix typo.
5
+ * ext/oci8/apiwrap.yml: add OCIIntervalFromText() prototype.
6
+
7
+ 2009-10-18 KUBO Takehiro <kubo@jiubao.org>
8
+ * ext/oci8/ocidatetime.c: Add workarounds for Oracle 9.2.0.1.
9
+ * lib/oci8/datetime.rb: Change the unit of OCI8::BindType::IntervalDS
10
+ from day to second. Add OCI8::BindType::IntervalDS.unit and
11
+ OCI8::BindType::IntervalDS.unit=.
12
+ * test/test_datetime.rb: Fix tests for the above changes.
13
+
14
+ 2009-10-17 KUBO Takehiro <kubo@jiubao.org>
15
+ * ext/oci8/oci8.c: Add a workaround for Oracle 9.2.0.1 when clearing
16
+ a client identifier.
17
+ * ext/oci8/oci8lib.c: Fix a segv when canceling a non-blocking
18
+ execution.
19
+ * test_appinfo.rb: Fix temporarily to prevent a segmentation fault
20
+ under Oracle 9.2.0.1.
21
+ * test/test_oci8.rb: Fix temporarily to prevent a segmentation fault
22
+ under Oracle 9.2.0.1. Fix for BigDecimal bundled in ruby 1.8.5.
23
+ * test/test_oranumber.rb: Fix for Oracle 9.2. Comparing float values
24
+ by <=> is too sensitive to use it in tests.
25
+
26
+ 2009-10-06 KUBO Takehiro <kubo@jiubao.org>
27
+ * ext/oci8/ocinumber.c: Add a global function OraNumber(obj) as a
28
+ shortcut of OraNumber.new(obj) as Rational and BigDecimal do.
29
+ Changes the return type of the four rules of arithmetic;
30
+ addition, subtraction, multiplication and division. It was
31
+ OraNumber, but now it depends on the operand.
32
+ * lib/oci8/bindtype.rb: Add OCI8::BindType::BigDecimal and
33
+ OCI8::BindType::Rational. Change the default data type for
34
+ number column which fit neither Integer nor Float from
35
+ OraNumber to BigDecimal.
36
+ * lib/oci8/oci8.rb: Fix for OCI8::BindType::Mapping to accept
37
+ a class name instead of the class object to support
38
+ OCI8::BindType::BigDecimal and OCI8::BindType::Rational without
39
+ requiring 'bigdecimal' and 'rational'.
40
+ * spec/oranumber_spec.rb: Add a spec file for OraNumber arithmetic.
41
+ * test/test_oci8.rb: Add tests for OCI8::BindType::BigDecimal and
42
+ OCI8::BindType::Rational.
43
+
44
+ 2009-10-04 KUBO Takehiro <kubo@jiubao.org>
45
+ * ext/oci8/oci8.c: Add constants missing in Oracle client prior to 10g.
46
+ * ext/oci8/oraconf.rb:
47
+ 1. Fix for ruby 1.8.5 with Oracle 8.x which needs some object
48
+ files to link with.
49
+ (reported by Jayson Cena)
50
+ 2. Revise the error message under the sudo environemnt.
51
+ 3. Print not only error message but also the error backtrace when
52
+ oraconf.rb fails.
53
+ * lib/oci8/object.rb: Fix to accept nil attribute in object type's
54
+ constructors. This works only for simple data types such as number,
55
+ string. But it doesn't for complex types such as object types.
56
+ (requested by Remi Gagnon)
57
+ * spec/object_type_spec.rb: Add a test for object type's constructors.
58
+
59
+ 2009-09-22 KUBO Takehiro <kubo@jiubao.org>
60
+ * lib/oci8/.document, lib/oci8/datetime.rb: 1. Add
61
+ OCI8::BindType.default_timezone and OCI8::BindType.default_timezone=.
62
+ 2. Change the logic to convert to Time and DateTime to adapt DST.
63
+ 3. Use new features of Time class in ruby 1.9.2 if they are available.
64
+ 4. Add rdoc comments.
65
+ * spec/fetch_datetime8_spec.rb, spec/fetch_datetime_spec.rb,
66
+ spec/fetch_time8_spec.rb, spec/fetch_time_spec.rb,
67
+ spec/spec_helper.rb: Add tests for OCI8::BindType::DateTime and
68
+ OCI8::BindType::Time.
69
+
70
+ 2009-09-13 KUBO Takehiro <kubo@jiubao.org>
71
+ * ext/oci8/lob.c, ext/oci8/oci8.h, test/test_clob.rb: Change
72
+ OCI8::LOB#write to accept an object which is not a String and
73
+ doesn't respond to 'to_str' as IO#write does.
74
+ (requested by Christopher Jones)
75
+
76
+ 2009-09-12 KUBO Takehiro <kubo@jiubao.org>
77
+ * ext/oci8/extconf.rb, lib/oci8.rb.in: Fixed for ruby 1.9.2 preview1.
78
+ (pointed by Raimonds Simanovskis)
79
+
80
+ 2009-09-12 KUBO Takehiro <kubo@jiubao.org>
81
+ * ext/oci8/oraconf.rb: Fixed to compile for AIX instant clients.
82
+ (reported by Kazuya Teramoto)
83
+
84
+ 2009-06-09 KUBO Takehiro <kubo@jiubao.org>
85
+ * ext/oci8/oci8lib.c: Change the initial polling interval of
86
+ non-blocking mode for ruby 1.8 from 100 msec to 10 msec, which
87
+ is same with ruby-oci8 1.0.
88
+ * ext/oci8/oci8.c: Change the default setting of non-blocking mode
89
+ for ruby 1.9 to true. Revise rdoc comments.
90
+
91
+ 2009-06-07 KUBO Takehiro <kubo@jiubao.org>
92
+ * ext/oci8/oci8.c: revise rdoc comments.
93
+
94
+ 2009-06-05 KUBO Takehiro <kubo@jiubao.org>
95
+ * Makefile: check rdoc version when making rdoc documentation.
96
+ The rdoc version must be 2.4.
97
+ * ext/oci8/.document, ext/oci8/oci8.c, lib/.document,
98
+ lib/oci8/.document, lib/oci8/oci8.rb: fix rdoc comments a bit.
99
+
100
+ 2009-05-24 KUBO Takehiro <kubo@jiubao.org>
101
+ * ext/oci8/object.c, lib/oci8/datetime.rb, lib/oci8/object.rb:
102
+ add DATE datatype support in object types.
103
+
104
+ 2009-05-19 KUBO Takehiro <kubo@jiubao.org>
105
+ * ext/oci8/bind.c: delete OCI8::BindType::Fixnum.
106
+ * lib/oci8/compat.rb: add OCI8::BindType::Fixnum as an alias
107
+ of OCI8::BindType::Integer.
108
+ * ext/oci8/extconf.rb: change extconf.rb's argument value of
109
+ '--with-oracle-version' to accept dotted version such as
110
+ '9.2.0.'
111
+ * ext/oci8/oraconf.rb: When extconf.rb fails and it is run
112
+ by sudo command, change the error message to notice that
113
+ 'sudo' may unset environment variables.
114
+
115
+ 2009-05-18 KUBO Takehiro <kubo@jiubao.org>
116
+ * ext/oci8/oci8.c: revise rdoc comments for OCI8#ping and
117
+ OCI8#client_identifier=. Add OCI8#module=, OCI8#action= and
118
+ OCI8#client_info.
119
+ * test/test_appinfo.rb: add test cases for OCI8#module=,
120
+ OCI8#action= and OCI8#client_info.
121
+
1
122
  2009-05-17 KUBO Takehiro <kubo@jiubao.org>
2
123
  * NEWS: add changes between 2.0.1 and 2.0.2.
3
124
  * VERSION: change version to 2.0.2.
data/Makefile CHANGED
@@ -1,5 +1,6 @@
1
1
  VERSION = `cat VERSION`
2
2
  RUBY = ruby -w
3
+ RDOC = rdoc
3
4
 
4
5
  all: build
5
6
 
@@ -30,10 +31,16 @@ format_c_source:
30
31
  astyle --options=none --style=linux --indent=spaces=4 --brackets=linux --suffix=none ext/oci8/*.[ch]
31
32
 
32
33
  # internal use only
33
- .PHONY: rdoc
34
+ .PHONY: rdoc check-rdoc-version run-rdoc
34
35
 
35
- rdoc:
36
- $(RUBY) custom-rdoc.rb -o rdoc -U README ext/oci8 lib
36
+ rdoc: check-rdoc-version run-rdoc
37
+
38
+ check-rdoc-version:
39
+ @echo check rdoc version
40
+ @expr match "`$(RDOC) --version`" '^rdoc 2\.4' > /dev/null || (echo 'rdoc version is not 2.4.'; exit 1)
41
+
42
+ run-rdoc:
43
+ TZ= $(RDOC) -o rdoc -c us-ascii --threads=1 -W http://ruby-oci8.rubyforge.org/svn/trunk/ruby-oci8/ ext/oci8 lib
37
44
 
38
45
  dist:
39
46
  -rm -rf ruby-oci8-$(VERSION)
@@ -52,7 +59,7 @@ dist-check: dist
52
59
  #
53
60
  RUBY_18 = c:\ruby
54
61
  RUBY_191 = c:\ruby-1.9.1
55
- GEMPKG = ruby-oci8-2.0.2-x86-mswin32-60.gem
62
+ GEMPKG = ruby-oci8-2.0.3-x86-mswin32-60.gem
56
63
 
57
64
  ext\oci8\oci8lib_18.so:
58
65
  $(RUBY_18)\bin\ruby -r fileutils -e "FileUtils.rm_rf('ruby18')"
data/NEWS CHANGED
@@ -1,3 +1,129 @@
1
+ 2.0.3:
2
+
3
+ * Imcompatible Changes
4
+
5
+ - Number column in a SQL statement
6
+
7
+ Changes the default data type for number column which fit neither
8
+ Integer nor Float from OraNumber to BigDecimal.
9
+
10
+ conn.exec("select 1.0 from dual") do |row|
11
+ p row[0] # => BigDecimal("1") if the ruby-oci8 version is 2.0.3.
12
+ # => OraNumber(1) if the version is 2.0.2.
13
+ end
14
+
15
+ - Priority of OraNumber within numerical types
16
+
17
+ The return types of basic arithmetic operations with other numerical
18
+ types are changed.
19
+
20
+ 2.0.3:
21
+ OraNumber + Integer => OraNumber (OraNumber wins.)
22
+ OraNumber + Float => Float (OraNumber loses.)
23
+ OraNumber + Rational => Rational (OraNumber loses.)
24
+ OraNumber + BigDecimal => BigDecimal (OraNumber loses.)
25
+
26
+ 2.0.2:
27
+ OraNumber + Integer => OraNumber (OraNumber wins always.)
28
+ OraNumber + Float => OraNumber
29
+ OraNumber + Rational => OraNumber
30
+ OraNumber + BigDecimal => OraNumber
31
+
32
+ - Interval day to second
33
+
34
+ The retrived value of Oracle data type "interval day to second"
35
+ was changed from the number of days as a Rational to the number
36
+ of seconds as a Float by default.
37
+ Use OCI8::BindType::IntervalDS.unit = :day to make it compatible
38
+ with the previous versions.
39
+
40
+ conn.exec("select to_dsinterval('0 00:00:01') from dual") do |row|
41
+ p row[0] # => 1.0 if the version is 2.0.3 and
42
+ # OCI8::BindType::IntervalDS.unit is :second.
43
+ # => (1/86400) if the version is 2.0.3 and
44
+ # OCI8::BindType::IntervalDS.unit is :day or
45
+ # the version is 2.0.2.
46
+ end
47
+
48
+ - Date, timestamp, timestamp with time zone data types and ruby 1.9.2
49
+
50
+ These data types are retrived always as Time values when the
51
+ ruby version is 1.9.2 because the Time class is enhanced to
52
+ represent any time zone and is free from year 2038 problem.
53
+
54
+ Prior to ruby 1.9.2, if the time cannot be represented by
55
+ Unix time or the time zone is neither utc nor local, they are
56
+ retrived as DateTime values.
57
+
58
+ - Non-blocking mode and ruby 1.9
59
+
60
+ non-blocking mode is enabled by default when the ruby is 1.9.
61
+
62
+ * New Features
63
+
64
+ - BigDecimal and Rational are availabe as bind values.
65
+
66
+ - New methods OCI8#module=, OCI8#action= and OCI8#client_info= are added.
67
+
68
+ These methods change the module name, the action name and the client_info
69
+ in the current session respectively.
70
+
71
+ After Oracle 10g client, these don't perform network round trips.
72
+ The change is reflected to the server by the next round trip such as
73
+ OCI8#exec, OCI8#ping, etc.
74
+
75
+ Prior to Oracle 10g client, these call PL/SQL functions such as
76
+ DBMS_APPLICATION_INFO.SET_MODULE, DBMS_APPLICATION_INFO.SET_ACTION,
77
+ and DBMS_APPLICATION_INFO.SET_CLIENT_INFO internally.
78
+ The change is reflected immediately by a network round trip.
79
+
80
+ - OCI8::BindType.default_timezone
81
+
82
+ The default time zone of Time or DateTime values.
83
+ This parameter is used only when
84
+ (1) date values are fetched and the Oracle client version is 8.x
85
+ or
86
+ (2) object types have date data type attributes.
87
+
88
+ Note that if the Oracle client version is 9i or upper, the time
89
+ zone is determined by the session time zone. The default value
90
+ is local time zone. You can change it to GMT by executing the
91
+ following SQL statement for each connection.
92
+
93
+ alter session set time_zone = '00:00'
94
+
95
+ * Other specification changes
96
+
97
+ - Add a global function OraNumber(obj) as a shortcut of OraNumber.new(obj)
98
+ as Rational and BigDecimal do.
99
+
100
+ - Fix to accept nil attribute in object type's
101
+ constructors. This works only for simple data types such as number,
102
+ string. But it doesn't for complex types such as object types.
103
+ (requested by Remi Gagnon)
104
+
105
+ - add DATE datatype support in object types.
106
+
107
+ - Change OCI8::LOB#write to accept an object which is not a String and
108
+ doesn't respond to 'to_str' as IO#write does.
109
+ (requested by Christopher Jones)
110
+
111
+ - Change the initial polling interval of
112
+ non-blocking mode for ruby 1.8 from 100 msec to 10 msec, which
113
+ is same with ruby-oci8 1.0.
114
+
115
+ * Fixed installation issues.
116
+
117
+ - Fix oraconf.rb for ruby 1.8.5 with Oracle 8.x which needs some object
118
+ files to link with.
119
+ (reported by Jayson Cena)
120
+
121
+ - Fix oraconf.rb for ruby 1.9.2 preview1.
122
+ (pointed by Raimonds Simanovskis)
123
+
124
+ - Fix oraconf.rb to compile for AIX instant clients.
125
+ (reported by Kazuya Teramoto)
126
+
1
127
  2.0.2:
2
128
 
3
129
  * add new methods
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
1
+ 2.0.3
@@ -1 +1,16 @@
1
- *.c
1
+ #attr.c
2
+ #oci8lib.c
3
+ #env.c
4
+
5
+ oci8.c
6
+ bind.c
7
+ stmt.c
8
+ encoding.c
9
+ error.c
10
+ metadata.c
11
+
12
+ lob.c
13
+ ocinumber.c
14
+ ocidatetime.c
15
+ oradate.c
16
+ object.c
@@ -1076,6 +1076,15 @@ OCIDateTimeGetTime:
1076
1076
  - ub1 *ss
1077
1077
  - ub4 *fsec
1078
1078
 
1079
+ # round trip: 0 (not docmented. I guess.)
1080
+ OCIIntervalFromText:
1081
+ :version: 900
1082
+ :args: - dvoid *hndl
1083
+ - OCIError *err
1084
+ - CONST OraText *inpstr
1085
+ - size_t str_len
1086
+ - OCIInterval *result
1087
+
1079
1088
  # round trip: 0 (not docmented. I guess.)
1080
1089
  OCIDateTimeGetTimeZoneOffset:
1081
1090
  :version: 900
@@ -3,7 +3,7 @@
3
3
  * attr.c
4
4
  *
5
5
  * $Author: kubo $
6
- * $Date: 2009-05-17 22:07:16 +0900 (Sun, 17 May 2009) $
6
+ * $Date: 2009-10-21 22:50:01 +0900 (Wed, 21 Oct 2009) $
7
7
  *
8
8
  * Copyright (C) 2002-2007 KUBO Takehiro <kubo@jiubao.org>
9
9
  */
@@ -3,7 +3,7 @@
3
3
  * bind.c
4
4
  *
5
5
  * $Author: kubo $
6
- * $Date: 2009-05-17 22:07:16 +0900 (Sun, 17 May 2009) $
6
+ * $Date: 2009-10-21 22:50:01 +0900 (Wed, 21 Oct 2009) $
7
7
  *
8
8
  * Copyright (C) 2002-2008 KUBO Takehiro <kubo@jiubao.org>
9
9
  */
@@ -238,42 +238,6 @@ static const oci8_bind_class_t bind_long_raw_class = {
238
238
  };
239
239
  #endif /* USE_DYNAMIC_FETCH */
240
240
 
241
- /*
242
- * bind_fixnum
243
- */
244
- static VALUE bind_fixnum_get(oci8_bind_t *obind, void *data, void *null_struct)
245
- {
246
- return LONG2NUM(*(long*)data);
247
- }
248
-
249
- static void bind_fixnum_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
250
- {
251
- Check_Type(val, T_FIXNUM);
252
- *(long*)data = FIX2LONG(val);
253
- }
254
-
255
- static void bind_fixnum_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
256
- {
257
- obind->value_sz = sizeof(long);
258
- obind->alloc_sz = sizeof(long);
259
- }
260
-
261
- static const oci8_bind_class_t bind_fixnum_class = {
262
- {
263
- NULL,
264
- oci8_bind_free,
265
- sizeof(oci8_bind_t)
266
- },
267
- bind_fixnum_get,
268
- bind_fixnum_set,
269
- bind_fixnum_init,
270
- NULL,
271
- NULL,
272
- NULL,
273
- NULL,
274
- SQLT_INT
275
- };
276
-
277
241
  /*
278
242
  * bind_float
279
243
  */
@@ -493,7 +457,6 @@ void Init_oci8_bind(VALUE klass)
493
457
  oci8_define_bind_class("Long", &bind_long_class);
494
458
  oci8_define_bind_class("LongRaw", &bind_long_raw_class);
495
459
  #endif /* USE_DYNAMIC_FETCH */
496
- oci8_define_bind_class("Fixnum", &bind_fixnum_class);
497
460
  oci8_define_bind_class("Float", &bind_float_class);
498
461
  if (oracle_client_version >= ORAVER_10_1) {
499
462
  oci8_define_bind_class("BinaryDouble", &bind_binary_double_class);
@@ -11,6 +11,7 @@ end
11
11
 
12
12
  require File.dirname(__FILE__) + '/oraconf'
13
13
  require File.dirname(__FILE__) + '/apiwrap'
14
+ require File.dirname(__FILE__) + '/../../lib/oci8/oracle_version.rb'
14
15
 
15
16
  RUBY_OCI8_VERSION = File.read("#{File.dirname(__FILE__)}/../../VERSION").chomp
16
17
 
@@ -70,7 +71,7 @@ have_type('OCICallbackLobWrite2', 'ociap.h')
70
71
  have_type('OCIAdmin*', 'ociap.h')
71
72
 
72
73
  if with_config('oracle-version')
73
- oci_client_version = with_config('oracle-version').to_i
74
+ oci_client_version = OCI8::OracleVersion.new(with_config('oracle-version')).to_i
74
75
  else
75
76
  oci_client_version = oci_actual_client_version
76
77
  end
@@ -118,14 +119,12 @@ replace = {
118
119
  # make ruby script before running create_makefile.
119
120
  replace_keyword(File.dirname(__FILE__) + '/../../lib/oci8.rb.in', '../../lib/oci8.rb', replace)
120
121
 
121
- case RUBY_VERSION
122
- when /^1\.9\.1/
123
- so_basename = "oci8lib_191"
124
- when /^1\.8/
125
- so_basename = "oci8lib_18"
126
- else
127
- raise 'unsupported ruby version: ' + RUBY_VERSION
128
- end
122
+ # Config::CONFIG["ruby_version"] indicates the ruby API version.
123
+ # 1.8 - ruby 1.8.x
124
+ # 1.9.1 - ruby 1.9.1 and 1.9.2
125
+ # 1.9.x - ruby 1.9.x future version which will break the API compatibility
126
+ so_basename = "oci8lib_" + Config::CONFIG["ruby_version"].gsub(/\W/, '')
127
+
129
128
  $defs << "-DInit_oci8lib=Init_#{so_basename}"
130
129
  $defs << "-Doci8lib=#{so_basename}"
131
130
 
@@ -379,11 +379,13 @@ static VALUE oci8_lob_write(VALUE self, VALUE data)
379
379
  ub4 amt;
380
380
 
381
381
  lob_open(lob);
382
+ if (TYPE(data) != T_STRING) {
383
+ data = rb_obj_as_string(data);
384
+ }
382
385
  if (lob->lobtype == OCI_TEMP_CLOB) {
383
- OCI8StringValue(data);
384
- } else {
385
- StringValue(data);
386
+ data = rb_str_export_to_enc(data, oci8_encoding);
386
387
  }
388
+ RB_GC_GUARD(data);
387
389
  amt = RSTRING_LEN(data);
388
390
  oci_lc(OCILobWrite_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &amt, lob->pos + 1, RSTRING_PTR(data), amt, OCI_ONE_PIECE, NULL, NULL, 0, lob->csfrm));
389
391
  lob->pos += amt;