ruby-oci8 2.1.7 → 2.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +136 -0
- data/NEWS +61 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/dist-files +5 -0
- data/docs/install-instant-client.md +2 -0
- data/ext/oci8/attr.c +0 -9
- data/ext/oci8/bind.c +86 -28
- data/ext/oci8/connection_pool.c +32 -17
- data/ext/oci8/extconf.rb +21 -0
- data/ext/oci8/hook_funcs.c +215 -0
- data/ext/oci8/lob.c +363 -168
- data/ext/oci8/metadata.c +43 -26
- data/ext/oci8/object.c +115 -36
- data/ext/oci8/oci8.c +392 -269
- data/ext/oci8/oci8.h +88 -33
- data/ext/oci8/oci8lib.c +59 -28
- data/ext/oci8/ocidatetime.c +100 -36
- data/ext/oci8/ocihandle.c +288 -286
- data/ext/oci8/ocinumber.c +172 -112
- data/ext/oci8/oradate.c +129 -87
- data/ext/oci8/plthook.h +56 -0
- data/ext/oci8/plthook_elf.c +537 -0
- data/ext/oci8/plthook_osx.c +474 -0
- data/ext/oci8/plthook_win32.c +376 -0
- data/ext/oci8/stmt.c +112 -75
- data/lib/oci8/cursor.rb +1 -1
- data/lib/oci8/oci8.rb +71 -0
- data/lib/oci8/properties.rb +18 -3
- metadata +10 -16
data/ext/oci8/ocinumber.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* ocinumber.c
|
4
4
|
*
|
5
|
-
* Copyright (C) 2005-
|
5
|
+
* Copyright (C) 2005-2015 Kubo Takehiro <kubo@jiubao.org>
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
#include "oci8.h"
|
@@ -44,7 +44,8 @@ static OCINumber const_m1; /* -1 */
|
|
44
44
|
static OCINumber const_PI2; /* +PI/2 */
|
45
45
|
static OCINumber const_mPI2; /* -PI/2 */
|
46
46
|
|
47
|
-
|
47
|
+
/* Dangerous macro! Don't use this if you are unsure that the val is an OCINumber. */
|
48
|
+
#define _NUMBER(val) ((OCINumber *)RTYPEDDATA_DATA(val))
|
48
49
|
|
49
50
|
#ifndef T_MASK
|
50
51
|
#define T_MASK 0x100 /* TODO: rboci8_type() should be changed to be more portable. */
|
@@ -102,12 +103,28 @@ static VALUE onum_to_r(VALUE self);
|
|
102
103
|
static VALUE onum_to_d(VALUE self);
|
103
104
|
static VALUE onum_to_d_real(OCINumber *num, OCIError *errhp);
|
104
105
|
|
106
|
+
static size_t onum_memsize(const void *ptr)
|
107
|
+
{
|
108
|
+
return sizeof(OCINumber);
|
109
|
+
}
|
110
|
+
|
111
|
+
static const rb_data_type_t onum_data_type = {
|
112
|
+
"OraNumber",
|
113
|
+
{NULL, RUBY_DEFAULT_FREE, onum_memsize,},
|
114
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
115
|
+
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
116
|
+
#endif
|
117
|
+
#ifdef RUBY_TYPED_WB_PROTECTED
|
118
|
+
| RUBY_TYPED_WB_PROTECTED
|
119
|
+
#endif
|
120
|
+
};
|
121
|
+
|
105
122
|
static VALUE onum_s_alloc(VALUE klass)
|
106
123
|
{
|
107
124
|
VALUE obj;
|
108
125
|
OCINumber *d;
|
109
126
|
|
110
|
-
obj =
|
127
|
+
obj = TypedData_Make_Struct(klass, OCINumber, &onum_data_type, d);
|
111
128
|
OCINumberSetZero(oci8_errhp, d);
|
112
129
|
return obj;
|
113
130
|
}
|
@@ -120,7 +137,7 @@ VALUE oci8_make_ocinumber(OCINumber *s, OCIError *errhp)
|
|
120
137
|
VALUE obj;
|
121
138
|
OCINumber *d;
|
122
139
|
|
123
|
-
obj =
|
140
|
+
obj = TypedData_Make_Struct(cOCINumber, OCINumber, &onum_data_type, d);
|
124
141
|
chkerr(OCINumberAssign(errhp, s, d));
|
125
142
|
return obj;
|
126
143
|
}
|
@@ -232,19 +249,19 @@ static int set_oci_number_from_num(OCINumber *result, VALUE num, int force, OCIE
|
|
232
249
|
}
|
233
250
|
if (RTEST(rb_obj_is_instance_of(num, cOCINumber))) {
|
234
251
|
/* OCI::Number */
|
235
|
-
chkerr(OCINumberAssign(errhp,
|
252
|
+
chkerr(OCINumberAssign(errhp, _NUMBER(num), result));
|
236
253
|
return 1;
|
237
254
|
}
|
238
255
|
if (rb_respond_to(num, id_split)) {
|
239
256
|
/* BigDecimal */
|
240
|
-
VALUE split = rb_funcall(num, id_split, 0);
|
257
|
+
volatile VALUE split = rb_funcall(num, id_split, 0);
|
241
258
|
|
242
259
|
if (TYPE(split) == T_ARRAY && RARRAY_LEN(split) == 4) {
|
243
260
|
/*
|
244
261
|
* sign, significant_digits, base, exponent = num.split
|
245
262
|
* onum = sign * "0.#{significant_digits}".to_f * (base ** exponent)
|
246
263
|
*/
|
247
|
-
VALUE *ary =
|
264
|
+
const VALUE *ary = RARRAY_CONST_PTR(split);
|
248
265
|
int sign;
|
249
266
|
OCINumber digits;
|
250
267
|
int exponent;
|
@@ -257,7 +274,9 @@ static int set_oci_number_from_num(OCINumber *result, VALUE num, int force, OCIE
|
|
257
274
|
}
|
258
275
|
sign = FIX2INT(ary[0]);
|
259
276
|
/* check digits */
|
260
|
-
|
277
|
+
if (TYPE(ary[1]) != T_STRING) {
|
278
|
+
goto is_not_big_decimal;
|
279
|
+
}
|
261
280
|
digits_len = RSTRING_LEN(ary[1]);
|
262
281
|
set_oci_number_from_str(&digits, ary[1], Qnil, Qnil, errhp);
|
263
282
|
/* check base */
|
@@ -393,8 +412,7 @@ OCINumber *oci8_dbl_to_onum(OCINumber *result, double dbl, OCIError *errhp)
|
|
393
412
|
*/
|
394
413
|
|
395
414
|
/*
|
396
|
-
*
|
397
|
-
* atan2(y, x)
|
415
|
+
* @overload atan2(y, x)
|
398
416
|
*
|
399
417
|
* Computes the principal value of the arc tangent of <i>y/x</i>,
|
400
418
|
* using the signs of both arguments to determine the quadrant of the
|
@@ -434,8 +452,7 @@ static VALUE omath_atan2(VALUE self, VALUE Ycoordinate, VALUE Xcoordinate)
|
|
434
452
|
}
|
435
453
|
|
436
454
|
/*
|
437
|
-
*
|
438
|
-
* cos(x)
|
455
|
+
* @overload cos(x)
|
439
456
|
*
|
440
457
|
* Computes the cosine of <i>x</i>, measured in radians.
|
441
458
|
*
|
@@ -453,8 +470,7 @@ static VALUE omath_cos(VALUE obj, VALUE radian)
|
|
453
470
|
}
|
454
471
|
|
455
472
|
/*
|
456
|
-
*
|
457
|
-
* sin(x)
|
473
|
+
* @overload sin(x)
|
458
474
|
*
|
459
475
|
* Computes the sine of <i>x</i>, measured in radians.
|
460
476
|
*
|
@@ -472,8 +488,7 @@ static VALUE omath_sin(VALUE obj, VALUE radian)
|
|
472
488
|
}
|
473
489
|
|
474
490
|
/*
|
475
|
-
*
|
476
|
-
* tan(x)
|
491
|
+
* @overload tan(x)
|
477
492
|
*
|
478
493
|
* Computes the tangent of <i>x</i>, measured in radians.
|
479
494
|
*
|
@@ -491,8 +506,7 @@ static VALUE omath_tan(VALUE obj, VALUE radian)
|
|
491
506
|
}
|
492
507
|
|
493
508
|
/*
|
494
|
-
*
|
495
|
-
* acos(x)
|
509
|
+
* @overload acos(x)
|
496
510
|
*
|
497
511
|
* Computes the principal value of the arc cosine of <i>x</i>.
|
498
512
|
*
|
@@ -521,8 +535,7 @@ static VALUE omath_acos(VALUE obj, VALUE num)
|
|
521
535
|
}
|
522
536
|
|
523
537
|
/*
|
524
|
-
*
|
525
|
-
* asin(x)
|
538
|
+
* @overload asin(x)
|
526
539
|
*
|
527
540
|
* Computes the principal value of the arc sine of <i>x</i>.
|
528
541
|
*
|
@@ -551,8 +564,7 @@ static VALUE omath_asin(VALUE obj, VALUE num)
|
|
551
564
|
}
|
552
565
|
|
553
566
|
/*
|
554
|
-
*
|
555
|
-
* atan(x)
|
567
|
+
* @overload atan(x)
|
556
568
|
*
|
557
569
|
* Computes the principal value of the arc tangent of their argument <i>x</i>.
|
558
570
|
*
|
@@ -570,8 +582,7 @@ static VALUE omath_atan(VALUE obj, VALUE num)
|
|
570
582
|
}
|
571
583
|
|
572
584
|
/*
|
573
|
-
*
|
574
|
-
* cosh(x)
|
585
|
+
* @overload cosh(x)
|
575
586
|
*
|
576
587
|
* Computes the hyperbolic cosine of <i>x</i>.
|
577
588
|
*
|
@@ -589,8 +600,7 @@ static VALUE omath_cosh(VALUE obj, VALUE num)
|
|
589
600
|
}
|
590
601
|
|
591
602
|
/*
|
592
|
-
*
|
593
|
-
* sinh(x)
|
603
|
+
* @overload sinh(x)
|
594
604
|
*
|
595
605
|
* Computes the hyperbolic sine of <i>x</i>.
|
596
606
|
*
|
@@ -608,8 +618,7 @@ static VALUE omath_sinh(VALUE obj, VALUE num)
|
|
608
618
|
}
|
609
619
|
|
610
620
|
/*
|
611
|
-
*
|
612
|
-
* tanh(x)
|
621
|
+
* @overload tanh(x)
|
613
622
|
*
|
614
623
|
* Computes the hyperbolic tangent of <i>x</i>.
|
615
624
|
*
|
@@ -627,8 +636,7 @@ static VALUE omath_tanh(VALUE obj, VALUE num)
|
|
627
636
|
}
|
628
637
|
|
629
638
|
/*
|
630
|
-
*
|
631
|
-
* exp(x)
|
639
|
+
* @overload exp(x)
|
632
640
|
*
|
633
641
|
* Computes the base- <i>e</i> exponential of <i>x</i>.
|
634
642
|
*
|
@@ -646,20 +654,20 @@ static VALUE omath_exp(VALUE obj, VALUE num)
|
|
646
654
|
}
|
647
655
|
|
648
656
|
/*
|
649
|
-
*
|
657
|
+
* @overload log(x)
|
650
658
|
*
|
651
|
-
*
|
659
|
+
* Computes the natural logarithm of <i>x</i>.
|
652
660
|
*
|
653
|
-
*
|
654
|
-
*
|
661
|
+
* @param [Numeric] x
|
662
|
+
* @return [OraNumber]
|
655
663
|
*
|
656
|
-
*
|
664
|
+
* @overload log(x, y)
|
657
665
|
*
|
658
|
-
*
|
666
|
+
* Computes the base <i>y</I> logarithm of <i>x</i>.
|
659
667
|
*
|
660
|
-
*
|
661
|
-
*
|
662
|
-
*
|
668
|
+
* @param [Numeric] x
|
669
|
+
* @param [Numeric] y
|
670
|
+
* @return [OraNumber]
|
663
671
|
*/
|
664
672
|
static VALUE omath_log(int argc, VALUE *argv, VALUE obj)
|
665
673
|
{
|
@@ -691,8 +699,7 @@ static VALUE omath_log(int argc, VALUE *argv, VALUE obj)
|
|
691
699
|
}
|
692
700
|
|
693
701
|
/*
|
694
|
-
*
|
695
|
-
* log10(x)
|
702
|
+
* @overload log10(x)
|
696
703
|
*
|
697
704
|
* Computes the base 10 logarithm of <i>x</i>.
|
698
705
|
*
|
@@ -715,8 +722,7 @@ static VALUE omath_log10(VALUE obj, VALUE num)
|
|
715
722
|
}
|
716
723
|
|
717
724
|
/*
|
718
|
-
*
|
719
|
-
* sqrt(x)
|
725
|
+
* @overload sqrt(x)
|
720
726
|
*
|
721
727
|
* Computes the square root of <i>x</i>.
|
722
728
|
*
|
@@ -745,17 +751,16 @@ static VALUE omath_sqrt(VALUE obj, VALUE num)
|
|
745
751
|
* Document-class: OraNumber
|
746
752
|
*
|
747
753
|
* OraNumber is a ruby representation of
|
748
|
-
* {http://docs.oracle.com/
|
754
|
+
* {http://docs.oracle.com/database/121/SQLRF/sql_elements001.htm#SQLRF30020 Oracle NUMBER data type}.
|
749
755
|
* without precision and scale designators.
|
750
756
|
*/
|
751
757
|
|
752
758
|
/*
|
753
|
-
*
|
754
|
-
* OraNumber(expr = nil, fmt = nil, nlsparam = nil)
|
759
|
+
* @overload OraNumber(expr = nil, fmt = nil, nlsparam = nil)
|
755
760
|
*
|
756
761
|
* Converts <i>expr</i> to a value of OraNumber. The <i>expr</i> can be a Numeric value
|
757
762
|
* or a String value. If it is a String value, optional <i>fmt</i> and <i>nlsparam</i>.
|
758
|
-
* is used as {http://docs.oracle.com/
|
763
|
+
* is used as {http://docs.oracle.com/database/121/SQLRF/functions226.htm Oracle SQL function TO_NUMBER}
|
759
764
|
* does.
|
760
765
|
*
|
761
766
|
* @example
|
@@ -783,12 +788,11 @@ static VALUE onum_f_new(int argc, VALUE *argv, VALUE self)
|
|
783
788
|
}
|
784
789
|
|
785
790
|
/*
|
786
|
-
*
|
787
|
-
* initialize(expr = nil, fmt = nil, nlsparam = nil)
|
791
|
+
* @overload initialize(expr = nil, fmt = nil, nlsparam = nil)
|
788
792
|
*
|
789
793
|
* Creates a value of OraNumber from <i>expr</i>. The <i>expr</i> can be a Numeric value
|
790
794
|
* or a String value. If it is a String value, optional <i>fmt</i> and <i>nlsparam</i>
|
791
|
-
* is used as {http://docs.oracle.com/
|
795
|
+
* is used as {http://docs.oracle.com/database/121/SQLRF/functions226.htm Oracle SQL function TO_NUMBER}
|
792
796
|
* does.
|
793
797
|
*
|
794
798
|
* @example
|
@@ -823,8 +827,7 @@ static VALUE onum_initialize(int argc, VALUE *argv, VALUE self)
|
|
823
827
|
}
|
824
828
|
|
825
829
|
/*
|
826
|
-
*
|
827
|
-
* initialize_copy(obj)
|
830
|
+
* @overload initialize_copy(obj)
|
828
831
|
*
|
829
832
|
* Replaces <i>self</i> with <i>obj</i>. <code>Object#clone</code> and <code>Object#dup</code>
|
830
833
|
* call this method to copy data unknown by the ruby interpreter.
|
@@ -890,8 +893,7 @@ static VALUE onum_neg(VALUE self)
|
|
890
893
|
}
|
891
894
|
|
892
895
|
/*
|
893
|
-
*
|
894
|
-
* self + other
|
896
|
+
* @overload +(other)
|
895
897
|
*
|
896
898
|
* Returns the sum of <i>self</i> and <i>other</i>.
|
897
899
|
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
@@ -932,8 +934,7 @@ static VALUE onum_add(VALUE lhs, VALUE rhs)
|
|
932
934
|
}
|
933
935
|
|
934
936
|
/*
|
935
|
-
*
|
936
|
-
* self - other
|
937
|
+
* @overload -(other)
|
937
938
|
*
|
938
939
|
* Returns the difference of <i>self</i> and <i>other</i>.
|
939
940
|
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
@@ -974,8 +975,7 @@ static VALUE onum_sub(VALUE lhs, VALUE rhs)
|
|
974
975
|
}
|
975
976
|
|
976
977
|
/*
|
977
|
-
*
|
978
|
-
* self * other
|
978
|
+
* @overload *(other)
|
979
979
|
*
|
980
980
|
* Returns the product of <i>self</i> and <i>other</i>.
|
981
981
|
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
@@ -1016,8 +1016,7 @@ static VALUE onum_mul(VALUE lhs, VALUE rhs)
|
|
1016
1016
|
}
|
1017
1017
|
|
1018
1018
|
/*
|
1019
|
-
*
|
1020
|
-
* self / other
|
1019
|
+
* @overload /(other)
|
1021
1020
|
*
|
1022
1021
|
* Returns the result of dividing <i>self</i> by <i>other</i>.
|
1023
1022
|
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
@@ -1066,8 +1065,7 @@ static VALUE onum_div(VALUE lhs, VALUE rhs)
|
|
1066
1065
|
}
|
1067
1066
|
|
1068
1067
|
/*
|
1069
|
-
*
|
1070
|
-
* self % other
|
1068
|
+
* @overload %(other)
|
1071
1069
|
*
|
1072
1070
|
* Returns the modulo after division of <i>self</i> by <i>other</i>.
|
1073
1071
|
*
|
@@ -1099,8 +1097,7 @@ static VALUE onum_mod(VALUE lhs, VALUE rhs)
|
|
1099
1097
|
}
|
1100
1098
|
|
1101
1099
|
/*
|
1102
|
-
*
|
1103
|
-
* self ** other
|
1100
|
+
* @overload **(other)
|
1104
1101
|
*
|
1105
1102
|
* Raises <i>self</i> to the power of <i>other</i>.
|
1106
1103
|
*
|
@@ -1129,8 +1126,7 @@ static VALUE onum_power(VALUE lhs, VALUE rhs)
|
|
1129
1126
|
}
|
1130
1127
|
|
1131
1128
|
/*
|
1132
|
-
*
|
1133
|
-
* self <=> other
|
1129
|
+
* @overload <=>(other)
|
1134
1130
|
*
|
1135
1131
|
* Returns -1, 0, or +1 depending on whether <i>self</i> is less than,
|
1136
1132
|
* equal to, or greater than <i>other</i>. This is the basis for the
|
@@ -1165,6 +1161,8 @@ static VALUE onum_cmp(VALUE lhs, VALUE rhs)
|
|
1165
1161
|
}
|
1166
1162
|
|
1167
1163
|
/*
|
1164
|
+
* @overload floor
|
1165
|
+
*
|
1168
1166
|
* Returns the largest <code>Integer</code> less than or equal to <i>self</i>.
|
1169
1167
|
*
|
1170
1168
|
* @example
|
@@ -1184,6 +1182,8 @@ static VALUE onum_floor(VALUE self)
|
|
1184
1182
|
}
|
1185
1183
|
|
1186
1184
|
/*
|
1185
|
+
* @overload ceil
|
1186
|
+
*
|
1187
1187
|
* Returns the smallest <code>Integer</code> greater than or equal to <i>self</i>.
|
1188
1188
|
*
|
1189
1189
|
* @example
|
@@ -1203,30 +1203,30 @@ static VALUE onum_ceil(VALUE self)
|
|
1203
1203
|
}
|
1204
1204
|
|
1205
1205
|
/*
|
1206
|
-
*
|
1206
|
+
* @overload round
|
1207
1207
|
*
|
1208
|
-
*
|
1208
|
+
* Rounds <i>self</i> to the nearest <code>Integer</code>.
|
1209
1209
|
*
|
1210
|
-
*
|
1211
|
-
*
|
1212
|
-
*
|
1213
|
-
*
|
1214
|
-
*
|
1210
|
+
* @example
|
1211
|
+
* OraNumber(1.49).round # => 1
|
1212
|
+
* OraNumber(1.5).round # => 2
|
1213
|
+
* OraNumber(-1.49).round # => -1
|
1214
|
+
* OraNumber(-1.5).round # => -2
|
1215
1215
|
*
|
1216
|
-
*
|
1216
|
+
* @return [Integer]
|
1217
1217
|
*
|
1218
|
-
*
|
1218
|
+
* @overload round(decplace)
|
1219
1219
|
*
|
1220
|
-
*
|
1220
|
+
* Rounds <i>onum</i> to a specified decimal place <i>decplace</i>.
|
1221
1221
|
*
|
1222
|
-
*
|
1223
|
-
*
|
1224
|
-
*
|
1225
|
-
*
|
1226
|
-
*
|
1222
|
+
* @example
|
1223
|
+
* OraNumber(123.456).round(2) # => #<OraNumber:123.46>
|
1224
|
+
* OraNumber(123.456).round(1) # => #<OraNumber:123.5>
|
1225
|
+
* OraNumber(123.456).round(0) # => #<OraNumber:123>
|
1226
|
+
* OraNumber(123.456).round(-1) # => #<OraNumber:120>
|
1227
1227
|
*
|
1228
|
-
*
|
1229
|
-
*
|
1228
|
+
* @param [Integer] decplace
|
1229
|
+
* @return [OraNumber]
|
1230
1230
|
*/
|
1231
1231
|
static VALUE onum_round(int argc, VALUE *argv, VALUE self)
|
1232
1232
|
{
|
@@ -1244,8 +1244,7 @@ static VALUE onum_round(int argc, VALUE *argv, VALUE self)
|
|
1244
1244
|
}
|
1245
1245
|
|
1246
1246
|
/*
|
1247
|
-
*
|
1248
|
-
* truncate(decplace = 0)
|
1247
|
+
* @overload truncate(decplace = 0)
|
1249
1248
|
*
|
1250
1249
|
* Truncates <i>self</i> to a specified decimal place <i>decplace</i>.
|
1251
1250
|
*
|
@@ -1260,7 +1259,7 @@ static VALUE onum_round(int argc, VALUE *argv, VALUE self)
|
|
1260
1259
|
* OraNumber(-123.456).truncate(2) # => #<OraNumber:-123.45>
|
1261
1260
|
* OraNumber(-123.456).truncate(-1) # => #<OraNumber:-120>
|
1262
1261
|
*
|
1263
|
-
* @param [Integer]
|
1262
|
+
* @param [Integer] decplace
|
1264
1263
|
* @return [OraNumber]
|
1265
1264
|
* @todo returns <i>Integer</i> when <i>decplace</i> is not specified.
|
1266
1265
|
*/
|
@@ -1276,8 +1275,7 @@ static VALUE onum_trunc(int argc, VALUE *argv, VALUE self)
|
|
1276
1275
|
}
|
1277
1276
|
|
1278
1277
|
/*
|
1279
|
-
*
|
1280
|
-
* round_prec(digits)
|
1278
|
+
* @overload round_prec(digits)
|
1281
1279
|
*
|
1282
1280
|
* Rounds <i>self</i> to a specified number of decimal digits.
|
1283
1281
|
* This method is available on Oracle 8.1 client or upper.
|
@@ -1287,6 +1285,7 @@ static VALUE onum_trunc(int argc, VALUE *argv, VALUE self)
|
|
1287
1285
|
* OraNumber(12.34).round_prec(2) # => #<OraNumber:12>
|
1288
1286
|
* OraNumber(123.4).round_prec(2) # => #<OraNumber:120>
|
1289
1287
|
*
|
1288
|
+
* @param [Integer] digits
|
1290
1289
|
* @return [OraNumber]
|
1291
1290
|
*/
|
1292
1291
|
static VALUE onum_round_prec(VALUE self, VALUE ndigs)
|
@@ -1299,12 +1298,11 @@ static VALUE onum_round_prec(VALUE self, VALUE ndigs)
|
|
1299
1298
|
}
|
1300
1299
|
|
1301
1300
|
/*
|
1302
|
-
*
|
1303
|
-
* onum.to_char(fmt = nil, nlsparam = nil)
|
1301
|
+
* @overload onum.to_char(fmt = nil, nlsparam = nil)
|
1304
1302
|
*
|
1305
1303
|
* Returns a string containing a representation of self.
|
1306
1304
|
* <i>fmt</i> and <i>nlsparam</i> are used as
|
1307
|
-
* {http://docs.oracle.com/
|
1305
|
+
* {http://docs.oracle.com/database/121/SQLRF/functions216.htm Oracle SQL function TO_CHAR(number)}
|
1308
1306
|
* does.
|
1309
1307
|
*
|
1310
1308
|
* @example
|
@@ -1365,6 +1363,8 @@ static VALUE onum_to_char(int argc, VALUE *argv, VALUE self)
|
|
1365
1363
|
}
|
1366
1364
|
|
1367
1365
|
/*
|
1366
|
+
* @overload to_s
|
1367
|
+
*
|
1368
1368
|
* Returns a string containing a representation of self.
|
1369
1369
|
*
|
1370
1370
|
* @return [String]
|
@@ -1377,6 +1377,8 @@ static VALUE onum_to_s(VALUE self)
|
|
1377
1377
|
}
|
1378
1378
|
|
1379
1379
|
/*
|
1380
|
+
* @overload to_i
|
1381
|
+
*
|
1380
1382
|
* Returns <i>self</i> truncated to an <code>Integer</code>.
|
1381
1383
|
*
|
1382
1384
|
* @return [Integer]
|
@@ -1406,6 +1408,8 @@ static VALUE onum_to_f(VALUE self)
|
|
1406
1408
|
}
|
1407
1409
|
|
1408
1410
|
/*
|
1411
|
+
* @overload to_r
|
1412
|
+
*
|
1409
1413
|
* Returns <i>self</i> as a <code>Rational</code>.
|
1410
1414
|
*
|
1411
1415
|
* @return [Rational]
|
@@ -1447,6 +1451,8 @@ static VALUE onum_to_r(VALUE self)
|
|
1447
1451
|
}
|
1448
1452
|
|
1449
1453
|
/*
|
1454
|
+
* @overload to_d
|
1455
|
+
*
|
1450
1456
|
* Returns <i>self</i> as a <code>BigDecimal</code>.
|
1451
1457
|
*
|
1452
1458
|
* @return [BigDecimal]
|
@@ -1473,13 +1479,14 @@ static VALUE onum_to_d_real(OCINumber *num, OCIError *errhp)
|
|
1473
1479
|
}
|
1474
1480
|
|
1475
1481
|
/*
|
1482
|
+
* @overload has_decimal_part?
|
1483
|
+
*
|
1476
1484
|
* Returns <code>true</code> if <i>self</i> has a decimal part.
|
1477
1485
|
*
|
1478
1486
|
* @example
|
1479
1487
|
* OraNumber(10).has_decimal_part? # => false
|
1480
1488
|
* OraNumber(10.1).has_decimal_part? # => true
|
1481
1489
|
*
|
1482
|
-
* @return [true or false]
|
1483
1490
|
* @since 2.0.5
|
1484
1491
|
*/
|
1485
1492
|
static VALUE onum_has_decimal_part_p(VALUE self)
|
@@ -1492,6 +1499,8 @@ static VALUE onum_has_decimal_part_p(VALUE self)
|
|
1492
1499
|
}
|
1493
1500
|
|
1494
1501
|
/*
|
1502
|
+
* @overload to_onum
|
1503
|
+
*
|
1495
1504
|
* Returns self.
|
1496
1505
|
*
|
1497
1506
|
* @return [OraNumber]
|
@@ -1502,9 +1511,10 @@ static VALUE onum_to_onum(VALUE self)
|
|
1502
1511
|
}
|
1503
1512
|
|
1504
1513
|
/*
|
1514
|
+
* @overload zero?
|
1515
|
+
*
|
1505
1516
|
* Returns <code>true</code> if <i>self</i> is zero.
|
1506
1517
|
*
|
1507
|
-
* @return [true or false]
|
1508
1518
|
*/
|
1509
1519
|
static VALUE onum_zero_p(VALUE self)
|
1510
1520
|
{
|
@@ -1516,6 +1526,8 @@ static VALUE onum_zero_p(VALUE self)
|
|
1516
1526
|
}
|
1517
1527
|
|
1518
1528
|
/*
|
1529
|
+
* @overload abs
|
1530
|
+
*
|
1519
1531
|
* Returns the absolute value of <i>self</i>.
|
1520
1532
|
*
|
1521
1533
|
* @return [OraNumber]
|
@@ -1530,8 +1542,7 @@ static VALUE onum_abs(VALUE self)
|
|
1530
1542
|
}
|
1531
1543
|
|
1532
1544
|
/*
|
1533
|
-
*
|
1534
|
-
* shift(ndigits)
|
1545
|
+
* @overload shift(ndigits)
|
1535
1546
|
*
|
1536
1547
|
* Returns <i>self</i> shifted by <i>ndigits</i>
|
1537
1548
|
* This method is available on Oracle 8.1 client or upper.
|
@@ -1540,6 +1551,7 @@ static VALUE onum_abs(VALUE self)
|
|
1540
1551
|
* OraNumber(123).shift(3) # => #<OraNumber:123000>
|
1541
1552
|
* OraNumber(123).shift(-3) # => #<OraNumber:0.123>
|
1542
1553
|
*
|
1554
|
+
* @param [Integer] ndigits
|
1543
1555
|
* @return [OraNumber]
|
1544
1556
|
*/
|
1545
1557
|
static VALUE onum_shift(VALUE self, VALUE exp)
|
@@ -1552,8 +1564,10 @@ static VALUE onum_shift(VALUE self, VALUE exp)
|
|
1552
1564
|
}
|
1553
1565
|
|
1554
1566
|
/*
|
1567
|
+
* @overload dump
|
1568
|
+
*
|
1555
1569
|
* Returns internal representation whose format is same with the return value of
|
1556
|
-
* {http://docs.oracle.com/
|
1570
|
+
* {http://docs.oracle.com/database/121/SQLRF/functions062.htm Oracle SQL function DUMP}.
|
1557
1571
|
*
|
1558
1572
|
* @example
|
1559
1573
|
* OraNumber.new(100).dump #=> "Typ=2 Len=2: 194,2"
|
@@ -1575,7 +1589,7 @@ static VALUE onum_dump(VALUE self)
|
|
1575
1589
|
*/
|
1576
1590
|
static VALUE onum_hash(VALUE self)
|
1577
1591
|
{
|
1578
|
-
char *c =
|
1592
|
+
char *c = RTYPEDDATA_DATA(self);
|
1579
1593
|
int size = c[0] + 1;
|
1580
1594
|
long i, hash;
|
1581
1595
|
|
@@ -1606,8 +1620,7 @@ static VALUE onum_inspect(VALUE self)
|
|
1606
1620
|
}
|
1607
1621
|
|
1608
1622
|
/*
|
1609
|
-
*
|
1610
|
-
* _dump
|
1623
|
+
* @overload _dump
|
1611
1624
|
*
|
1612
1625
|
* Serializes <i>self</i>.
|
1613
1626
|
* This method is called by Marshal.dump().
|
@@ -1617,7 +1630,7 @@ static VALUE onum_inspect(VALUE self)
|
|
1617
1630
|
*/
|
1618
1631
|
static VALUE onum__dump(int argc, VALUE *argv, VALUE self)
|
1619
1632
|
{
|
1620
|
-
char *c =
|
1633
|
+
char *c = RTYPEDDATA_DATA(self);
|
1621
1634
|
int size = c[0] + 1;
|
1622
1635
|
VALUE dummy;
|
1623
1636
|
|
@@ -1626,15 +1639,14 @@ static VALUE onum__dump(int argc, VALUE *argv, VALUE self)
|
|
1626
1639
|
}
|
1627
1640
|
|
1628
1641
|
/*
|
1629
|
-
*
|
1630
|
-
* _load(bytes)
|
1642
|
+
* @overload _load(bytes)
|
1631
1643
|
*
|
1632
1644
|
* Restores a byte stream serialized by {OraNumber#_dump}.
|
1633
1645
|
* This method is called by Marshal.load() to deserialize a byte stream
|
1634
1646
|
* created by Marshal.dump().
|
1635
1647
|
*
|
1636
1648
|
* @param [String] bytes a byte stream
|
1637
|
-
* @return [OraNumber]
|
1649
|
+
* @return [OraNumber] a deserialized object
|
1638
1650
|
*/
|
1639
1651
|
static VALUE
|
1640
1652
|
onum_s_load(VALUE klass, VALUE str)
|
@@ -1712,9 +1724,20 @@ static void bind_ocinumber_init_elem(oci8_bind_t *obind, VALUE svc)
|
|
1712
1724
|
} while (++idx < obind->maxar_sz);
|
1713
1725
|
}
|
1714
1726
|
|
1715
|
-
static const
|
1727
|
+
static const oci8_bind_data_type_t bind_ocinumber_data_type = {
|
1716
1728
|
{
|
1717
|
-
|
1729
|
+
{
|
1730
|
+
"OCI8::BindType::OraNumber",
|
1731
|
+
{
|
1732
|
+
NULL,
|
1733
|
+
oci8_handle_cleanup,
|
1734
|
+
oci8_handle_size,
|
1735
|
+
},
|
1736
|
+
&oci8_bind_data_type.rb_data_type, NULL,
|
1737
|
+
#ifdef RUBY_TYPED_WB_PROTECTED
|
1738
|
+
RUBY_TYPED_WB_PROTECTED,
|
1739
|
+
#endif
|
1740
|
+
},
|
1718
1741
|
oci8_bind_free,
|
1719
1742
|
sizeof(oci8_bind_t)
|
1720
1743
|
},
|
@@ -1726,9 +1749,25 @@ static const oci8_bind_vtable_t bind_ocinumber_vtable = {
|
|
1726
1749
|
SQLT_VNU,
|
1727
1750
|
};
|
1728
1751
|
|
1729
|
-
static
|
1752
|
+
static VALUE bind_ocinumber_alloc(VALUE klass)
|
1753
|
+
{
|
1754
|
+
return oci8_allocate_typeddata(klass, &bind_ocinumber_data_type.base);
|
1755
|
+
}
|
1756
|
+
|
1757
|
+
static const oci8_bind_data_type_t bind_integer_data_type = {
|
1730
1758
|
{
|
1731
|
-
|
1759
|
+
{
|
1760
|
+
"OCI8::BindType::Integer",
|
1761
|
+
{
|
1762
|
+
NULL,
|
1763
|
+
oci8_handle_cleanup,
|
1764
|
+
oci8_handle_size,
|
1765
|
+
},
|
1766
|
+
&oci8_bind_data_type.rb_data_type, NULL,
|
1767
|
+
#ifdef RUBY_TYPED_WB_PROTECTED
|
1768
|
+
RUBY_TYPED_WB_PROTECTED,
|
1769
|
+
#endif
|
1770
|
+
},
|
1732
1771
|
oci8_bind_free,
|
1733
1772
|
sizeof(oci8_bind_t)
|
1734
1773
|
},
|
@@ -1740,9 +1779,25 @@ static const oci8_bind_vtable_t bind_integer_vtable = {
|
|
1740
1779
|
SQLT_VNU,
|
1741
1780
|
};
|
1742
1781
|
|
1743
|
-
static
|
1782
|
+
static VALUE bind_integer_alloc(VALUE klass)
|
1783
|
+
{
|
1784
|
+
return oci8_allocate_typeddata(klass, &bind_integer_data_type.base);
|
1785
|
+
}
|
1786
|
+
|
1787
|
+
static const oci8_bind_data_type_t bind_float_data_type = {
|
1744
1788
|
{
|
1745
|
-
|
1789
|
+
{
|
1790
|
+
"OCI8::BindType::Float",
|
1791
|
+
{
|
1792
|
+
NULL,
|
1793
|
+
oci8_handle_cleanup,
|
1794
|
+
oci8_handle_size,
|
1795
|
+
},
|
1796
|
+
&oci8_bind_data_type.rb_data_type, NULL,
|
1797
|
+
#ifdef RUBY_TYPED_WB_PROTECTED
|
1798
|
+
RUBY_TYPED_WB_PROTECTED,
|
1799
|
+
#endif
|
1800
|
+
},
|
1746
1801
|
oci8_bind_free,
|
1747
1802
|
sizeof(oci8_bind_t)
|
1748
1803
|
},
|
@@ -1754,6 +1809,11 @@ static const oci8_bind_vtable_t bind_float_vtable = {
|
|
1754
1809
|
SQLT_VNU,
|
1755
1810
|
};
|
1756
1811
|
|
1812
|
+
static VALUE bind_float_alloc(VALUE klass)
|
1813
|
+
{
|
1814
|
+
return oci8_allocate_typeddata(klass, &bind_float_data_type.base);
|
1815
|
+
}
|
1816
|
+
|
1757
1817
|
void
|
1758
1818
|
Init_oci_number(VALUE cOCI8, OCIError *errhp)
|
1759
1819
|
{
|
@@ -1867,9 +1927,9 @@ Init_oci_number(VALUE cOCI8, OCIError *errhp)
|
|
1867
1927
|
rb_define_method(cOCINumber, "_dump", onum__dump, -1);
|
1868
1928
|
rb_define_singleton_method(cOCINumber, "_load", onum_s_load, 1);
|
1869
1929
|
|
1870
|
-
oci8_define_bind_class("OraNumber", &
|
1871
|
-
oci8_define_bind_class("Integer", &
|
1872
|
-
oci8_define_bind_class("Float", &
|
1930
|
+
oci8_define_bind_class("OraNumber", &bind_ocinumber_data_type, bind_ocinumber_alloc);
|
1931
|
+
oci8_define_bind_class("Integer", &bind_integer_data_type, bind_integer_alloc);
|
1932
|
+
oci8_define_bind_class("Float", &bind_float_data_type, bind_float_alloc);
|
1873
1933
|
|
1874
1934
|
#if 0 /* for rdoc/yard */
|
1875
1935
|
oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
|