ruby-oci8 2.2.3 → 2.2.12
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.
- checksums.yaml +7 -0
- data/ChangeLog +427 -0
- data/NEWS +335 -42
- data/README.md +20 -9
- data/dist-files +9 -3
- data/docs/bind-array-to-in_cond.md +2 -2
- data/docs/conflicts-local-connections-and-processes.md +7 -4
- data/docs/hanging-after-inactivity.md +63 -0
- data/docs/install-binary-package.md +15 -11
- data/docs/install-full-client.md +18 -21
- data/docs/install-instant-client.md +45 -27
- data/docs/install-on-osx.md +31 -120
- data/docs/ldap-auth-and-function-interposition.md +123 -0
- data/docs/number-type-mapping.md +79 -0
- data/docs/platform-specific-issues.md +17 -50
- data/docs/report-installation-issue.md +3 -0
- data/docs/timeout-parameters.md +3 -0
- data/ext/oci8/apiwrap.c.tmpl +2 -5
- data/ext/oci8/apiwrap.rb +6 -1
- data/ext/oci8/apiwrap.yml +34 -22
- data/ext/oci8/attr.c +4 -2
- data/ext/oci8/bind.c +366 -6
- data/ext/oci8/connection_pool.c +3 -3
- data/ext/oci8/encoding.c +5 -5
- data/ext/oci8/env.c +8 -2
- data/ext/oci8/error.c +24 -16
- data/ext/oci8/extconf.rb +8 -4
- data/ext/oci8/hook_funcs.c +274 -61
- data/ext/oci8/lob.c +31 -75
- data/ext/oci8/metadata.c +2 -2
- data/ext/oci8/object.c +72 -27
- data/ext/oci8/oci8.c +45 -132
- data/ext/oci8/oci8.h +32 -88
- data/ext/oci8/oci8lib.c +178 -38
- data/ext/oci8/ocihandle.c +37 -37
- data/ext/oci8/ocinumber.c +23 -18
- data/ext/oci8/oraconf.rb +158 -339
- data/ext/oci8/oradate.c +19 -19
- data/ext/oci8/plthook.h +10 -0
- data/ext/oci8/plthook_elf.c +433 -268
- data/ext/oci8/plthook_osx.c +40 -9
- data/ext/oci8/plthook_win32.c +9 -0
- data/ext/oci8/stmt.c +52 -17
- data/ext/oci8/win32.c +4 -22
- data/lib/oci8/bindtype.rb +1 -15
- data/lib/oci8/check_load_error.rb +57 -10
- data/lib/oci8/cursor.rb +57 -25
- data/lib/oci8/metadata.rb +9 -1
- data/lib/oci8/object.rb +10 -0
- data/lib/oci8/oci8.rb +33 -28
- data/lib/oci8/oracle_version.rb +11 -1
- data/lib/oci8/properties.rb +22 -0
- data/lib/oci8/version.rb +1 -1
- data/lib/oci8.rb +48 -4
- data/lib/ruby-oci8.rb +0 -3
- data/pre-distclean.rb +1 -3
- data/ruby-oci8.gemspec +3 -8
- data/setup.rb +11 -2
- data/test/README.md +37 -0
- data/test/config.rb +1 -1
- data/test/setup_test_object.sql +21 -13
- data/test/setup_test_package.sql +59 -0
- data/test/test_all.rb +2 -0
- data/test/test_bind_boolean.rb +99 -0
- data/test/test_bind_integer.rb +47 -0
- data/test/test_break.rb +11 -9
- data/test/test_clob.rb +4 -16
- data/test/test_connstr.rb +29 -13
- data/test/test_datetime.rb +8 -3
- data/test/test_object.rb +27 -9
- data/test/test_oci8.rb +170 -46
- data/test/test_oranumber.rb +12 -6
- data/test/test_package_type.rb +15 -3
- data/test/test_properties.rb +17 -0
- metadata +40 -54
- data/docs/osx-install-dev-tools.png +0 -0
- data/test/README +0 -42
data/ext/oci8/object.c
CHANGED
@@ -44,6 +44,8 @@ enum {
|
|
44
44
|
ATTR_FLOAT,
|
45
45
|
ATTR_INTEGER,
|
46
46
|
ATTR_OCIDATE,
|
47
|
+
ATTR_TIMESTAMP,
|
48
|
+
ATTR_TIMESTAMP_TZ,
|
47
49
|
ATTR_BINARY_DOUBLE,
|
48
50
|
ATTR_BINARY_FLOAT,
|
49
51
|
ATTR_NAMED_TYPE,
|
@@ -235,6 +237,10 @@ static VALUE get_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *dat
|
|
235
237
|
return oci8_make_integer((OCINumber *)data, oci8_errhp);
|
236
238
|
case ATTR_OCIDATE:
|
237
239
|
return oci8_make_ocidate((OCIDate *)data);
|
240
|
+
case ATTR_TIMESTAMP:
|
241
|
+
return oci8_make_ocitimestamp(*(OCIDateTime**)data, FALSE);
|
242
|
+
case ATTR_TIMESTAMP_TZ:
|
243
|
+
return oci8_make_ocitimestamp(*(OCIDateTime**)data, TRUE);
|
238
244
|
case ATTR_BINARY_DOUBLE:
|
239
245
|
return rb_float_new(*(double*)data);
|
240
246
|
case ATTR_BINARY_FLOAT:
|
@@ -413,6 +419,18 @@ static VALUE oci8_named_coll_set_coll_element(VALUE self, VALUE datatype, VALUE
|
|
413
419
|
case ATTR_OCIDATE:
|
414
420
|
cb_data.indp = &cb_data.ind;
|
415
421
|
break;
|
422
|
+
case ATTR_TIMESTAMP:
|
423
|
+
chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->hp.svc, OCI_TYPECODE_TIMESTAMP, NULL, NULL, OCI_DURATION_SESSION, TRUE, &cb_data.data.ptr),
|
424
|
+
svcctx);
|
425
|
+
chker2(OCIObjectGetInd(oci8_envhp, oci8_errhp, cb_data.data.ptr, (dvoid**)&cb_data.indp),
|
426
|
+
svcctx);
|
427
|
+
break;
|
428
|
+
case ATTR_TIMESTAMP_TZ:
|
429
|
+
chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->hp.svc, OCI_TYPECODE_TIMESTAMP_TZ, NULL, NULL, OCI_DURATION_SESSION, TRUE, &cb_data.data.ptr),
|
430
|
+
svcctx);
|
431
|
+
chker2(OCIObjectGetInd(oci8_envhp, oci8_errhp, cb_data.data.ptr, (dvoid**)&cb_data.indp),
|
432
|
+
svcctx);
|
433
|
+
break;
|
416
434
|
case ATTR_BINARY_DOUBLE:
|
417
435
|
cb_data.data.dbl = 0.0;
|
418
436
|
cb_data.indp = &cb_data.ind;
|
@@ -467,7 +485,7 @@ static VALUE set_coll_element_func(set_coll_element_cb_data_t *cb_data)
|
|
467
485
|
|
468
486
|
chkerr(OCICollSize(oci8_envhp, oci8_errhp, coll, &size));
|
469
487
|
if (RARRAY_LEN(val) < size) {
|
470
|
-
chkerr(OCICollTrim(oci8_envhp, oci8_errhp, size - RARRAY_LEN(val), coll));
|
488
|
+
chkerr(OCICollTrim(oci8_envhp, oci8_errhp, (sb4)(size - RARRAY_LEN(val)), coll));
|
471
489
|
}
|
472
490
|
for (idx = 0; idx < RARRAY_LEN(val); idx++) {
|
473
491
|
switch (FIX2INT(datatype)) {
|
@@ -507,6 +525,8 @@ static VALUE set_coll_element_ensure(set_coll_element_cb_data_t *cb_data)
|
|
507
525
|
switch (FIX2INT(datatype)) {
|
508
526
|
case ATTR_STRING:
|
509
527
|
case ATTR_RAW:
|
528
|
+
case ATTR_TIMESTAMP:
|
529
|
+
case ATTR_TIMESTAMP_TZ:
|
510
530
|
case ATTR_NAMED_TYPE:
|
511
531
|
case ATTR_NAMED_COLLECTION:
|
512
532
|
if (cb_data->data.ptr != NULL) {
|
@@ -539,13 +559,13 @@ static void set_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data
|
|
539
559
|
case ATTR_STRING:
|
540
560
|
OCI8StringValue(val);
|
541
561
|
chkerr(OCIStringAssignText(oci8_envhp, oci8_errhp,
|
542
|
-
RSTRING_ORATEXT(val),
|
562
|
+
RSTRING_ORATEXT(val), RSTRING_LENINT(val),
|
543
563
|
(OCIString **)data));
|
544
564
|
break;
|
545
565
|
case ATTR_RAW:
|
546
566
|
StringValue(val);
|
547
567
|
chkerr(OCIRawAssignBytes(oci8_envhp, oci8_errhp,
|
548
|
-
RSTRING_ORATEXT(val),
|
568
|
+
RSTRING_ORATEXT(val), RSTRING_LENINT(val),
|
549
569
|
(OCIRaw **)data));
|
550
570
|
break;
|
551
571
|
case ATTR_OCINUMBER:
|
@@ -558,6 +578,12 @@ static void set_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data
|
|
558
578
|
case ATTR_OCIDATE:
|
559
579
|
oci8_set_ocidate((OCIDate*)data, val);
|
560
580
|
break;
|
581
|
+
case ATTR_TIMESTAMP:
|
582
|
+
oci8_set_ocitimestamp_tz(*(OCIDateTime **)data, val, Qnil);
|
583
|
+
break;
|
584
|
+
case ATTR_TIMESTAMP_TZ:
|
585
|
+
oci8_set_ocitimestamp_tz(*(OCIDateTime **)data, val, Qnil);
|
586
|
+
break;
|
561
587
|
case ATTR_BINARY_DOUBLE:
|
562
588
|
*(double*)data = NUM2DBL(val);
|
563
589
|
break;
|
@@ -654,45 +680,57 @@ static VALUE oci8_named_collection_alloc(VALUE klass)
|
|
654
680
|
return oci8_allocate_typeddata(klass, &oci8_named_collection_data_type);
|
655
681
|
}
|
656
682
|
|
683
|
+
typedef struct {
|
684
|
+
oci8_bind_t bind;
|
685
|
+
VALUE *obj;
|
686
|
+
} bind_named_type_t;
|
687
|
+
|
657
688
|
static void bind_named_type_mark(oci8_base_t *base)
|
658
689
|
{
|
659
|
-
|
660
|
-
oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
|
690
|
+
bind_named_type_t *bnt = (bind_named_type_t *)base;
|
661
691
|
|
662
|
-
if (
|
692
|
+
if (bnt->obj != NULL) {
|
663
693
|
ub4 idx = 0;
|
664
694
|
|
665
695
|
do {
|
666
|
-
rb_gc_mark(
|
667
|
-
} while (++idx <
|
696
|
+
rb_gc_mark(bnt->obj[idx]);
|
697
|
+
} while (++idx < bnt->bind.maxar_sz);
|
668
698
|
}
|
669
|
-
rb_gc_mark(
|
699
|
+
rb_gc_mark(bnt->bind.tdo);
|
670
700
|
}
|
671
701
|
|
672
702
|
static void bind_named_type_free(oci8_base_t *base)
|
673
703
|
{
|
674
|
-
|
675
|
-
|
704
|
+
bind_named_type_t *bnt = (bind_named_type_t *)base;
|
705
|
+
void **hp = (void **)bnt->bind.valuep;
|
676
706
|
|
677
|
-
if (
|
707
|
+
if (hp != NULL) {
|
678
708
|
ub4 idx = 0;
|
679
709
|
|
680
710
|
do {
|
681
|
-
if (
|
682
|
-
OCIObjectFree(oci8_envhp, oci8_errhp,
|
683
|
-
|
711
|
+
if (hp[idx] != NULL) {
|
712
|
+
OCIObjectFree(oci8_envhp, oci8_errhp, hp[idx], OCI_DEFAULT);
|
713
|
+
hp[idx] = NULL;
|
684
714
|
}
|
685
|
-
} while (++idx <
|
715
|
+
} while (++idx < bnt->bind.maxar_sz);
|
716
|
+
}
|
717
|
+
if (bnt->obj != NULL) {
|
718
|
+
xfree(bnt->obj);
|
719
|
+
bnt->obj = NULL;
|
686
720
|
}
|
687
721
|
oci8_bind_free(base);
|
688
722
|
}
|
689
723
|
|
690
724
|
static VALUE bind_named_type_get(oci8_bind_t *obind, void *data, void *null_struct)
|
691
725
|
{
|
692
|
-
|
693
|
-
|
726
|
+
bind_named_type_t *bnt = (bind_named_type_t *)obind;
|
727
|
+
ub4 idx = obind->curar_idx;
|
728
|
+
|
729
|
+
return bnt->obj[idx];
|
694
730
|
}
|
695
731
|
|
732
|
+
NORETURN(static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val));
|
733
|
+
|
696
734
|
static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
|
697
735
|
{
|
698
736
|
rb_raise(rb_eRuntimeError, "not supported");
|
@@ -700,10 +738,12 @@ static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_stru
|
|
700
738
|
|
701
739
|
static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
702
740
|
{
|
741
|
+
bind_named_type_t *bnt = (bind_named_type_t *)obind;
|
703
742
|
VALUE tdo_obj = length;
|
704
743
|
|
705
744
|
obind->value_sz = sizeof(void*);
|
706
|
-
obind->alloc_sz = sizeof(
|
745
|
+
obind->alloc_sz = sizeof(void*);
|
746
|
+
bnt->obj = xcalloc(sizeof(VALUE), obind->maxar_sz ? obind->maxar_sz : 1);
|
707
747
|
|
708
748
|
CHECK_TDO(tdo_obj);
|
709
749
|
RB_OBJ_WRITE(obind->base.self, &obind->tdo, tdo_obj);
|
@@ -711,7 +751,8 @@ static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE
|
|
711
751
|
|
712
752
|
static void bind_named_type_init_elem(oci8_bind_t *obind, VALUE svc)
|
713
753
|
{
|
714
|
-
|
754
|
+
bind_named_type_t *bnt = (bind_named_type_t *)obind;
|
755
|
+
void **hp = (void **)obind->valuep;
|
715
756
|
oci8_base_t *tdo = DATA_PTR(obind->tdo);
|
716
757
|
OCITypeCode tc = OCITypeTypeCode(oci8_envhp, oci8_errhp, tdo->hp.tdo);
|
717
758
|
VALUE klass = Qnil;
|
@@ -729,14 +770,14 @@ static void bind_named_type_init_elem(oci8_bind_t *obind, VALUE svc)
|
|
729
770
|
}
|
730
771
|
svcctx = oci8_get_svcctx(svc);
|
731
772
|
do {
|
732
|
-
|
733
|
-
RB_OBJ_WRITTEN(obind->base.self, Qundef,
|
734
|
-
obj = DATA_PTR(
|
735
|
-
RB_OBJ_WRITE(
|
736
|
-
obj->instancep = (char**)&
|
773
|
+
bnt->obj[idx] = rb_class_new_instance(0, NULL, klass);
|
774
|
+
RB_OBJ_WRITTEN(obind->base.self, Qundef, bnt->obj[idx]);
|
775
|
+
obj = DATA_PTR(bnt->obj[idx]);
|
776
|
+
RB_OBJ_WRITE(bnt->obj[idx], &obj->tdo, obind->tdo);
|
777
|
+
obj->instancep = (char**)&hp[idx];
|
737
778
|
obj->null_structp = (char**)&obind->u.null_structs[idx];
|
738
779
|
oci8_link_to_parent(&obj->base, &obind->base);
|
739
|
-
RB_OBJ_WRITTEN(
|
780
|
+
RB_OBJ_WRITTEN(bnt->obj[idx], Qundef, obind->base.self);
|
740
781
|
|
741
782
|
chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->base.hp.svc, tc, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, (dvoid**)obj->instancep),
|
742
783
|
&svcctx->base);
|
@@ -778,7 +819,7 @@ static const oci8_bind_data_type_t bind_named_type_data_type = {
|
|
778
819
|
#endif
|
779
820
|
},
|
780
821
|
bind_named_type_free,
|
781
|
-
sizeof(
|
822
|
+
sizeof(bind_named_type_t)
|
782
823
|
},
|
783
824
|
bind_named_type_get,
|
784
825
|
bind_named_type_set,
|
@@ -818,6 +859,10 @@ void Init_oci_object(VALUE cOCI8)
|
|
818
859
|
/* @private */
|
819
860
|
rb_define_const(cOCI8TDO, "ATTR_OCIDATE", INT2FIX(ATTR_OCIDATE));
|
820
861
|
/* @private */
|
862
|
+
rb_define_const(cOCI8TDO, "ATTR_TIMESTAMP", INT2FIX(ATTR_TIMESTAMP));
|
863
|
+
/* @private */
|
864
|
+
rb_define_const(cOCI8TDO, "ATTR_TIMESTAMP_TZ", INT2FIX(ATTR_TIMESTAMP_TZ));
|
865
|
+
/* @private */
|
821
866
|
rb_define_const(cOCI8TDO, "ATTR_BINARY_DOUBLE", INT2FIX(ATTR_BINARY_DOUBLE));
|
822
867
|
/* @private */
|
823
868
|
rb_define_const(cOCI8TDO, "ATTR_BINARY_FLOAT", INT2FIX(ATTR_BINARY_FLOAT));
|
data/ext/oci8/oci8.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* oci8.c - part of ruby-oci8
|
4
4
|
*
|
5
|
-
* Copyright (C) 2002-
|
5
|
+
* Copyright (C) 2002-2019 Kubo Takehiro <kubo@jiubao.org>
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
#include "oci8.h"
|
@@ -286,7 +286,7 @@ static VALUE oci8_s_oracle_client_vernum(VALUE klass)
|
|
286
286
|
/*
|
287
287
|
* @overload OCI8.__get_prop(key)
|
288
288
|
*
|
289
|
-
* @param [
|
289
|
+
* @param [Integer] key 1, 2 or 3
|
290
290
|
* @return [Object] depends on +key+.
|
291
291
|
* @private
|
292
292
|
*/
|
@@ -306,16 +306,13 @@ static VALUE oci8_s_get_prop(VALUE klass, VALUE key)
|
|
306
306
|
/*
|
307
307
|
* @overload OCI8.__set_prop(key, value)
|
308
308
|
*
|
309
|
-
* @param [
|
309
|
+
* @param [Integer] key 1, 2 or 3
|
310
310
|
* @param [Object] value depends on +key+.
|
311
311
|
*
|
312
312
|
* @private
|
313
313
|
*/
|
314
314
|
static VALUE oci8_s_set_prop(VALUE klass, VALUE key, VALUE val)
|
315
315
|
{
|
316
|
-
#ifdef HAVE_PLTHOOK
|
317
|
-
static int hook_functions_installed = 0;
|
318
|
-
#endif
|
319
316
|
switch (NUM2INT(key)) {
|
320
317
|
case 1:
|
321
318
|
oci8_float_conversion_type_is_ruby = RTEST(val) ? 1 : 0;
|
@@ -331,13 +328,21 @@ static VALUE oci8_s_set_prop(VALUE klass, VALUE key, VALUE val)
|
|
331
328
|
oci8_env_mode = NUM2UINT(val);
|
332
329
|
break;
|
333
330
|
case 3:
|
331
|
+
if (oci8_cancel_read_at_exit == -1) {
|
332
|
+
rb_raise(rb_eNotImpError, "OCI8.properties[:cancel_read_at_exit] isn't available.");
|
333
|
+
}
|
334
334
|
#ifdef HAVE_PLTHOOK
|
335
|
-
|
336
|
-
|
337
|
-
|
335
|
+
oci8_install_hook_functions();
|
336
|
+
oci8_cancel_read_at_exit = RTEST(val) ? 1 : 0;
|
337
|
+
#endif
|
338
|
+
break;
|
339
|
+
case 4:
|
340
|
+
if (oci8_tcp_keepalive_time == -1) {
|
341
|
+
rb_raise(rb_eNotImpError, "OCI8.properties[:tcp_keepalive_time] isn't available.");
|
338
342
|
}
|
339
|
-
#
|
340
|
-
|
343
|
+
#ifdef HAVE_PLTHOOK
|
344
|
+
oci8_install_hook_functions();
|
345
|
+
oci8_tcp_keepalive_time = NIL_P(val) ? 0 : NUM2INT(val);
|
341
346
|
#endif
|
342
347
|
break;
|
343
348
|
default:
|
@@ -359,7 +364,7 @@ static VALUE oci8_s_set_prop(VALUE klass, VALUE key, VALUE val)
|
|
359
364
|
* # When NLS_LANG is FRENCH_FRANCE.AL32UTF8
|
360
365
|
* OCI8.error_message(1) # => "ORA-00001: violation de contrainte unique (%s.%s)"
|
361
366
|
*
|
362
|
-
* @param [
|
367
|
+
* @param [Integer] message_no Oracle error message number
|
363
368
|
* @return [String] Oracle error message
|
364
369
|
*/
|
365
370
|
static VALUE oci8_s_error_message(VALUE klass, VALUE msgid)
|
@@ -419,49 +424,6 @@ static VALUE oci8_parse_connect_string(VALUE self, VALUE conn_str)
|
|
419
424
|
return rb_ary_new3(4, user, pass, dbname, mode);
|
420
425
|
}
|
421
426
|
|
422
|
-
/*
|
423
|
-
* Logoff strategy for sessions connected by OCILogon.
|
424
|
-
*/
|
425
|
-
typedef struct {
|
426
|
-
OCISvcCtx *svchp;
|
427
|
-
OCISession *usrhp;
|
428
|
-
OCIServer *srvhp;
|
429
|
-
} simple_logoff_arg_t;
|
430
|
-
|
431
|
-
static void *simple_logoff_prepare(oci8_svcctx_t *svcctx)
|
432
|
-
{
|
433
|
-
simple_logoff_arg_t *sla = xmalloc(sizeof(simple_logoff_arg_t));
|
434
|
-
sla->svchp = svcctx->base.hp.svc;
|
435
|
-
sla->usrhp = svcctx->usrhp;
|
436
|
-
sla->srvhp = svcctx->srvhp;
|
437
|
-
svcctx->usrhp = NULL;
|
438
|
-
svcctx->srvhp = NULL;
|
439
|
-
return sla;
|
440
|
-
}
|
441
|
-
|
442
|
-
static void *simple_logoff_execute(void *arg)
|
443
|
-
{
|
444
|
-
simple_logoff_arg_t *sla = (simple_logoff_arg_t *)arg;
|
445
|
-
OCIError *errhp = oci8_errhp;
|
446
|
-
boolean txn = TRUE;
|
447
|
-
sword rv;
|
448
|
-
|
449
|
-
if (oracle_client_version >= ORAVER_12_1) {
|
450
|
-
OCIAttrGet(sla->usrhp, OCI_HTYPE_SESSION, &txn, NULL, OCI_ATTR_TRANSACTION_IN_PROGRESS, errhp);
|
451
|
-
}
|
452
|
-
if (txn) {
|
453
|
-
OCITransRollback(sla->svchp, errhp, OCI_DEFAULT);
|
454
|
-
}
|
455
|
-
rv = OCILogoff(sla->svchp, errhp);
|
456
|
-
xfree(sla);
|
457
|
-
return (void*)(VALUE)rv;
|
458
|
-
}
|
459
|
-
|
460
|
-
static const oci8_logoff_strategy_t simple_logoff = {
|
461
|
-
simple_logoff_prepare,
|
462
|
-
simple_logoff_execute,
|
463
|
-
};
|
464
|
-
|
465
427
|
/*
|
466
428
|
* Logoff strategy for sessions connected by OCIServerAttach and OCISessionBegin.
|
467
429
|
*/
|
@@ -526,61 +488,6 @@ static const oci8_logoff_strategy_t complex_logoff = {
|
|
526
488
|
complex_logoff_execute,
|
527
489
|
};
|
528
490
|
|
529
|
-
/*
|
530
|
-
* @overload logon2(username, password, dbname, mode)
|
531
|
-
*
|
532
|
-
* Creates a simple logon session by the OCI function OCILogon2().
|
533
|
-
*
|
534
|
-
* @param [String] username
|
535
|
-
* @param [String] password
|
536
|
-
* @param [String] dbname
|
537
|
-
* @param [Integer] mode
|
538
|
-
* @private
|
539
|
-
*/
|
540
|
-
static VALUE oci8_logon2(VALUE self, VALUE username, VALUE password, VALUE dbname, VALUE mode)
|
541
|
-
{
|
542
|
-
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
543
|
-
ub4 logon2_mode;
|
544
|
-
|
545
|
-
if (svcctx->logoff_strategy != NULL) {
|
546
|
-
rb_raise(rb_eRuntimeError, "Could not reuse the session.");
|
547
|
-
}
|
548
|
-
|
549
|
-
/* check arugmnets */
|
550
|
-
OCI8SafeStringValue(username);
|
551
|
-
OCI8SafeStringValue(password);
|
552
|
-
if (!NIL_P(dbname)) {
|
553
|
-
OCI8SafeStringValue(dbname);
|
554
|
-
}
|
555
|
-
logon2_mode = NUM2UINT(mode);
|
556
|
-
|
557
|
-
/* logon */
|
558
|
-
svcctx->base.type = OCI_HTYPE_SVCCTX;
|
559
|
-
chker2(OCILogon2_nb(svcctx, oci8_envhp, oci8_errhp, &svcctx->base.hp.svc,
|
560
|
-
RSTRING_ORATEXT(username), RSTRING_LEN(username),
|
561
|
-
RSTRING_ORATEXT(password), RSTRING_LEN(password),
|
562
|
-
NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
|
563
|
-
NIL_P(dbname) ? 0 : RSTRING_LEN(dbname), logon2_mode),
|
564
|
-
&svcctx->base);
|
565
|
-
svcctx->logoff_strategy = &simple_logoff;
|
566
|
-
|
567
|
-
if (logon2_mode & OCI_LOGON2_CPOOL) {
|
568
|
-
svcctx->state |= OCI8_STATE_CPOOL;
|
569
|
-
}
|
570
|
-
|
571
|
-
/* setup the session handle */
|
572
|
-
chker2(OCIAttrGet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX, &svcctx->usrhp, 0, OCI_ATTR_SESSION, oci8_errhp),
|
573
|
-
&svcctx->base);
|
574
|
-
copy_session_handle(svcctx);
|
575
|
-
|
576
|
-
/* setup the server handle */
|
577
|
-
chker2(OCIAttrGet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX, &svcctx->srvhp, 0, OCI_ATTR_SERVER, oci8_errhp),
|
578
|
-
&svcctx->base);
|
579
|
-
copy_server_handle(svcctx);
|
580
|
-
|
581
|
-
return Qnil;
|
582
|
-
}
|
583
|
-
|
584
491
|
/*
|
585
492
|
* @overload allocate_handles()
|
586
493
|
*
|
@@ -649,7 +556,7 @@ static VALUE oci8_server_attach(VALUE self, VALUE dbname, VALUE attach_mode)
|
|
649
556
|
/* attach to the server */
|
650
557
|
chker2(OCIServerAttach_nb(svcctx, svcctx->srvhp, oci8_errhp,
|
651
558
|
NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
|
652
|
-
NIL_P(dbname) ? 0 :
|
559
|
+
NIL_P(dbname) ? 0 : RSTRING_LENINT(dbname),
|
653
560
|
mode),
|
654
561
|
&svcctx->base);
|
655
562
|
chker2(OCIAttrSet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX,
|
@@ -668,13 +575,15 @@ static VALUE oci8_server_attach(VALUE self, VALUE dbname, VALUE attach_mode)
|
|
668
575
|
*
|
669
576
|
* Begins the session by the OCI function OCISessionBegin().
|
670
577
|
*
|
671
|
-
* @param [
|
672
|
-
* @param [
|
578
|
+
* @param [Integer] cred
|
579
|
+
* @param [Integer] mode
|
673
580
|
* @private
|
674
581
|
*/
|
675
582
|
static VALUE oci8_session_begin(VALUE self, VALUE cred, VALUE mode)
|
676
583
|
{
|
677
584
|
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
585
|
+
char buf[100];
|
586
|
+
ub4 version;
|
678
587
|
|
679
588
|
if (svcctx->logoff_strategy != &complex_logoff) {
|
680
589
|
rb_raise(rb_eRuntimeError, "Use this method only for the service context handle created by OCI8#server_handle().");
|
@@ -697,6 +606,16 @@ static VALUE oci8_session_begin(VALUE self, VALUE cred, VALUE mode)
|
|
697
606
|
oci8_errhp),
|
698
607
|
&svcctx->base);
|
699
608
|
svcctx->state |= OCI8_STATE_SESSION_BEGIN_WAS_CALLED;
|
609
|
+
if (have_OCIServerRelease2) {
|
610
|
+
chker2(OCIServerRelease2(svcctx->base.hp.ptr, oci8_errhp, (text*)buf,
|
611
|
+
sizeof(buf), (ub1)svcctx->base.type, &version, OCI_DEFAULT),
|
612
|
+
&svcctx->base);
|
613
|
+
} else {
|
614
|
+
chker2(OCIServerRelease(svcctx->base.hp.ptr, oci8_errhp, (text*)buf,
|
615
|
+
sizeof(buf), (ub1)svcctx->base.type, &version),
|
616
|
+
&svcctx->base);
|
617
|
+
}
|
618
|
+
svcctx->server_version = version;
|
700
619
|
return Qnil;
|
701
620
|
}
|
702
621
|
|
@@ -815,14 +734,9 @@ static VALUE oci8_set_autocommit(VALUE self, VALUE val)
|
|
815
734
|
/*
|
816
735
|
* @overload long_read_len
|
817
736
|
*
|
818
|
-
*
|
819
|
-
*
|
820
|
-
*
|
821
|
-
* If the actual data length is longer than long_read_len,
|
822
|
-
* the fetched valud is truncated and the value of {OCI8#last_error}
|
823
|
-
* become {OCISuccessWithInfo} whose message is "ORA-01406: fetched column value was truncated".
|
824
|
-
*
|
825
|
-
* Note: long_read_len is also used for maximum length of XMLTYPE data type.
|
737
|
+
* @deprecated This has no effect since ruby-oci8 2.2.7.
|
738
|
+
* LONG, LONG RAW and XMLTYPE columns are fetched up to 4 gigabytes
|
739
|
+
* without this parameter.
|
826
740
|
*
|
827
741
|
* @return [Integer]
|
828
742
|
* @see #long_read_len=
|
@@ -830,14 +744,16 @@ static VALUE oci8_set_autocommit(VALUE self, VALUE val)
|
|
830
744
|
static VALUE oci8_long_read_len(VALUE self)
|
831
745
|
{
|
832
746
|
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
747
|
+
rb_warning("OCI8.long_read_len has no effect since ruby-oci8 2.2.7");
|
833
748
|
return svcctx->long_read_len;
|
834
749
|
}
|
835
750
|
|
836
751
|
/*
|
837
752
|
* @overload long_read_len=(length)
|
838
753
|
*
|
839
|
-
*
|
840
|
-
*
|
754
|
+
* @deprecated This has no effect since ruby-oci8 2.2.7.
|
755
|
+
* LONG, LONG RAW and XMLTYPE columns are fetched up to 4 gigabytes
|
756
|
+
* without this parameter.
|
841
757
|
*
|
842
758
|
* @param [Integer] length
|
843
759
|
* @see #long_read_len
|
@@ -847,6 +763,7 @@ static VALUE oci8_set_long_read_len(VALUE self, VALUE val)
|
|
847
763
|
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
848
764
|
Check_Type(val, T_FIXNUM);
|
849
765
|
RB_OBJ_WRITE(self, &svcctx->long_read_len, val);
|
766
|
+
rb_warning("OCI8.long_read_len= has no effect since ruby-oci8 2.2.7");
|
850
767
|
return val;
|
851
768
|
}
|
852
769
|
|
@@ -889,11 +806,8 @@ static VALUE oci8_break(VALUE self)
|
|
889
806
|
static VALUE oci8_oracle_server_vernum(VALUE self)
|
890
807
|
{
|
891
808
|
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
892
|
-
char buf[100];
|
893
|
-
ub4 version;
|
894
809
|
|
895
|
-
|
896
|
-
return UINT2NUM(version);
|
810
|
+
return UINT2NUM(svcctx->server_version);
|
897
811
|
}
|
898
812
|
|
899
813
|
/*
|
@@ -950,7 +864,7 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
|
|
950
864
|
if (!NIL_P(val)) {
|
951
865
|
OCI8SafeStringValue(val);
|
952
866
|
ptr = RSTRING_PTR(val);
|
953
|
-
size =
|
867
|
+
size = RSTRING_LENINT(val);
|
954
868
|
} else {
|
955
869
|
ptr = "";
|
956
870
|
size = 0;
|
@@ -985,7 +899,7 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
|
|
985
899
|
if (!NIL_P(val)) {
|
986
900
|
OCI8SafeStringValue(val);
|
987
901
|
ptr = RSTRING_PTR(val);
|
988
|
-
size =
|
902
|
+
size = RSTRING_LENINT(val);
|
989
903
|
} else {
|
990
904
|
ptr = "";
|
991
905
|
size = 0;
|
@@ -1019,7 +933,7 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
|
|
1019
933
|
if (!NIL_P(val)) {
|
1020
934
|
OCI8SafeStringValue(val);
|
1021
935
|
ptr = RSTRING_PTR(val);
|
1022
|
-
size =
|
936
|
+
size = RSTRING_LENINT(val);
|
1023
937
|
} else {
|
1024
938
|
ptr = "";
|
1025
939
|
size = 0;
|
@@ -1050,7 +964,7 @@ static VALUE oci8_set_client_info(VALUE self, VALUE val)
|
|
1050
964
|
if (!NIL_P(val)) {
|
1051
965
|
OCI8SafeStringValue(val);
|
1052
966
|
ptr = RSTRING_PTR(val);
|
1053
|
-
size =
|
967
|
+
size = RSTRING_LENINT(val);
|
1054
968
|
} else {
|
1055
969
|
ptr = "";
|
1056
970
|
size = 0;
|
@@ -1102,7 +1016,6 @@ void Init_oci8(VALUE *out)
|
|
1102
1016
|
rb_define_singleton_method_nodoc(cOCI8, "__set_prop", oci8_s_set_prop, 2);
|
1103
1017
|
rb_define_singleton_method(cOCI8, "error_message", oci8_s_error_message, 1);
|
1104
1018
|
rb_define_private_method(cOCI8, "parse_connect_string", oci8_parse_connect_string, 1);
|
1105
|
-
rb_define_private_method(cOCI8, "logon2", oci8_logon2, 4);
|
1106
1019
|
rb_define_private_method(cOCI8, "allocate_handles", oci8_allocate_handles, 0);
|
1107
1020
|
rb_define_private_method(cOCI8, "server_attach", oci8_server_attach, 2);
|
1108
1021
|
rb_define_private_method(cOCI8, "session_begin", oci8_session_begin, 2);
|