ruby-oci8 2.2.6.1 → 2.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -144,13 +144,13 @@ static VALUE oci8_cpool_initialize(int argc, VALUE *argv, VALUE self)
144
144
  chker2(OCIConnectionPoolCreate(oci8_envhp, oci8_errhp, cpool->base.hp.poolhp,
145
145
  &pool_name, &pool_name_len,
146
146
  NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
147
- NIL_P(dbname) ? 0 : RSTRING_LEN(dbname),
147
+ NIL_P(dbname) ? 0 : RSTRING_LENINT(dbname),
148
148
  FIX2UINT(conn_min), FIX2UINT(conn_max),
149
149
  FIX2UINT(conn_incr),
150
150
  NIL_P(username) ? NULL : RSTRING_ORATEXT(username),
151
- NIL_P(username) ? 0 : RSTRING_LEN(username),
151
+ NIL_P(username) ? 0 : RSTRING_LENINT(username),
152
152
  NIL_P(password) ? NULL : RSTRING_ORATEXT(password),
153
- NIL_P(password) ? 0 : RSTRING_LEN(password),
153
+ NIL_P(password) ? 0 : RSTRING_LENINT(password),
154
154
  OCI_DEFAULT),
155
155
  &cpool->base);
156
156
  RB_OBJ_WRITE(cpool->base.self, &cpool->pool_name, rb_str_new(TO_CHARPTR(pool_name), pool_name_len));
data/ext/oci8/extconf.rb CHANGED
@@ -139,6 +139,8 @@ when 'rbx'
139
139
  so_basename += 'rbx'
140
140
  when 'jruby'
141
141
  raise "Ruby-oci8 doesn't support jruby because its C extension support is in development in jruby 1.6 and deprecated in jruby 1.7."
142
+ when 'truffleruby'
143
+ so_basename += 'truffleruby'
142
144
  else
143
145
  raise 'unsupported ruby engine: ' + RUBY_ENGINE
144
146
  end
@@ -153,8 +155,9 @@ when /darwin/
153
155
  else
154
156
  plthook_src = "plthook_elf.c"
155
157
  end
156
- if xsystem(cc_command("").gsub(CONFTEST_C, File.dirname(__FILE__) + "/" + plthook_src))
157
- File.delete(plthook_src.gsub(/\.c$/, '.' + RbConfig::CONFIG["OBJEXT"]))
158
+ FileUtils.copy(File.dirname(__FILE__) + "/" + plthook_src, CONFTEST_C)
159
+ if xsystem(cc_command(""))
160
+ FileUtils.rm_f("#{CONFTEST}.#{$OBJEXT}")
158
161
  puts plthook_src
159
162
  $objs << plthook_src.gsub(/\.c$/, '.o')
160
163
  $objs << "hook_funcs.o"
@@ -298,13 +298,28 @@ static void *ocifunc_addr(void *dlsym_handle, const char **file)
298
298
  if (dladdr(addr, &dli) == 0) {
299
299
  return NULL;
300
300
  }
301
- if (strstr(dli.dli_fname, "/libclntsh." SO_EXT) == 0) {
301
+ if (strstr(dli.dli_fname, "/libclntsh." SO_EXT) == NULL) {
302
302
  return NULL;
303
303
  }
304
304
  *file = dli.dli_fname;
305
305
  return addr;
306
306
  }
307
307
 
308
+ #ifdef __linux__
309
+ #include <link.h>
310
+ static void *ocifunc_addr_linux(const char **file)
311
+ {
312
+ struct link_map *lm;
313
+ for (lm = _r_debug.r_map; lm != NULL; lm = lm->l_next) {
314
+ if (strstr(lm->l_name, "/libclntsh." SO_EXT) != NULL) {
315
+ *file = lm->l_name;
316
+ return (void*)lm->l_addr;
317
+ }
318
+ }
319
+ return NULL;
320
+ }
321
+ #endif
322
+
308
323
  void oci8_install_hook_functions(void)
309
324
  {
310
325
  static int hook_functions_installed = 0;
@@ -319,6 +334,11 @@ void oci8_install_hook_functions(void)
319
334
  /* OCI symbols may be hooked by LD_PRELOAD. */
320
335
  addr = ocifunc_addr(RTLD_NEXT, &file);
321
336
  }
337
+ #ifdef __linux__
338
+ if (addr == NULL) {
339
+ addr = ocifunc_addr_linux(&file);
340
+ }
341
+ #endif
322
342
  if (addr == NULL) {
323
343
  rb_raise(rb_eRuntimeError, "No shared library is found to hook.");
324
344
  }
data/ext/oci8/lob.c CHANGED
@@ -639,10 +639,9 @@ static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
639
639
  {
640
640
  oci8_lob_t *lob = TO_LOB(self);
641
641
  oci8_svcctx_t *svcctx = check_svcctx(lob);
642
- ub8 lob_length;
643
- ub8 read_len;
644
642
  ub8 pos = lob->pos;
645
- long strbufsiz;
643
+ long strbufsiz = 512;
644
+ ub8 sz;
646
645
  ub8 byte_amt;
647
646
  ub8 char_amt;
648
647
  sword rv;
@@ -652,36 +651,21 @@ static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
652
651
  ub1 piece = OCI_FIRST_PIECE;
653
652
 
654
653
  rb_scan_args(argc, argv, "01", &size);
655
- lob_length = oci8_lob_get_length(lob);
656
- if (lob_length == 0 && NIL_P(size)) {
657
- return rb_usascii_str_new("", 0);
658
- }
659
- if (lob_length <= pos) /* EOF */
660
- return Qnil;
661
654
  if (NIL_P(size)) {
662
- read_len = lob_length - pos;
655
+ sz = UB4MAXVAL;
663
656
  } else {
664
- ub8 sz = NUM2ULL(size);
665
- read_len = MIN(sz, lob_length - pos);
657
+ sz = NUM2ULL(size);
658
+ }
659
+ if (lob->state == S_BFILE_CLOSE) {
660
+ open_bfile(svcctx, lob, errhp);
666
661
  }
662
+ read_more_data:
667
663
  if (lob->lobtype == OCI_TEMP_CLOB) {
668
664
  byte_amt = 0;
669
- char_amt = read_len;
670
- if (oci8_nls_ratio == 1) {
671
- strbufsiz = MIN(read_len, ULONG_MAX);
672
- } else {
673
- strbufsiz = MIN(read_len + read_len / 8, ULONG_MAX);
674
- }
675
- if (strbufsiz <= 10) {
676
- strbufsiz = 10;
677
- }
665
+ char_amt = sz;
678
666
  } else {
679
- byte_amt = read_len;
667
+ byte_amt = sz;
680
668
  char_amt = 0;
681
- strbufsiz = MIN(read_len, ULONG_MAX);
682
- }
683
- if (lob->state == S_BFILE_CLOSE) {
684
- open_bfile(svcctx, lob, errhp);
685
669
  }
686
670
  do {
687
671
  VALUE strbuf = rb_str_buf_new(strbufsiz);
@@ -711,22 +695,30 @@ static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
711
695
  }
712
696
  rb_str_set_len(strbuf, byte_amt);
713
697
  rb_ary_push(v, strbuf);
698
+ if (strbufsiz < 128 * 1024 * 1024) {
699
+ strbufsiz *= 2;
700
+ }
714
701
  } while (rv == OCI_NEED_DATA);
715
702
 
716
- if (pos >= lob_length) {
717
- bfile_close(lob);
703
+ if (NIL_P(size) && pos - lob->pos == sz) {
704
+ lob->pos = pos;
705
+ piece = OCI_FIRST_PIECE;
706
+ goto read_more_data;
718
707
  }
719
708
  lob->pos = pos;
720
709
  switch (RARRAY_LEN(v)) {
721
710
  case 0:
722
- return Qnil;
711
+ if (NIL_P(size) && pos == 0) {
712
+ return rb_usascii_str_new("", 0);
713
+ } else {
714
+ return Qnil;
715
+ }
723
716
  case 1:
724
717
  v = RARRAY_AREF(v, 0);
725
718
  break;
726
719
  default:
727
720
  v = rb_ary_join(v, Qnil);
728
721
  }
729
- OBJ_TAINT(v);
730
722
  if (lob->lobtype == OCI_TEMP_CLOB) {
731
723
  /* set encoding */
732
724
  rb_enc_associate(v, oci8_encoding);
@@ -773,10 +765,10 @@ static VALUE oci8_lob_write(VALUE self, VALUE data)
773
765
  RB_GC_GUARD(str);
774
766
  if (lob->lobtype == OCI_TEMP_CLOB) {
775
767
  lob->pos += char_amt;
776
- return UINT2NUM(char_amt);
768
+ return ULL2NUM(char_amt);
777
769
  } else {
778
770
  lob->pos += byte_amt;
779
- return UINT2NUM(byte_amt);
771
+ return ULL2NUM(byte_amt);
780
772
  }
781
773
  }
782
774
 
data/ext/oci8/metadata.c CHANGED
@@ -195,7 +195,7 @@ VALUE oci8_do_describe(VALUE self, void *objptr, ub4 objlen, ub1 objtype, VALUE
195
195
  static VALUE oci8_describe(VALUE self, VALUE name, VALUE klass, VALUE check_public)
196
196
  {
197
197
  char *str;
198
- size_t idx, len;
198
+ int idx, len;
199
199
  VALUE metadata;
200
200
  VALUE obj_link = Qnil;
201
201
 
@@ -204,7 +204,7 @@ static VALUE oci8_describe(VALUE self, VALUE name, VALUE klass, VALUE check_publ
204
204
  rb_raise(rb_eArgError, "empty string is set.");
205
205
  }
206
206
  str = RSTRING_PTR(name);
207
- len = RSTRING_LEN(name);
207
+ len = RSTRING_LENINT(name);
208
208
  for (idx = 0; idx < len; idx++) {
209
209
  if (str[idx] == '@') {
210
210
  obj_link = rb_enc_str_new(str + idx + 1, len - idx - 1, oci8_encoding);
data/ext/oci8/object.c CHANGED
@@ -485,7 +485,7 @@ static VALUE set_coll_element_func(set_coll_element_cb_data_t *cb_data)
485
485
 
486
486
  chkerr(OCICollSize(oci8_envhp, oci8_errhp, coll, &size));
487
487
  if (RARRAY_LEN(val) < size) {
488
- chkerr(OCICollTrim(oci8_envhp, oci8_errhp, size - RARRAY_LEN(val), coll));
488
+ chkerr(OCICollTrim(oci8_envhp, oci8_errhp, (sb4)(size - RARRAY_LEN(val)), coll));
489
489
  }
490
490
  for (idx = 0; idx < RARRAY_LEN(val); idx++) {
491
491
  switch (FIX2INT(datatype)) {
@@ -559,13 +559,13 @@ static void set_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data
559
559
  case ATTR_STRING:
560
560
  OCI8StringValue(val);
561
561
  chkerr(OCIStringAssignText(oci8_envhp, oci8_errhp,
562
- RSTRING_ORATEXT(val), RSTRING_LEN(val),
562
+ RSTRING_ORATEXT(val), RSTRING_LENINT(val),
563
563
  (OCIString **)data));
564
564
  break;
565
565
  case ATTR_RAW:
566
566
  StringValue(val);
567
567
  chkerr(OCIRawAssignBytes(oci8_envhp, oci8_errhp,
568
- RSTRING_ORATEXT(val), RSTRING_LEN(val),
568
+ RSTRING_ORATEXT(val), RSTRING_LENINT(val),
569
569
  (OCIRaw **)data));
570
570
  break;
571
571
  case ATTR_OCINUMBER:
@@ -680,45 +680,57 @@ static VALUE oci8_named_collection_alloc(VALUE klass)
680
680
  return oci8_allocate_typeddata(klass, &oci8_named_collection_data_type);
681
681
  }
682
682
 
683
+ typedef struct {
684
+ oci8_bind_t bind;
685
+ VALUE *obj;
686
+ } bind_named_type_t;
687
+
683
688
  static void bind_named_type_mark(oci8_base_t *base)
684
689
  {
685
- oci8_bind_t *obind = (oci8_bind_t *)base;
686
- oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
690
+ bind_named_type_t *bnt = (bind_named_type_t *)base;
687
691
 
688
- if (oho != NULL) {
692
+ if (bnt->obj != NULL) {
689
693
  ub4 idx = 0;
690
694
 
691
695
  do {
692
- rb_gc_mark(oho[idx].obj);
693
- } while (++idx < obind->maxar_sz);
696
+ rb_gc_mark(bnt->obj[idx]);
697
+ } while (++idx < bnt->bind.maxar_sz);
694
698
  }
695
- rb_gc_mark(obind->tdo);
699
+ rb_gc_mark(bnt->bind.tdo);
696
700
  }
697
701
 
698
702
  static void bind_named_type_free(oci8_base_t *base)
699
703
  {
700
- oci8_bind_t *obind = (oci8_bind_t *)base;
701
- oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
704
+ bind_named_type_t *bnt = (bind_named_type_t *)base;
705
+ void **hp = (void **)bnt->bind.valuep;
702
706
 
703
- if (oho != NULL) {
707
+ if (hp != NULL) {
704
708
  ub4 idx = 0;
705
709
 
706
710
  do {
707
- if (oho[idx].hp != NULL) {
708
- OCIObjectFree(oci8_envhp, oci8_errhp, oho[idx].hp, OCI_DEFAULT);
709
- oho[idx].hp = NULL;
711
+ if (hp[idx] != NULL) {
712
+ OCIObjectFree(oci8_envhp, oci8_errhp, hp[idx], OCI_DEFAULT);
713
+ hp[idx] = NULL;
710
714
  }
711
- } while (++idx < obind->maxar_sz);
715
+ } while (++idx < bnt->bind.maxar_sz);
716
+ }
717
+ if (bnt->obj != NULL) {
718
+ xfree(bnt->obj);
719
+ bnt->obj = NULL;
712
720
  }
713
721
  oci8_bind_free(base);
714
722
  }
715
723
 
716
724
  static VALUE bind_named_type_get(oci8_bind_t *obind, void *data, void *null_struct)
717
725
  {
718
- oci8_hp_obj_t *oho = (oci8_hp_obj_t *)data;
719
- return oho->obj;
726
+ bind_named_type_t *bnt = (bind_named_type_t *)obind;
727
+ ub4 idx = obind->curar_idx;
728
+
729
+ return bnt->obj[idx];
720
730
  }
721
731
 
732
+ NORETURN(static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val));
733
+
722
734
  static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
723
735
  {
724
736
  rb_raise(rb_eRuntimeError, "not supported");
@@ -726,10 +738,12 @@ static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_stru
726
738
 
727
739
  static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
728
740
  {
741
+ bind_named_type_t *bnt = (bind_named_type_t *)obind;
729
742
  VALUE tdo_obj = length;
730
743
 
731
744
  obind->value_sz = sizeof(void*);
732
- obind->alloc_sz = sizeof(oci8_hp_obj_t);
745
+ obind->alloc_sz = sizeof(void*);
746
+ bnt->obj = xcalloc(sizeof(VALUE), obind->maxar_sz ? obind->maxar_sz : 1);
733
747
 
734
748
  CHECK_TDO(tdo_obj);
735
749
  RB_OBJ_WRITE(obind->base.self, &obind->tdo, tdo_obj);
@@ -737,7 +751,8 @@ static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE
737
751
 
738
752
  static void bind_named_type_init_elem(oci8_bind_t *obind, VALUE svc)
739
753
  {
740
- oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
754
+ bind_named_type_t *bnt = (bind_named_type_t *)obind;
755
+ void **hp = (void **)obind->valuep;
741
756
  oci8_base_t *tdo = DATA_PTR(obind->tdo);
742
757
  OCITypeCode tc = OCITypeTypeCode(oci8_envhp, oci8_errhp, tdo->hp.tdo);
743
758
  VALUE klass = Qnil;
@@ -755,14 +770,14 @@ static void bind_named_type_init_elem(oci8_bind_t *obind, VALUE svc)
755
770
  }
756
771
  svcctx = oci8_get_svcctx(svc);
757
772
  do {
758
- oho[idx].obj = rb_class_new_instance(0, NULL, klass);
759
- RB_OBJ_WRITTEN(obind->base.self, Qundef, oho[idx].obj);
760
- obj = DATA_PTR(oho[idx].obj);
761
- RB_OBJ_WRITE(oho[idx].obj, &obj->tdo, obind->tdo);
762
- obj->instancep = (char**)&oho[idx].hp;
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];
763
778
  obj->null_structp = (char**)&obind->u.null_structs[idx];
764
779
  oci8_link_to_parent(&obj->base, &obind->base);
765
- RB_OBJ_WRITTEN(oho[idx].obj, Qundef, obind->base.self);
780
+ RB_OBJ_WRITTEN(bnt->obj[idx], Qundef, obind->base.self);
766
781
 
767
782
  chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->base.hp.svc, tc, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, (dvoid**)obj->instancep),
768
783
  &svcctx->base);
@@ -804,7 +819,7 @@ static const oci8_bind_data_type_t bind_named_type_data_type = {
804
819
  #endif
805
820
  },
806
821
  bind_named_type_free,
807
- sizeof(oci8_bind_t)
822
+ sizeof(bind_named_type_t)
808
823
  },
809
824
  bind_named_type_get,
810
825
  bind_named_type_set,
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-2015 Kubo Takehiro <kubo@jiubao.org>
5
+ * Copyright (C) 2002-2019 Kubo Takehiro <kubo@jiubao.org>
6
6
  *
7
7
  */
8
8
  #include "oci8.h"
@@ -556,7 +556,7 @@ static VALUE oci8_server_attach(VALUE self, VALUE dbname, VALUE attach_mode)
556
556
  /* attach to the server */
557
557
  chker2(OCIServerAttach_nb(svcctx, svcctx->srvhp, oci8_errhp,
558
558
  NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
559
- NIL_P(dbname) ? 0 : RSTRING_LEN(dbname),
559
+ NIL_P(dbname) ? 0 : RSTRING_LENINT(dbname),
560
560
  mode),
561
561
  &svcctx->base);
562
562
  chker2(OCIAttrSet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX,
@@ -734,14 +734,9 @@ static VALUE oci8_set_autocommit(VALUE self, VALUE val)
734
734
  /*
735
735
  * @overload long_read_len
736
736
  *
737
- * Gets the maximum length in bytes to fetch a LONG or LONG RAW
738
- * column. The default value is 65535.
739
- *
740
- * If the actual data length is longer than long_read_len,
741
- * the fetched valud is truncated and the value of {OCI8#last_error}
742
- * become {OCISuccessWithInfo} whose message is "ORA-01406: fetched column value was truncated".
743
- *
744
- * 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.
745
740
  *
746
741
  * @return [Integer]
747
742
  * @see #long_read_len=
@@ -749,14 +744,16 @@ static VALUE oci8_set_autocommit(VALUE self, VALUE val)
749
744
  static VALUE oci8_long_read_len(VALUE self)
750
745
  {
751
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");
752
748
  return svcctx->long_read_len;
753
749
  }
754
750
 
755
751
  /*
756
752
  * @overload long_read_len=(length)
757
753
  *
758
- * Sets the maximum length in bytes to fetch a LONG or LONG RAW
759
- * column.
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.
760
757
  *
761
758
  * @param [Integer] length
762
759
  * @see #long_read_len
@@ -766,6 +763,7 @@ static VALUE oci8_set_long_read_len(VALUE self, VALUE val)
766
763
  oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
767
764
  Check_Type(val, T_FIXNUM);
768
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");
769
767
  return val;
770
768
  }
771
769
 
@@ -866,7 +864,7 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
866
864
  if (!NIL_P(val)) {
867
865
  OCI8SafeStringValue(val);
868
866
  ptr = RSTRING_PTR(val);
869
- size = RSTRING_LEN(val);
867
+ size = RSTRING_LENINT(val);
870
868
  } else {
871
869
  ptr = "";
872
870
  size = 0;
@@ -901,7 +899,7 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
901
899
  if (!NIL_P(val)) {
902
900
  OCI8SafeStringValue(val);
903
901
  ptr = RSTRING_PTR(val);
904
- size = RSTRING_LEN(val);
902
+ size = RSTRING_LENINT(val);
905
903
  } else {
906
904
  ptr = "";
907
905
  size = 0;
@@ -935,7 +933,7 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
935
933
  if (!NIL_P(val)) {
936
934
  OCI8SafeStringValue(val);
937
935
  ptr = RSTRING_PTR(val);
938
- size = RSTRING_LEN(val);
936
+ size = RSTRING_LENINT(val);
939
937
  } else {
940
938
  ptr = "";
941
939
  size = 0;
@@ -966,7 +964,7 @@ static VALUE oci8_set_client_info(VALUE self, VALUE val)
966
964
  if (!NIL_P(val)) {
967
965
  OCI8SafeStringValue(val);
968
966
  ptr = RSTRING_PTR(val);
969
- size = RSTRING_LEN(val);
967
+ size = RSTRING_LENINT(val);
970
968
  } else {
971
969
  ptr = "";
972
970
  size = 0;
data/ext/oci8/oci8.h CHANGED
@@ -424,6 +424,7 @@ void *oci8_check_typeddata(VALUE obj, const oci8_handle_data_type_t *data_type,
424
424
  extern VALUE eOCIException;
425
425
  extern VALUE eOCIBreak;
426
426
  void Init_oci8_error(void);
427
+ NORETURN(void oci8_do_raise(OCIError *errhp, sword status, OCIStmt *stmthp, const char *file, int line));
427
428
  NORETURN(void oci8_do_env_raise(OCIEnv *envhp, sword status, int free_envhp, const char *file, int line));
428
429
  NORETURN(void oci8_do_raise_init_error(const char *file, int line));
429
430
  sb4 oci8_get_error_code(OCIError *errhp);
data/ext/oci8/oci8lib.c CHANGED
@@ -71,7 +71,7 @@ static VALUE bind_base_alloc(VALUE klass)
71
71
  rb_raise(rb_eNameError, "private method `new' called for %s:Class", rb_class2name(klass));
72
72
  }
73
73
 
74
- #if defined(HAVE_PLTHOOK) && !defined(WIN32) && !defined(__CYGWIN__)
74
+ #if defined(HAVE_PLTHOOK) && !defined(WIN32) && !defined(__CYGWIN__) && !defined(TRUFFLERUBY)
75
75
  static const char *find_libclntsh(void *handle)
76
76
  {
77
77
  void *symaddr = dlsym(handle, "OCIEnvCreate");
@@ -226,7 +226,7 @@ Init_oci8lib()
226
226
  oracle_client_version = ORAVERNUM(major, minor, update, patch, port_update);
227
227
  }
228
228
  #endif
229
- #if defined(HAVE_PLTHOOK) && !defined(WIN32) && !defined(__CYGWIN__)
229
+ #if defined(HAVE_PLTHOOK) && !defined(WIN32) && !defined(__CYGWIN__) && !defined(TRUFFLERUBY)
230
230
  rebind_internal_symbols();
231
231
  #endif
232
232
 
@@ -461,6 +461,7 @@ sword oci8_call_without_gvl(oci8_svcctx_t *svcctx, void *(*func)(void *), void *
461
461
  parg.func = func;
462
462
  parg.data = data;
463
463
  rv = (sword)rb_protect(protected_call, (VALUE)&parg, &state);
464
+ RB_OBJ_WRITE(svcctx->base.self, &svcctx->executing_thread, Qnil);
464
465
  if (state) {
465
466
  rb_jump_tag(state);
466
467
  }
@@ -481,8 +482,8 @@ typedef struct {
481
482
  OCIStmt *stmtp;
482
483
  } cb_arg_t;
483
484
 
484
- static VALUE exec_sql(cb_arg_t *arg);
485
- static VALUE ensure_func(cb_arg_t *arg);
485
+ static VALUE exec_sql(VALUE varg);
486
+ static VALUE ensure_func(VALUE varg);
486
487
 
487
488
  /*
488
489
  * utility function to execute a single SQL statement
@@ -503,13 +504,14 @@ sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_
503
504
  return (sword)rb_ensure(exec_sql, (VALUE)&arg, ensure_func, (VALUE)&arg);
504
505
  }
505
506
 
506
- static VALUE exec_sql(cb_arg_t *arg)
507
+ static VALUE exec_sql(VALUE varg)
507
508
  {
509
+ cb_arg_t *arg = (cb_arg_t *)varg;
508
510
  ub4 pos;
509
511
  sword rv;
510
512
 
511
513
  chker2(OCIStmtPrepare2(arg->svcctx->base.hp.svc, &arg->stmtp, oci8_errhp,
512
- (text*)arg->sql_text, strlen(arg->sql_text), NULL, 0,
514
+ (text*)arg->sql_text, (ub4)strlen(arg->sql_text), NULL, 0,
513
515
  OCI_NTV_SYNTAX, OCI_DEFAULT),
514
516
  &arg->svcctx->base);
515
517
  for (pos = 0; pos < arg->num_define_vars; pos++) {
@@ -546,8 +548,9 @@ static VALUE exec_sql(cb_arg_t *arg)
546
548
  return (VALUE)rv;
547
549
  }
548
550
 
549
- static VALUE ensure_func(cb_arg_t *arg)
551
+ static VALUE ensure_func(VALUE varg)
550
552
  {
553
+ cb_arg_t *arg = (cb_arg_t *)varg;
551
554
  if (arg->stmtp != NULL) {
552
555
  OCIStmtRelease(arg->stmtp, oci8_errhp, NULL, 0, OCI_DEFAULT);
553
556
  }
data/ext/oci8/ocihandle.c CHANGED
@@ -752,7 +752,7 @@ static VALUE attr_set_string(VALUE self, VALUE attr_type, VALUE val)
752
752
  Check_Type(attr_type, T_FIXNUM);
753
753
  OCI8SafeStringValue(val);
754
754
  /* set attribute */
755
- chker2(OCIAttrSet(base->hp.ptr, base->type, RSTRING_PTR(val), RSTRING_LEN(val), FIX2INT(attr_type), oci8_errhp), base);
755
+ chker2(OCIAttrSet(base->hp.ptr, base->type, RSTRING_PTR(val), RSTRING_LENINT(val), FIX2INT(attr_type), oci8_errhp), base);
756
756
  return self;
757
757
  }
758
758
 
@@ -776,7 +776,7 @@ static VALUE attr_set_binary(VALUE self, VALUE attr_type, VALUE val)
776
776
  Check_Type(attr_type, T_FIXNUM);
777
777
  SafeStringValue(val);
778
778
  /* set attribute */
779
- chker2(OCIAttrSet(base->hp.ptr, base->type, RSTRING_PTR(val), RSTRING_LEN(val), FIX2INT(attr_type), oci8_errhp), base);
779
+ chker2(OCIAttrSet(base->hp.ptr, base->type, RSTRING_PTR(val), RSTRING_LENINT(val), FIX2INT(attr_type), oci8_errhp), base);
780
780
  return self;
781
781
  }
782
782
 
data/ext/oci8/ocinumber.c CHANGED
@@ -154,7 +154,7 @@ static void set_oci_number_from_str(OCINumber *result, VALUE str, VALUE fmt, VAL
154
154
  StringValue(str);
155
155
  /* set from string. */
156
156
  if (NIL_P(fmt)) {
157
- int rv = oranumber_from_str(result, RSTRING_PTR(str), RSTRING_LEN(str));
157
+ int rv = oranumber_from_str(result, RSTRING_PTR(str), RSTRING_LENINT(str));
158
158
  if (rv == ORANUMBER_SUCCESS) {
159
159
  return; /* success */
160
160
  } else {
@@ -172,17 +172,17 @@ static void set_oci_number_from_str(OCINumber *result, VALUE str, VALUE fmt, VAL
172
172
  }
173
173
  StringValue(fmt);
174
174
  fmt_ptr = RSTRING_ORATEXT(fmt);
175
- fmt_len = RSTRING_LEN(fmt);
175
+ fmt_len = RSTRING_LENINT(fmt);
176
176
  if (NIL_P(nls_params)) {
177
177
  nls_params_ptr = NULL;
178
178
  nls_params_len = 0;
179
179
  } else {
180
180
  StringValue(nls_params);
181
181
  nls_params_ptr = RSTRING_ORATEXT(nls_params);
182
- nls_params_len = RSTRING_LEN(nls_params);
182
+ nls_params_len = RSTRING_LENINT(nls_params);
183
183
  }
184
184
  chkerr(OCINumberFromText(errhp,
185
- RSTRING_ORATEXT(str), RSTRING_LEN(str),
185
+ RSTRING_ORATEXT(str), RSTRING_LENINT(str),
186
186
  fmt_ptr, fmt_len, nls_params_ptr, nls_params_len,
187
187
  result));
188
188
  }
@@ -216,6 +216,8 @@ static int set_oci_number_from_num(OCINumber *result, VALUE num, int force, OCIE
216
216
  num = rb_big2str(num, 10);
217
217
  set_oci_number_from_str(result, num, Qnil, Qnil, errhp);
218
218
  return 1;
219
+ default:
220
+ break;
219
221
  }
220
222
  if (RTEST(rb_obj_is_instance_of(num, cOCINumber))) {
221
223
  /* OCI::Number */
@@ -247,7 +249,7 @@ static int set_oci_number_from_num(OCINumber *result, VALUE num, int force, OCIE
247
249
  if (TYPE(ary[1]) != T_STRING) {
248
250
  goto is_not_big_decimal;
249
251
  }
250
- digits_len = RSTRING_LEN(ary[1]);
252
+ digits_len = RSTRING_LENINT(ary[1]);
251
253
  set_oci_number_from_str(&digits, ary[1], Qnil, Qnil, errhp);
252
254
  /* check base */
253
255
  if (TYPE(ary[2]) != T_FIXNUM || FIX2LONG(ary[2]) != 10) {
@@ -363,7 +365,7 @@ OCINumber *oci8_dbl_to_onum(OCINumber *result, double dbl, OCIError *errhp)
363
365
  sword rv;
364
366
 
365
367
  str = rb_obj_as_string(rb_float_new(dbl));
366
- rv = oranumber_from_str(result, RSTRING_PTR(str), RSTRING_LEN(str));
368
+ rv = oranumber_from_str(result, RSTRING_PTR(str), RSTRING_LENINT(str));
367
369
  if (rv != 0) {
368
370
  oci8_raise_by_msgno(rv, NULL);
369
371
  }
@@ -1307,14 +1309,14 @@ static VALUE onum_to_char(int argc, VALUE *argv, VALUE self)
1307
1309
  }
1308
1310
  StringValue(fmt);
1309
1311
  fmt_ptr = RSTRING_ORATEXT(fmt);
1310
- fmt_len = RSTRING_LEN(fmt);
1312
+ fmt_len = RSTRING_LENINT(fmt);
1311
1313
  if (NIL_P(nls_params)) {
1312
1314
  nls_params_ptr = NULL;
1313
1315
  nls_params_len = 0;
1314
1316
  } else {
1315
1317
  StringValue(nls_params);
1316
1318
  nls_params_ptr = RSTRING_ORATEXT(nls_params);
1317
- nls_params_len = RSTRING_LEN(nls_params);
1319
+ nls_params_len = RSTRING_LENINT(nls_params);
1318
1320
  }
1319
1321
  rv = OCINumberToText(errhp, _NUMBER(self),
1320
1322
  fmt_ptr, fmt_len, nls_params_ptr, nls_params_len,
@@ -1435,7 +1437,7 @@ static VALUE onum_to_d_real(OCINumber *num, OCIError *errhp)
1435
1437
  rb_require("bigdecimal");
1436
1438
  cBigDecimal = rb_const_get(rb_cObject, id_BigDecimal);
1437
1439
  }
1438
- chkerr(OCINumberToText(errhp, num, (const oratext *)fmt, strlen(fmt),
1440
+ chkerr(OCINumberToText(errhp, num, (const oratext *)fmt, (ub4)strlen(fmt),
1439
1441
  NULL, 0, &buf_size, TO_ORATEXT(buf)));
1440
1442
  return rb_funcall(rb_cObject, id_BigDecimal, 1, rb_usascii_str_new(buf, buf_size));
1441
1443
  }