ruby-oci8 2.2.7 → 2.2.11

Sign up to get free protection for your applications and to get access to all the features.
data/ext/oci8/lob.c CHANGED
@@ -719,7 +719,6 @@ read_more_data:
719
719
  default:
720
720
  v = rb_ary_join(v, Qnil);
721
721
  }
722
- OBJ_TAINT(v);
723
722
  if (lob->lobtype == OCI_TEMP_CLOB) {
724
723
  /* set encoding */
725
724
  rb_enc_associate(v, oci8_encoding);
@@ -766,10 +765,10 @@ static VALUE oci8_lob_write(VALUE self, VALUE data)
766
765
  RB_GC_GUARD(str);
767
766
  if (lob->lobtype == OCI_TEMP_CLOB) {
768
767
  lob->pos += char_amt;
769
- return UINT2NUM(char_amt);
768
+ return ULL2NUM(char_amt);
770
769
  } else {
771
770
  lob->pos += byte_amt;
772
- return UINT2NUM(byte_amt);
771
+ return ULL2NUM(byte_amt);
773
772
  }
774
773
  }
775
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:
@@ -729,6 +729,8 @@ static VALUE bind_named_type_get(oci8_bind_t *obind, void *data, void *null_stru
729
729
  return bnt->obj[idx];
730
730
  }
731
731
 
732
+ NORETURN(static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val));
733
+
732
734
  static void bind_named_type_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
733
735
  {
734
736
  rb_raise(rb_eRuntimeError, "not supported");
data/ext/oci8/oci8.c CHANGED
@@ -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,
@@ -864,7 +864,7 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
864
864
  if (!NIL_P(val)) {
865
865
  OCI8SafeStringValue(val);
866
866
  ptr = RSTRING_PTR(val);
867
- size = RSTRING_LEN(val);
867
+ size = RSTRING_LENINT(val);
868
868
  } else {
869
869
  ptr = "";
870
870
  size = 0;
@@ -899,7 +899,7 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
899
899
  if (!NIL_P(val)) {
900
900
  OCI8SafeStringValue(val);
901
901
  ptr = RSTRING_PTR(val);
902
- size = RSTRING_LEN(val);
902
+ size = RSTRING_LENINT(val);
903
903
  } else {
904
904
  ptr = "";
905
905
  size = 0;
@@ -933,7 +933,7 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
933
933
  if (!NIL_P(val)) {
934
934
  OCI8SafeStringValue(val);
935
935
  ptr = RSTRING_PTR(val);
936
- size = RSTRING_LEN(val);
936
+ size = RSTRING_LENINT(val);
937
937
  } else {
938
938
  ptr = "";
939
939
  size = 0;
@@ -964,7 +964,7 @@ static VALUE oci8_set_client_info(VALUE self, VALUE val)
964
964
  if (!NIL_P(val)) {
965
965
  OCI8SafeStringValue(val);
966
966
  ptr = RSTRING_PTR(val);
967
- size = RSTRING_LEN(val);
967
+ size = RSTRING_LENINT(val);
968
968
  } else {
969
969
  ptr = "";
970
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
  }