ruby-oci8 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +13 -0
- data/ChangeLog +104 -0
- data/NEWS +337 -235
- data/README.md +38 -0
- data/VERSION +1 -1
- data/dist-files +7 -6
- data/docs/install-binary-package.md +40 -0
- data/docs/install-full-client.md +116 -0
- data/docs/install-instant-client.md +167 -0
- data/docs/platform-specific-issues.md +209 -0
- data/docs/report-installation-issue.md +50 -0
- data/ext/oci8/apiwrap.yml +37 -14
- data/ext/oci8/error.c +26 -11
- data/ext/oci8/extconf.rb +19 -3
- data/ext/oci8/lob.c +287 -0
- data/ext/oci8/oci8.c +15 -9
- data/ext/oci8/oci8.h +8 -0
- data/ext/oci8/oci8lib.c +7 -2
- data/ext/oci8/ocihandle.c +209 -99
- data/ext/oci8/ocinumber.c +430 -147
- data/ext/oci8/oradate.c +92 -75
- data/ext/oci8/stmt.c +30 -12
- data/ext/oci8/win32.c +22 -0
- data/lib/oci8/bindtype.rb +1 -0
- data/lib/oci8/connection_pool.rb +1 -0
- data/lib/oci8/encoding-init.rb +1 -0
- data/lib/oci8/object.rb +29 -4
- data/lib/oci8/oci8.rb +75 -17
- data/lib/oci8/ocihandle.rb +192 -12
- data/lib/oci8/oracle_version.rb +47 -41
- data/lib/oci8/properties.rb +19 -0
- data/pre-distclean.rb +2 -2
- data/ruby-oci8.gemspec +7 -3
- data/test/config.rb +1 -6
- data/test/test_datetime.rb +70 -32
- data/test/test_oci8.rb +8 -2
- metadata +35 -53
- data/README +0 -5
- data/doc/api.en.html +0 -527
- data/doc/api.en.rd +0 -554
- data/doc/api.ja.html +0 -525
- data/doc/api.ja.rd +0 -557
- data/doc/manual.css +0 -35
data/ext/oci8/oradate.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* oradate.c
|
4
4
|
*
|
5
|
-
* Copyright (C) 2002-
|
5
|
+
* Copyright (C) 2002-2012 KUBO Takehiro <kubo@jiubao.org>
|
6
6
|
*
|
7
7
|
* date and time between 4712 B.C. and 9999 A.D.
|
8
8
|
*/
|
@@ -14,9 +14,8 @@ static VALUE cOraDate;
|
|
14
14
|
/*
|
15
15
|
* Document-class: OraDate
|
16
16
|
*
|
17
|
-
* ruby class compatible with Oracle <tt>DATE</tt> data type.
|
18
|
-
*
|
19
|
-
*
|
17
|
+
* OraDate is the ruby class compatible with Oracle <tt>DATE</tt> data type.
|
18
|
+
* The range is between 4712 B.C. and 9999 A.D.
|
20
19
|
*/
|
21
20
|
struct ora_date {
|
22
21
|
unsigned char century;
|
@@ -79,10 +78,15 @@ static VALUE ora_date_s_allocate(VALUE klass)
|
|
79
78
|
}
|
80
79
|
|
81
80
|
/*
|
82
|
-
*
|
83
|
-
*
|
81
|
+
* call-seq:
|
82
|
+
* initialize(year = 1, month = 1, day = 1, hour = 0, min = 0, sec = 0)
|
83
|
+
*
|
84
|
+
* Returns an <code>OraDate</code> object initialized to the specified date and time.
|
84
85
|
*
|
85
|
-
*
|
86
|
+
* @example
|
87
|
+
* OraDate.new # => 0001-01-01 00:00:00
|
88
|
+
* OraDate.new(2012) # => 2012-01-01 00:00:00
|
89
|
+
* OraDate.new(2012, 3, 4) # => 2012-03-04 00:00:00
|
86
90
|
*/
|
87
91
|
static VALUE ora_date_initialize(int argc, VALUE *argv, VALUE self)
|
88
92
|
{
|
@@ -138,7 +142,9 @@ static VALUE ora_date_initialize(int argc, VALUE *argv, VALUE self)
|
|
138
142
|
return Qnil;
|
139
143
|
}
|
140
144
|
|
141
|
-
/*
|
145
|
+
/*
|
146
|
+
* @private
|
147
|
+
*/
|
142
148
|
static VALUE ora_date_initialize_copy(VALUE lhs, VALUE rhs)
|
143
149
|
{
|
144
150
|
ora_date_t *l, *r;
|
@@ -151,11 +157,10 @@ static VALUE ora_date_initialize_copy(VALUE lhs, VALUE rhs)
|
|
151
157
|
}
|
152
158
|
|
153
159
|
/*
|
154
|
-
*
|
155
|
-
*
|
160
|
+
* Returns an <code>OraDate</code> object initialized to the
|
161
|
+
* current local time.
|
156
162
|
*
|
157
|
-
*
|
158
|
-
* current local time.
|
163
|
+
* @return [OraDate]
|
159
164
|
*/
|
160
165
|
static VALUE ora_date_s_now(int argc, VALUE *argv, VALUE klass)
|
161
166
|
{
|
@@ -183,11 +188,10 @@ static VALUE ora_date_s_now(int argc, VALUE *argv, VALUE klass)
|
|
183
188
|
}
|
184
189
|
|
185
190
|
/*
|
186
|
-
*
|
187
|
-
*
|
191
|
+
* Returns a string representing <i>self</i>.
|
192
|
+
* The string format is 'yyyy/mm/dd hh:mi:ss'.
|
188
193
|
*
|
189
|
-
*
|
190
|
-
* The string format is 'yyyy/mm/dd hh:mi:ss'.
|
194
|
+
* @return [OraDate]
|
191
195
|
*/
|
192
196
|
static VALUE ora_date_to_s(VALUE self)
|
193
197
|
{
|
@@ -201,11 +205,9 @@ static VALUE ora_date_to_s(VALUE self)
|
|
201
205
|
}
|
202
206
|
|
203
207
|
/*
|
204
|
-
*
|
205
|
-
* oradate.to_a -> array
|
208
|
+
* Returns a 6-element <i>array</i> of year, month, day, hour, minute and second.
|
206
209
|
*
|
207
|
-
*
|
208
|
-
* {<code>[year, month, day, hour, minute, second]</code>}.
|
210
|
+
* @return [Array]
|
209
211
|
*/
|
210
212
|
static VALUE ora_date_to_a(VALUE self)
|
211
213
|
{
|
@@ -223,10 +225,9 @@ static VALUE ora_date_to_a(VALUE self)
|
|
223
225
|
}
|
224
226
|
|
225
227
|
/*
|
226
|
-
*
|
227
|
-
* oradate.year -> fixnum
|
228
|
+
* Returns the year field of <i>self</i>.
|
228
229
|
*
|
229
|
-
*
|
230
|
+
* @return [Fixnum]
|
230
231
|
*/
|
231
232
|
static VALUE ora_date_year(VALUE self)
|
232
233
|
{
|
@@ -237,10 +238,12 @@ static VALUE ora_date_year(VALUE self)
|
|
237
238
|
}
|
238
239
|
|
239
240
|
/*
|
240
|
-
*
|
241
|
-
*
|
241
|
+
* call-seq:
|
242
|
+
* year = num
|
242
243
|
*
|
243
|
-
*
|
244
|
+
* Assigns <i>num</i> to the year field of <i>self</i>.
|
245
|
+
*
|
246
|
+
* @param [Fixnum] number between -4712 and 9999
|
244
247
|
*/
|
245
248
|
static VALUE ora_date_set_year(VALUE self, VALUE val)
|
246
249
|
{
|
@@ -255,10 +258,10 @@ static VALUE ora_date_set_year(VALUE self, VALUE val)
|
|
255
258
|
}
|
256
259
|
|
257
260
|
/*
|
258
|
-
*
|
259
|
-
*
|
261
|
+
* Returns the month field of <i>self</i>.
|
262
|
+
* The month starts with one.
|
260
263
|
*
|
261
|
-
*
|
264
|
+
* @return [Fixnum]
|
262
265
|
*/
|
263
266
|
static VALUE ora_date_month(VALUE self)
|
264
267
|
{
|
@@ -269,10 +272,13 @@ static VALUE ora_date_month(VALUE self)
|
|
269
272
|
}
|
270
273
|
|
271
274
|
/*
|
272
|
-
*
|
273
|
-
*
|
275
|
+
* call-seq:
|
276
|
+
* month = num
|
277
|
+
*
|
278
|
+
* Assigns <i>num</i> to the month field of <i>self</i>.
|
279
|
+
* The month starts with one.
|
274
280
|
*
|
275
|
-
*
|
281
|
+
* @param [Fixnum] number between 1 and 12
|
276
282
|
*/
|
277
283
|
static VALUE ora_date_set_month(VALUE self, VALUE val)
|
278
284
|
{
|
@@ -287,10 +293,9 @@ static VALUE ora_date_set_month(VALUE self, VALUE val)
|
|
287
293
|
}
|
288
294
|
|
289
295
|
/*
|
290
|
-
*
|
291
|
-
* oradate.day -> fixnum
|
296
|
+
* Returns the day of month field of <i>self</i>.
|
292
297
|
*
|
293
|
-
*
|
298
|
+
* @return [Fixnum]
|
294
299
|
*/
|
295
300
|
static VALUE ora_date_day(VALUE self)
|
296
301
|
{
|
@@ -301,10 +306,12 @@ static VALUE ora_date_day(VALUE self)
|
|
301
306
|
}
|
302
307
|
|
303
308
|
/*
|
304
|
-
*
|
305
|
-
*
|
309
|
+
* call-seq:
|
310
|
+
* day = num
|
311
|
+
*
|
312
|
+
* Assigns <i>num</i> to the day of month field of <i>self</i>.
|
306
313
|
*
|
307
|
-
*
|
314
|
+
* @param [Fixnum] number between 1 and 31
|
308
315
|
*/
|
309
316
|
static VALUE ora_date_set_day(VALUE self, VALUE val)
|
310
317
|
{
|
@@ -319,10 +326,9 @@ static VALUE ora_date_set_day(VALUE self, VALUE val)
|
|
319
326
|
}
|
320
327
|
|
321
328
|
/*
|
322
|
-
*
|
323
|
-
* oradate.hour -> fixnum
|
329
|
+
* Returns the hour field of <i>self</i>.
|
324
330
|
*
|
325
|
-
*
|
331
|
+
* @return [Fixnum]
|
326
332
|
*/
|
327
333
|
static VALUE ora_date_hour(VALUE self)
|
328
334
|
{
|
@@ -333,10 +339,12 @@ static VALUE ora_date_hour(VALUE self)
|
|
333
339
|
}
|
334
340
|
|
335
341
|
/*
|
336
|
-
*
|
337
|
-
*
|
342
|
+
* call-seq:
|
343
|
+
* hour = num
|
338
344
|
*
|
339
|
-
*
|
345
|
+
* Assigns <i>num</i> to the hour field of <i>self</i>.
|
346
|
+
*
|
347
|
+
* @param [Fixnum] number between 0 and 23
|
340
348
|
*/
|
341
349
|
static VALUE ora_date_set_hour(VALUE self, VALUE val)
|
342
350
|
{
|
@@ -351,10 +359,9 @@ static VALUE ora_date_set_hour(VALUE self, VALUE val)
|
|
351
359
|
}
|
352
360
|
|
353
361
|
/*
|
354
|
-
*
|
355
|
-
* oradate.minute -> fixnum
|
362
|
+
* Returns the minute field of <i>self</i>.
|
356
363
|
*
|
357
|
-
*
|
364
|
+
* @return [Fixnum]
|
358
365
|
*/
|
359
366
|
static VALUE ora_date_minute(VALUE self)
|
360
367
|
{
|
@@ -365,10 +372,12 @@ static VALUE ora_date_minute(VALUE self)
|
|
365
372
|
}
|
366
373
|
|
367
374
|
/*
|
368
|
-
*
|
369
|
-
*
|
375
|
+
* call-seq:
|
376
|
+
* minute = num
|
377
|
+
*
|
378
|
+
* Assigns <i>num</i> to the minute field of <i>self</i>.
|
370
379
|
*
|
371
|
-
*
|
380
|
+
* @param [Fixnum] number between 0 and 59
|
372
381
|
*/
|
373
382
|
static VALUE ora_date_set_minute(VALUE self, VALUE val)
|
374
383
|
{
|
@@ -383,10 +392,9 @@ static VALUE ora_date_set_minute(VALUE self, VALUE val)
|
|
383
392
|
}
|
384
393
|
|
385
394
|
/*
|
386
|
-
*
|
387
|
-
* oradate.second -> fixnum
|
395
|
+
* Returns the second field of <i>self</i>.
|
388
396
|
*
|
389
|
-
*
|
397
|
+
* @return [Fixnum]
|
390
398
|
*/
|
391
399
|
static VALUE ora_date_second(VALUE self)
|
392
400
|
{
|
@@ -397,10 +405,12 @@ static VALUE ora_date_second(VALUE self)
|
|
397
405
|
}
|
398
406
|
|
399
407
|
/*
|
400
|
-
*
|
401
|
-
*
|
408
|
+
* call-seq:
|
409
|
+
* second = num
|
410
|
+
*
|
411
|
+
* Assigns <i>num</i> to the second field of <i>self</i>.
|
402
412
|
*
|
403
|
-
*
|
413
|
+
* @param [Fixnum] number between 0 and 59
|
404
414
|
*/
|
405
415
|
static VALUE ora_date_set_second(VALUE self, VALUE val)
|
406
416
|
{
|
@@ -415,13 +425,13 @@ static VALUE ora_date_set_second(VALUE self, VALUE val)
|
|
415
425
|
}
|
416
426
|
|
417
427
|
/*
|
418
|
-
*
|
419
|
-
* oradate.trunc
|
428
|
+
* Truncates hour, minute and second fields to zero.
|
420
429
|
*
|
421
|
-
*
|
430
|
+
* @example
|
431
|
+
* oradate = OraDate.now # => 2008/07/17 11:07:30
|
432
|
+
* oradate.trunc # => 2008/07/17 00:00:00
|
422
433
|
*
|
423
|
-
*
|
424
|
-
* oradate.trunc # 2008/07/17 00:00:00
|
434
|
+
* @return [OraDate]
|
425
435
|
*/
|
426
436
|
static VALUE ora_date_trunc(VALUE self)
|
427
437
|
{
|
@@ -435,12 +445,11 @@ static VALUE ora_date_trunc(VALUE self)
|
|
435
445
|
}
|
436
446
|
|
437
447
|
/*
|
438
|
-
*
|
439
|
-
*
|
448
|
+
* call-seq:
|
449
|
+
* self <=> other
|
440
450
|
*
|
441
|
-
*
|
442
|
-
*
|
443
|
-
* <code>Comparable</code> module is included.
|
451
|
+
* Returns -1, 0, or +1 depending on whether <i>self</i> is less than,
|
452
|
+
* equal to, or greater than <i>other</i>.
|
444
453
|
*/
|
445
454
|
static VALUE ora_date_cmp(VALUE self, VALUE val)
|
446
455
|
{
|
@@ -465,7 +474,9 @@ static VALUE ora_date_cmp(VALUE self, VALUE val)
|
|
465
474
|
return INT2FIX(0);
|
466
475
|
}
|
467
476
|
|
468
|
-
/*
|
477
|
+
/*
|
478
|
+
* @private
|
479
|
+
*/
|
469
480
|
static VALUE ora_date_hash(VALUE self)
|
470
481
|
{
|
471
482
|
ora_date_t *od;
|
@@ -483,10 +494,11 @@ static VALUE ora_date_hash(VALUE self)
|
|
483
494
|
}
|
484
495
|
|
485
496
|
/*
|
486
|
-
*
|
487
|
-
*
|
497
|
+
* Serializes <i>self</i>.
|
498
|
+
* This method is called by Marshal.dump().
|
488
499
|
*
|
489
|
-
*
|
500
|
+
* @return [String] a byte stream
|
501
|
+
* @see OraDate._load
|
490
502
|
*/
|
491
503
|
static VALUE ora_date_dump(int argc, VALUE *argv, VALUE self)
|
492
504
|
{
|
@@ -496,10 +508,15 @@ static VALUE ora_date_dump(int argc, VALUE *argv, VALUE self)
|
|
496
508
|
}
|
497
509
|
|
498
510
|
/*
|
499
|
-
*
|
500
|
-
*
|
511
|
+
* call-seq:
|
512
|
+
* _load(bytes)
|
513
|
+
*
|
514
|
+
* Restores a byte stream serialized by {OraDate#_dump}.
|
515
|
+
* This method is called by Marshal.load() to deserialize a byte stream
|
516
|
+
* created by Marshal.dump().
|
501
517
|
*
|
502
|
-
*
|
518
|
+
* @param [String] bytes a byte stream
|
519
|
+
* @return [OraDate] an deserialized object
|
503
520
|
*/
|
504
521
|
static VALUE ora_date_s_load(VALUE klass, VALUE str)
|
505
522
|
{
|
@@ -516,9 +533,9 @@ static VALUE ora_date_s_load(VALUE klass, VALUE str)
|
|
516
533
|
}
|
517
534
|
|
518
535
|
/*
|
519
|
-
*
|
536
|
+
* Document-class: OCI8::BindType::OraDate
|
520
537
|
*
|
521
|
-
*
|
538
|
+
* This is a helper class to bind OraDate as Oracle's <tt>DATE</tt> datatype.
|
522
539
|
*
|
523
540
|
*/
|
524
541
|
static VALUE bind_oradate_get(oci8_bind_t *obind, void *data, void *null_struct)
|
data/ext/oci8/stmt.c
CHANGED
@@ -35,6 +35,7 @@ typedef struct {
|
|
35
35
|
VALUE svc;
|
36
36
|
VALUE binds;
|
37
37
|
VALUE defns;
|
38
|
+
int use_stmt_release;
|
38
39
|
} oci8_stmt_t;
|
39
40
|
|
40
41
|
static void oci8_stmt_mark(oci8_base_t *base)
|
@@ -51,6 +52,11 @@ static void oci8_stmt_free(oci8_base_t *base)
|
|
51
52
|
stmt->svc = Qnil;
|
52
53
|
stmt->binds = Qnil;
|
53
54
|
stmt->defns = Qnil;
|
55
|
+
if (stmt->use_stmt_release) {
|
56
|
+
OCIStmtRelease(base->hp.stmt, oci8_errhp, NULL, 0, OCI_DEFAULT);
|
57
|
+
base->type = 0;
|
58
|
+
stmt->use_stmt_release = 0;
|
59
|
+
}
|
54
60
|
}
|
55
61
|
|
56
62
|
static oci8_base_vtable_t oci8_stmt_vtable = {
|
@@ -62,20 +68,38 @@ static oci8_base_vtable_t oci8_stmt_vtable = {
|
|
62
68
|
static VALUE oci8_stmt_initialize(int argc, VALUE *argv, VALUE self)
|
63
69
|
{
|
64
70
|
oci8_stmt_t *stmt = DATA_PTR(self);
|
71
|
+
oci8_svcctx_t *svcctx;
|
65
72
|
VALUE svc;
|
66
73
|
VALUE sql;
|
67
74
|
sword rv;
|
68
75
|
|
69
76
|
rb_scan_args(argc, argv, "11", &svc, &sql);
|
70
77
|
|
71
|
-
|
72
|
-
|
78
|
+
svcctx = oci8_get_svcctx(svc);
|
79
|
+
oci8_check_pid_consistency(svcctx);
|
80
|
+
if (argc > 1 && oracle_client_version >= ORAVER_9_2) {
|
73
81
|
OCI8SafeStringValue(sql);
|
74
82
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
83
|
+
rv = OCIStmtPrepare2(svcctx->base.hp.svc, &stmt->base.hp.stmt, oci8_errhp, RSTRING_ORATEXT(sql), RSTRING_LEN(sql), NULL, 0, OCI_NTV_SYNTAX, OCI_DEFAULT);
|
84
|
+
if (IS_OCI_ERROR(rv)) {
|
85
|
+
chker2(rv, &svcctx->base);
|
86
|
+
}
|
87
|
+
stmt->base.type = OCI_HTYPE_STMT;
|
88
|
+
stmt->use_stmt_release = 1;
|
89
|
+
} else {
|
90
|
+
rv = OCIHandleAlloc(oci8_envhp, &stmt->base.hp.ptr, OCI_HTYPE_STMT, 0, NULL);
|
91
|
+
if (rv != OCI_SUCCESS) {
|
92
|
+
oci8_env_raise(oci8_envhp, rv);
|
93
|
+
}
|
94
|
+
stmt->base.type = OCI_HTYPE_STMT;
|
95
|
+
if (argc > 1) {
|
96
|
+
OCI8SafeStringValue(sql);
|
97
|
+
rv = OCIStmtPrepare(stmt->base.hp.stmt, oci8_errhp, RSTRING_ORATEXT(sql), RSTRING_LEN(sql), OCI_NTV_SYNTAX, OCI_DEFAULT);
|
98
|
+
if (IS_OCI_ERROR(rv)) {
|
99
|
+
chker3(rv, &svcctx->base, stmt->base.hp.stmt);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
79
103
|
stmt->svc = svc;
|
80
104
|
stmt->binds = rb_hash_new();
|
81
105
|
stmt->defns = rb_ary_new();
|
@@ -84,12 +108,6 @@ static VALUE oci8_stmt_initialize(int argc, VALUE *argv, VALUE self)
|
|
84
108
|
rb_ivar_set(stmt->base.self, id_at_con, svc);
|
85
109
|
rb_ivar_set(stmt->base.self, id_at_max_array_size, Qnil);
|
86
110
|
|
87
|
-
if (argc > 1) {
|
88
|
-
rv = OCIStmtPrepare(stmt->base.hp.stmt, oci8_errhp, RSTRING_ORATEXT(sql), RSTRING_LEN(sql), OCI_NTV_SYNTAX, OCI_DEFAULT);
|
89
|
-
if (IS_OCI_ERROR(rv)) {
|
90
|
-
chker3(rv, &stmt->base, stmt->base.hp.stmt);
|
91
|
-
}
|
92
|
-
}
|
93
111
|
oci8_link_to_parent((oci8_base_t*)stmt, (oci8_base_t*)DATA_PTR(svc));
|
94
112
|
return Qnil;
|
95
113
|
}
|
data/ext/oci8/win32.c
CHANGED
@@ -13,6 +13,14 @@
|
|
13
13
|
#endif
|
14
14
|
#include <windows.h>
|
15
15
|
|
16
|
+
/*
|
17
|
+
* Document-module: OCI8::Win32Util
|
18
|
+
*
|
19
|
+
* Windows specific utility module.
|
20
|
+
*
|
21
|
+
* @private
|
22
|
+
*/
|
23
|
+
|
16
24
|
NORETURN(static void raise_error(void));
|
17
25
|
|
18
26
|
static void raise_error(void)
|
@@ -33,6 +41,11 @@ static void raise_error(void)
|
|
33
41
|
rb_raise(rb_eRuntimeError, "%s", msg);
|
34
42
|
}
|
35
43
|
|
44
|
+
/*
|
45
|
+
* Returns the full path of OCI.DLL used by the current process.
|
46
|
+
*
|
47
|
+
* @return [String]
|
48
|
+
*/
|
36
49
|
static VALUE dll_path(VALUE module)
|
37
50
|
{
|
38
51
|
HMODULE hModule;
|
@@ -120,6 +133,15 @@ static VALUE enum_homes_ensure(enum_homes_arg_t *arg)
|
|
120
133
|
return Qnil;
|
121
134
|
}
|
122
135
|
|
136
|
+
/*
|
137
|
+
* Enumerates full clients' Oracle homes and NLS_LANG parameters
|
138
|
+
* registerd in the Windows registry.
|
139
|
+
*
|
140
|
+
* @yield [oracle_home, nls_lang]
|
141
|
+
* @yieldparam [String] oracle_home
|
142
|
+
* @yieldparam [String] nls_lang
|
143
|
+
* @return [nil]
|
144
|
+
*/
|
123
145
|
static VALUE enum_homes(VALUE module)
|
124
146
|
{
|
125
147
|
enum_homes_arg_t arg;
|