ruby-oci8 2.0.4 → 2.0.5
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.
- data/ChangeLog +158 -1
- data/Makefile +1 -3
- data/NEWS +70 -0
- data/VERSION +1 -1
- data/dist-files +1 -0
- data/ext/oci8/apiwrap.yml +284 -138
- data/ext/oci8/attr.c +1 -1
- data/ext/oci8/bind.c +36 -9
- data/ext/oci8/env.c +59 -33
- data/ext/oci8/error.c +4 -0
- data/ext/oci8/extconf.rb +15 -1
- data/ext/oci8/lob.c +44 -0
- data/ext/oci8/metadata.c +1 -1
- data/ext/oci8/object.c +55 -0
- data/ext/oci8/oci8.c +9 -14
- data/ext/oci8/oci8.h +39 -25
- data/ext/oci8/oci8lib.c +38 -3
- data/ext/oci8/ocidatetime.c +69 -80
- data/ext/oci8/ocihandle.c +9 -1
- data/ext/oci8/ocinumber.c +40 -18
- data/ext/oci8/oraconf.rb +126 -126
- data/ext/oci8/oradate.c +2 -2
- data/ext/oci8/oranumber_util.c +38 -1
- data/ext/oci8/stmt.c +28 -22
- data/ext/oci8/win32.c +9 -3
- data/lib/oci8.rb.in +13 -2
- data/lib/oci8/.document +1 -0
- data/lib/oci8/bindtype.rb +16 -3
- data/lib/oci8/datetime.rb +14 -6
- data/lib/oci8/encoding-init.rb +6 -1
- data/lib/oci8/encoding.yml +2 -2
- data/lib/oci8/object.rb +28 -9
- data/lib/oci8/oci8.rb +22 -6
- data/lib/oci8/properties.rb +50 -0
- data/test/test_break.rb +6 -7
- data/test/test_oranumber.rb +96 -5
- metadata +7 -4
data/ext/oci8/oci8.c
CHANGED
@@ -263,12 +263,12 @@ static VALUE oci8_svcctx_initialize(int argc, VALUE *argv, VALUE self)
|
|
263
263
|
RSTRING_ORATEXT(vpassword), RSTRING_LEN(vpassword),
|
264
264
|
NIL_P(vdbname) ? NULL : RSTRING_ORATEXT(vdbname),
|
265
265
|
NIL_P(vdbname) ? 0 : RSTRING_LEN(vdbname));
|
266
|
+
if (IS_OCI_ERROR(rv)) {
|
267
|
+
oci8_raise(oci8_errhp, rv, NULL);
|
268
|
+
}
|
266
269
|
svcctx->base.hp.svc = svchp;
|
267
270
|
svcctx->base.type = OCI_HTYPE_SVCCTX;
|
268
271
|
svcctx->logon_type = T_IMPLICIT;
|
269
|
-
if (rv != OCI_SUCCESS) {
|
270
|
-
oci8_raise(oci8_errhp, rv, NULL);
|
271
|
-
}
|
272
272
|
break;
|
273
273
|
case T_EXPLICIT:
|
274
274
|
/* allocate OCI handles. */
|
@@ -313,7 +313,7 @@ static VALUE oci8_svcctx_initialize(int argc, VALUE *argv, VALUE self)
|
|
313
313
|
}
|
314
314
|
svcctx->pid = getpid();
|
315
315
|
svcctx->is_autocommit = 0;
|
316
|
-
#ifdef
|
316
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
317
317
|
svcctx->non_blocking = 1;
|
318
318
|
#endif
|
319
319
|
svcctx->long_read_len = INT2FIX(65535);
|
@@ -417,7 +417,7 @@ static VALUE oci8_rollback(VALUE self)
|
|
417
417
|
static VALUE oci8_non_blocking_p(VALUE self)
|
418
418
|
{
|
419
419
|
oci8_svcctx_t *svcctx = DATA_PTR(self);
|
420
|
-
#ifdef
|
420
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
421
421
|
return svcctx->non_blocking ? Qtrue : Qfalse;
|
422
422
|
#else
|
423
423
|
sb1 non_blocking;
|
@@ -470,7 +470,7 @@ static VALUE oci8_non_blocking_p(VALUE self)
|
|
470
470
|
static VALUE oci8_set_non_blocking(VALUE self, VALUE val)
|
471
471
|
{
|
472
472
|
oci8_svcctx_t *svcctx = DATA_PTR(self);
|
473
|
-
#ifdef
|
473
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
474
474
|
svcctx->non_blocking = RTEST(val);
|
475
475
|
#else
|
476
476
|
sb1 non_blocking;
|
@@ -560,14 +560,14 @@ static VALUE oci8_set_long_read_len(VALUE self, VALUE val)
|
|
560
560
|
static VALUE oci8_break(VALUE self)
|
561
561
|
{
|
562
562
|
oci8_svcctx_t *svcctx = DATA_PTR(self);
|
563
|
-
#ifndef
|
563
|
+
#ifndef HAVE_RB_THREAD_BLOCKING_REGION
|
564
564
|
sword rv;
|
565
565
|
#endif
|
566
566
|
|
567
567
|
if (NIL_P(svcctx->executing_thread)) {
|
568
568
|
return Qfalse;
|
569
569
|
}
|
570
|
-
#ifndef
|
570
|
+
#ifndef HAVE_RB_THREAD_BLOCKING_REGION
|
571
571
|
rv = OCIBreak(svcctx->base.hp.ptr, oci8_errhp);
|
572
572
|
if (rv != OCI_SUCCESS)
|
573
573
|
oci8_raise(oci8_errhp, rv, NULL);
|
@@ -992,12 +992,7 @@ VALUE Init_oci8(void)
|
|
992
992
|
|
993
993
|
oci8_svcctx_t *oci8_get_svcctx(VALUE obj)
|
994
994
|
{
|
995
|
-
|
996
|
-
Check_Handle(obj, cOCI8, base);
|
997
|
-
if (base->type == 0) {
|
998
|
-
rb_raise(eOCIException, "invalid argument %s was freed already.", rb_class2name(CLASS_OF(obj)));
|
999
|
-
}
|
1000
|
-
return (oci8_svcctx_t *)base;
|
995
|
+
return (oci8_svcctx_t *)oci8_get_handle(obj, cOCI8);
|
1001
996
|
}
|
1002
997
|
|
1003
998
|
OCISvcCtx *oci8_get_oci_svcctx(VALUE obj)
|
data/ext/oci8/oci8.h
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* oci8.h - part of ruby-oci8
|
4
4
|
*
|
5
|
-
* Copyright (C) 2002-
|
5
|
+
* Copyright (C) 2002-2011 KUBO Takehiro <kubo@jiubao.org>
|
6
6
|
*/
|
7
7
|
#ifndef _RUBY_OCI_H_
|
8
8
|
#define _RUBY_OCI_H_ 1
|
@@ -74,10 +74,10 @@ typedef orasb8 sb8;
|
|
74
74
|
#ifndef HAVE_TYPE_ORATEXT
|
75
75
|
typedef unsigned char oratext;
|
76
76
|
#endif
|
77
|
-
#
|
77
|
+
#if !defined HAVE_TYPE_OCIDATETIME_ && !defined HAVE_TYPE_OCIDATETIMEP
|
78
78
|
typedef struct OCIDateTime OCIDateTime;
|
79
79
|
#endif
|
80
|
-
#
|
80
|
+
#if !defined HAVE_TYPE_OCIINTERVAL_ && !defined HAVE_TYPE_OCIINTERVALP
|
81
81
|
typedef struct OCIInterval OCIInterval;
|
82
82
|
#endif
|
83
83
|
#ifndef HAVE_TYPE_OCICALLBACKLOBREAD2
|
@@ -90,10 +90,10 @@ typedef sb4 (*OCICallbackLobWrite2)(dvoid *ctxp, dvoid *bufp, oraub8 *lenp,
|
|
90
90
|
ub1 *piece, dvoid **changed_bufpp,
|
91
91
|
oraub8 *changed_lenp);
|
92
92
|
#endif
|
93
|
-
#
|
93
|
+
#if !defined HAVE_TYPE_OCIADMIN_ && !defined HAVE_TYPE_OCIADMINP
|
94
94
|
typedef struct OCIAdmin OCIAdmin;
|
95
95
|
#endif
|
96
|
-
#
|
96
|
+
#if !defined HAVE_TYPE_OCIMSG_ && !defined HAVE_TYPE_OCIMSGP
|
97
97
|
typedef struct OCIMsg OCIMsg;
|
98
98
|
#endif
|
99
99
|
|
@@ -116,9 +116,6 @@ typedef struct OCIMsg OCIMsg;
|
|
116
116
|
/* new macros in ruby 1.9.
|
117
117
|
* define compatible macros for ruby 1.8 or lower.
|
118
118
|
*/
|
119
|
-
#ifndef RCLASS_SUPER
|
120
|
-
#define RCLASS_SUPER(c) RCLASS(c)->super
|
121
|
-
#endif
|
122
119
|
#ifndef RFLOAT_VALUE
|
123
120
|
#define RFLOAT_VALUE(obj) RFLOAT(obj)->value
|
124
121
|
#endif
|
@@ -135,7 +132,7 @@ typedef struct OCIMsg OCIMsg;
|
|
135
132
|
#if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO)
|
136
133
|
#define rb_errinfo() ruby_errinfo
|
137
134
|
#endif
|
138
|
-
#ifndef
|
135
|
+
#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
|
139
136
|
typedef VALUE rb_blocking_function_t(void *);
|
140
137
|
#endif
|
141
138
|
|
@@ -149,6 +146,17 @@ typedef VALUE rb_blocking_function_t(void *);
|
|
149
146
|
#define rb_usascii_str_new_cstr(ptr) rb_str_new2(ptr)
|
150
147
|
#endif
|
151
148
|
|
149
|
+
/* a new function in ruby 1.9.3.
|
150
|
+
* define a compatible macro for ruby 1.9.2 or lower.
|
151
|
+
*/
|
152
|
+
#ifndef HAVE_RB_CLASS_SUPERCLASS
|
153
|
+
#ifdef RCLASS_SUPER
|
154
|
+
#define rb_class_superclass(cls) RCLASS_SUPER(cls)
|
155
|
+
#else
|
156
|
+
#define rb_class_superclass(cls) (RCLASS(cls)->super)
|
157
|
+
#endif
|
158
|
+
#endif
|
159
|
+
|
152
160
|
/* macros depends on the compiler.
|
153
161
|
* LIKELY(x) hint for the compiler that 'x' is 1(TRUE) in many cases.
|
154
162
|
* UNLIKELY(x) hint for the compiler that 'x' is 0(FALSE) in many cases.
|
@@ -173,10 +181,6 @@ typedef VALUE rb_blocking_function_t(void *);
|
|
173
181
|
#endif
|
174
182
|
|
175
183
|
/* macros to access thread-local storage.
|
176
|
-
*
|
177
|
-
* int oci8_tls_key_init(oci8_tls_key_t *key);
|
178
|
-
* initialie a key to access thread-local storege
|
179
|
-
* This returns 0 on success or error number.
|
180
184
|
*
|
181
185
|
* void *oci8_tls_get(oci8_tls_key_t key);
|
182
186
|
* get a value associated with the key.
|
@@ -185,26 +189,20 @@ typedef VALUE rb_blocking_function_t(void *);
|
|
185
189
|
* set a value to the key.
|
186
190
|
*
|
187
191
|
*/
|
188
|
-
#ifdef
|
192
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
189
193
|
/* ruby 1.9 */
|
190
194
|
#if defined(_WIN32)
|
191
195
|
#include <windows.h>
|
192
196
|
#define oci8_tls_key_t DWORD
|
193
|
-
#define oci8_tls_key_init(key_p) \
|
194
|
-
((*(key_p) = TlsAlloc()), \
|
195
|
-
(*(key_p) == 0xFFFFFFFF) ? GetLastError() : 0)
|
196
197
|
#define oci8_tls_get(key) TlsGetValue(key)
|
197
198
|
#define oci8_tls_set(key, val) TlsSetValue((key), (val))
|
198
|
-
#
|
199
|
+
#else
|
199
200
|
#include <pthread.h>
|
200
201
|
#define oci8_tls_key_t pthread_key_t
|
201
|
-
#define oci8_tls_key_init(key_p) pthread_key_create((key_p), NULL)
|
202
202
|
#define oci8_tls_get(key) pthread_getspecific(key)
|
203
203
|
#define oci8_tls_set(key, val) pthread_setspecific((key), (val))
|
204
|
-
#else
|
205
|
-
#error unsupported thread API
|
206
204
|
#endif
|
207
|
-
#endif /*
|
205
|
+
#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
|
208
206
|
|
209
207
|
/* utility macros
|
210
208
|
*/
|
@@ -310,7 +308,7 @@ typedef struct {
|
|
310
308
|
OCIServer *srvhp;
|
311
309
|
rb_pid_t pid;
|
312
310
|
char is_autocommit;
|
313
|
-
#ifdef
|
311
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
314
312
|
char non_blocking;
|
315
313
|
#endif
|
316
314
|
VALUE long_read_len;
|
@@ -364,7 +362,7 @@ typedef struct {
|
|
364
362
|
* extern OCIError *oci8_errhp;
|
365
363
|
*/
|
366
364
|
#define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp())
|
367
|
-
#ifdef
|
365
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
368
366
|
#define oci8_errhp oci8_get_errhp()
|
369
367
|
#else
|
370
368
|
#define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp())
|
@@ -374,7 +372,7 @@ typedef struct {
|
|
374
372
|
extern ub4 oci8_env_mode;
|
375
373
|
extern OCIEnv *oci8_global_envhp;
|
376
374
|
OCIEnv *oci8_make_envhp(void);
|
377
|
-
#ifdef
|
375
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
378
376
|
extern oci8_tls_key_t oci8_tls_key; /* native thread key */
|
379
377
|
OCIError *oci8_make_errhp(void);
|
380
378
|
|
@@ -396,6 +394,17 @@ extern ID oci8_id_get;
|
|
396
394
|
extern ID oci8_id_set;
|
397
395
|
extern ID oci8_id_keys;
|
398
396
|
extern ID oci8_id_oci8_class;
|
397
|
+
#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
|
398
|
+
extern ID oci8_id_add_op; /* ID of the addition operator '+' */
|
399
|
+
extern ID oci8_id_sub_op; /* ID of the subtraction operator '-' */
|
400
|
+
extern ID oci8_id_mul_op; /* ID of the multiplication operator '*' */
|
401
|
+
extern ID oci8_id_div_op; /* ID of the division operator '/' */
|
402
|
+
#else
|
403
|
+
#define oci8_id_add_op '+'
|
404
|
+
#define oci8_id_sub_op '-'
|
405
|
+
#define oci8_id_mul_op '*'
|
406
|
+
#define oci8_id_div_op '/'
|
407
|
+
#endif
|
399
408
|
extern int oci8_in_finalizer;
|
400
409
|
extern VALUE oci8_cOCIHandle;
|
401
410
|
void oci8_base_free(oci8_base_t *base);
|
@@ -409,6 +418,7 @@ sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_
|
|
409
418
|
#if defined RUNTIME_API_CHECK
|
410
419
|
void *oci8_find_symbol(const char *symbol_name);
|
411
420
|
#endif
|
421
|
+
oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass);
|
412
422
|
|
413
423
|
/* error.c */
|
414
424
|
extern VALUE eOCIException;
|
@@ -460,6 +470,10 @@ VALUE oci8_make_clob(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
|
460
470
|
VALUE oci8_make_nclob(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
461
471
|
VALUE oci8_make_blob(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
462
472
|
VALUE oci8_make_bfile(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
473
|
+
void oci8_assign_clob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
|
474
|
+
void oci8_assign_nclob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
|
475
|
+
void oci8_assign_blob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
|
476
|
+
void oci8_assign_bfile(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
|
463
477
|
|
464
478
|
/* oradate.c */
|
465
479
|
void Init_ora_date(void);
|
data/ext/oci8/oci8lib.c
CHANGED
@@ -15,6 +15,12 @@ ID oci8_id_get;
|
|
15
15
|
ID oci8_id_set;
|
16
16
|
ID oci8_id_keys;
|
17
17
|
ID oci8_id_oci8_class;
|
18
|
+
#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
|
19
|
+
ID oci8_id_add_op;
|
20
|
+
ID oci8_id_sub_op;
|
21
|
+
ID oci8_id_mul_op;
|
22
|
+
ID oci8_id_div_op;
|
23
|
+
#endif
|
18
24
|
int oci8_in_finalizer = 0;
|
19
25
|
VALUE oci8_cOCIHandle;
|
20
26
|
|
@@ -38,11 +44,16 @@ void oci8_base_free(oci8_base_t *base)
|
|
38
44
|
base->hp.ptr = NULL;
|
39
45
|
}
|
40
46
|
|
47
|
+
#ifdef HAVE_RB_SET_END_PROC
|
41
48
|
static void at_exit_func(VALUE val)
|
42
49
|
{
|
43
50
|
oci8_in_finalizer = 1;
|
44
51
|
}
|
52
|
+
#endif
|
45
53
|
|
54
|
+
#ifdef _WIN32
|
55
|
+
__declspec(dllexport)
|
56
|
+
#endif
|
46
57
|
void
|
47
58
|
Init_oci8lib()
|
48
59
|
{
|
@@ -65,7 +76,15 @@ Init_oci8lib()
|
|
65
76
|
oci8_id_set = rb_intern("set");
|
66
77
|
oci8_id_keys = rb_intern("keys");
|
67
78
|
oci8_id_oci8_class = rb_intern("__oci8_class__");
|
79
|
+
#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
|
80
|
+
oci8_id_add_op = rb_intern("+");
|
81
|
+
oci8_id_sub_op = rb_intern("-");
|
82
|
+
oci8_id_mul_op = rb_intern("*");
|
83
|
+
oci8_id_div_op = rb_intern("/");
|
84
|
+
#endif
|
85
|
+
#ifdef HAVE_RB_SET_END_PROC
|
68
86
|
rb_set_end_proc(at_exit_func, Qnil);
|
87
|
+
#endif
|
69
88
|
|
70
89
|
Init_oci8_error();
|
71
90
|
Init_oci8_env();
|
@@ -196,7 +215,7 @@ void oci8_unlink_from_parent(oci8_base_t *base)
|
|
196
215
|
base->parent = NULL;
|
197
216
|
}
|
198
217
|
|
199
|
-
#ifdef
|
218
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
200
219
|
|
201
220
|
#if 0
|
202
221
|
typedef struct {
|
@@ -251,7 +270,7 @@ sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, v
|
|
251
270
|
return (sword)func(data);
|
252
271
|
}
|
253
272
|
}
|
254
|
-
#else /*
|
273
|
+
#else /* HAVE_RB_THREAD_BLOCKING_REGION */
|
255
274
|
|
256
275
|
/* ruby 1.8 */
|
257
276
|
sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data)
|
@@ -281,7 +300,7 @@ sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, v
|
|
281
300
|
svcctx->executing_thread = Qnil;
|
282
301
|
return rv;
|
283
302
|
}
|
284
|
-
#endif /*
|
303
|
+
#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
|
285
304
|
|
286
305
|
typedef struct {
|
287
306
|
oci8_svcctx_t *svcctx;
|
@@ -468,3 +487,19 @@ void *oci8_find_symbol(const char *symbol_name)
|
|
468
487
|
#endif /* defined _WIN32 */
|
469
488
|
}
|
470
489
|
#endif /* RUNTIME_API_CHECK */
|
490
|
+
|
491
|
+
oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass)
|
492
|
+
{
|
493
|
+
oci8_base_t *hp;
|
494
|
+
|
495
|
+
if (!rb_obj_is_kind_of(obj, klass)) {
|
496
|
+
rb_raise(rb_eTypeError, "invalid argument %s (expect %s)",
|
497
|
+
rb_obj_classname(obj), rb_class2name(klass));
|
498
|
+
}
|
499
|
+
Data_Get_Struct(obj, oci8_base_t, hp);
|
500
|
+
if (hp->type == 0) {
|
501
|
+
rb_raise(rb_eRuntimeError, "%s was already closed.",
|
502
|
+
rb_obj_classname(obj));
|
503
|
+
}
|
504
|
+
return hp;
|
505
|
+
}
|
data/ext/oci8/ocidatetime.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* ocidatetime.c
|
4
4
|
*
|
5
5
|
* $Author: kubo $
|
6
|
-
* $Date:
|
6
|
+
* $Date: 2011-06-12 22:14:51 +0900 (日, 12 6月 2011) $
|
7
7
|
*
|
8
8
|
* Copyright (C) 2005-2008 KUBO Takehiro <kubo@jiubao.org>
|
9
9
|
*
|
@@ -102,7 +102,37 @@ static const oci8_bind_class_t bind_ocidate_class = {
|
|
102
102
|
|
103
103
|
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
|
104
104
|
|
105
|
-
|
105
|
+
static void bind_init_elem_common(oci8_bind_t *obind, VALUE svc, ub4 type)
|
106
|
+
{
|
107
|
+
ub4 idx = 0;
|
108
|
+
sword rv;
|
109
|
+
|
110
|
+
do {
|
111
|
+
rv = OCIDescriptorAlloc(oci8_envhp, (dvoid*)((dvoid**)obind->valuep + idx), type, 0, 0);
|
112
|
+
if (rv != OCI_SUCCESS)
|
113
|
+
oci8_env_raise(oci8_envhp, rv);
|
114
|
+
} while (++idx < obind->maxar_sz);
|
115
|
+
}
|
116
|
+
|
117
|
+
static void bind_free_common(oci8_base_t *base, ub4 type)
|
118
|
+
{
|
119
|
+
oci8_bind_t *obind = (oci8_bind_t *)base;
|
120
|
+
|
121
|
+
if (obind->valuep != NULL) {
|
122
|
+
ub4 idx = 0;
|
123
|
+
void **pp = (void**)obind->valuep;
|
124
|
+
|
125
|
+
do {
|
126
|
+
if (pp[idx] != NULL) {
|
127
|
+
OCIDescriptorFree(pp[idx], type);
|
128
|
+
pp[idx] = NULL;
|
129
|
+
}
|
130
|
+
} while (++idx < obind->maxar_sz);
|
131
|
+
}
|
132
|
+
oci8_bind_free(base);
|
133
|
+
}
|
134
|
+
|
135
|
+
VALUE oci8_make_ocitimestamp_tz(OCIDateTime *dttm)
|
106
136
|
{
|
107
137
|
sb2 year;
|
108
138
|
ub1 month;
|
@@ -113,13 +143,10 @@ VALUE oci8_make_ocitimestamp(OCIDateTime *dttm)
|
|
113
143
|
ub4 fsec;
|
114
144
|
sb1 tz_hour;
|
115
145
|
sb1 tz_minute;
|
116
|
-
sword rv;
|
117
|
-
int have_tz;
|
118
146
|
|
119
147
|
oci_lc(OCIDateTimeGetDate(oci8_envhp, oci8_errhp, dttm, &year, &month, &day));
|
120
148
|
oci_lc(OCIDateTimeGetTime(oci8_envhp, oci8_errhp, dttm, &hour, &minute, &sec, &fsec));
|
121
|
-
|
122
|
-
have_tz = (rv == OCI_SUCCESS);
|
149
|
+
oci_lc(OCIDateTimeGetTimeZoneOffset(oci8_envhp, oci8_errhp, dttm, &tz_hour, &tz_minute));
|
123
150
|
return rb_ary_new3(9,
|
124
151
|
INT2FIX(year),
|
125
152
|
INT2FIX(month),
|
@@ -128,11 +155,11 @@ VALUE oci8_make_ocitimestamp(OCIDateTime *dttm)
|
|
128
155
|
INT2FIX(minute),
|
129
156
|
INT2FIX(sec),
|
130
157
|
INT2FIX(fsec),
|
131
|
-
|
132
|
-
|
158
|
+
INT2FIX(tz_hour),
|
159
|
+
INT2FIX(tz_minute));
|
133
160
|
}
|
134
161
|
|
135
|
-
OCIDateTime *
|
162
|
+
OCIDateTime *oci8_set_ocitimestamp_tz(OCIDateTime *dttm, VALUE val, VALUE svc)
|
136
163
|
{
|
137
164
|
long year;
|
138
165
|
long month;
|
@@ -214,35 +241,12 @@ OCIDateTime *oci8_set_ocitimestamp(OCIDateTime *dttm, VALUE val, VALUE svc)
|
|
214
241
|
return dttm;
|
215
242
|
}
|
216
243
|
|
217
|
-
|
218
|
-
oci8_bind_t obind;
|
219
|
-
ub4 type;
|
220
|
-
} oci8_bind_dsc_t;
|
221
|
-
|
222
|
-
static void oci8_bind_dsc_free(oci8_base_t *base)
|
244
|
+
static VALUE bind_ocitimestamp_tz_get(oci8_bind_t *obind, void *data, void *null_struct)
|
223
245
|
{
|
224
|
-
|
225
|
-
ub4 type = ((oci8_bind_dsc_t *)base)->type;
|
226
|
-
if (obind->valuep != NULL) {
|
227
|
-
ub4 idx = 0;
|
228
|
-
void **pp = (void**)obind->valuep;
|
229
|
-
|
230
|
-
do {
|
231
|
-
if (pp[idx] != NULL) {
|
232
|
-
OCIDescriptorFree(pp[idx], type);
|
233
|
-
pp[idx] = NULL;
|
234
|
-
}
|
235
|
-
} while (++idx < obind->maxar_sz);
|
236
|
-
}
|
237
|
-
oci8_bind_free(base);
|
238
|
-
}
|
239
|
-
|
240
|
-
static VALUE bind_ocitimestamp_get(oci8_bind_t *obind, void *data, void *null_struct)
|
241
|
-
{
|
242
|
-
return oci8_make_ocitimestamp(*(OCIDateTime **)data);
|
246
|
+
return oci8_make_ocitimestamp_tz(*(OCIDateTime **)data);
|
243
247
|
}
|
244
248
|
|
245
|
-
static void
|
249
|
+
static void bind_ocitimestamp_tz_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
|
246
250
|
{
|
247
251
|
oci8_base_t *parent;
|
248
252
|
oci8_base_t *svcctx;
|
@@ -259,41 +263,36 @@ static void bind_ocitimestamp_set(oci8_bind_t *obind, void *data, void **null_st
|
|
259
263
|
parent, parent ? parent->type : -1,
|
260
264
|
svcctx, svcctx ? svcctx->type : -1);
|
261
265
|
}
|
262
|
-
|
266
|
+
oci8_set_ocitimestamp_tz(*(OCIDateTime **)data, val, svcctx->self);
|
263
267
|
}
|
264
268
|
|
265
|
-
static void
|
269
|
+
static void bind_ocitimestamp_tz_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
266
270
|
{
|
267
|
-
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
|
268
|
-
|
269
271
|
oci8_link_to_parent((oci8_base_t*)obind, (oci8_base_t*)oci8_get_svcctx(svc));
|
270
272
|
obind->value_sz = sizeof(OCIDateTime *);
|
271
273
|
obind->alloc_sz = sizeof(OCIDateTime *);
|
272
|
-
obind_dsc->type = OCI_DTYPE_TIMESTAMP_TZ;
|
273
274
|
}
|
274
275
|
|
275
|
-
static void
|
276
|
+
static void bind_ocitimestamp_tz_init_elem(oci8_bind_t *obind, VALUE svc)
|
276
277
|
{
|
277
|
-
|
278
|
-
|
278
|
+
bind_init_elem_common(obind, svc, OCI_DTYPE_TIMESTAMP_TZ);
|
279
|
+
}
|
279
280
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
oci8_env_raise(oci8_envhp, rv);
|
284
|
-
} while (++idx < obind->maxar_sz);
|
281
|
+
static void bind_ocitimestamp_tz_free(oci8_base_t *base)
|
282
|
+
{
|
283
|
+
bind_free_common(base, OCI_DTYPE_TIMESTAMP_TZ);
|
285
284
|
}
|
286
285
|
|
287
|
-
static const oci8_bind_class_t
|
286
|
+
static const oci8_bind_class_t bind_ocitimestamp_tz_class = {
|
288
287
|
{
|
289
288
|
NULL,
|
290
|
-
|
291
|
-
sizeof(
|
289
|
+
bind_ocitimestamp_tz_free,
|
290
|
+
sizeof(oci8_bind_t)
|
292
291
|
},
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
292
|
+
bind_ocitimestamp_tz_get,
|
293
|
+
bind_ocitimestamp_tz_set,
|
294
|
+
bind_ocitimestamp_tz_init,
|
295
|
+
bind_ocitimestamp_tz_init_elem,
|
297
296
|
NULL,
|
298
297
|
NULL,
|
299
298
|
NULL,
|
@@ -417,23 +416,18 @@ static void bind_ociinterval_ym_set(oci8_bind_t *obind, void *data, void **null_
|
|
417
416
|
|
418
417
|
static void bind_ociinterval_ym_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
419
418
|
{
|
420
|
-
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
|
421
|
-
|
422
419
|
obind->value_sz = sizeof(OCIInterval*);
|
423
420
|
obind->alloc_sz = sizeof(OCIInterval*);
|
424
|
-
obind_dsc->type = OCI_DTYPE_INTERVAL_YM;
|
425
421
|
}
|
426
422
|
|
427
423
|
static void bind_ociinterval_ym_init_elem(oci8_bind_t *obind, VALUE svc)
|
428
424
|
{
|
429
|
-
|
430
|
-
|
425
|
+
bind_init_elem_common(obind, svc, OCI_DTYPE_INTERVAL_YM);
|
426
|
+
}
|
431
427
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
oci8_env_raise(oci8_envhp, rv);
|
436
|
-
} while (++idx < obind->maxar_sz);
|
428
|
+
static void bind_ociinterval_ym_free(oci8_base_t *base)
|
429
|
+
{
|
430
|
+
bind_free_common(base, OCI_DTYPE_INTERVAL_YM);
|
437
431
|
}
|
438
432
|
|
439
433
|
static VALUE bind_ociinterval_ds_get(oci8_bind_t *obind, void *data, void *null_struct)
|
@@ -448,30 +442,25 @@ static void bind_ociinterval_ds_set(oci8_bind_t *obind, void *data, void **null_
|
|
448
442
|
|
449
443
|
static void bind_ociinterval_ds_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
|
450
444
|
{
|
451
|
-
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
|
452
|
-
|
453
445
|
obind->value_sz = sizeof(OCIInterval *);
|
454
446
|
obind->alloc_sz = sizeof(OCIInterval *);
|
455
|
-
obind_dsc->type = OCI_DTYPE_INTERVAL_DS;
|
456
447
|
}
|
457
448
|
|
458
449
|
static void bind_ociinterval_ds_init_elem(oci8_bind_t *obind, VALUE svc)
|
459
450
|
{
|
460
|
-
|
461
|
-
|
451
|
+
bind_init_elem_common(obind, svc, OCI_DTYPE_INTERVAL_DS);
|
452
|
+
}
|
462
453
|
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
oci8_env_raise(oci8_envhp, rv);
|
467
|
-
} while (++idx < obind->maxar_sz);
|
454
|
+
static void bind_ociinterval_ds_free(oci8_base_t *base)
|
455
|
+
{
|
456
|
+
bind_free_common(base, OCI_DTYPE_INTERVAL_DS);
|
468
457
|
}
|
469
458
|
|
470
459
|
static const oci8_bind_class_t bind_ociinterval_ym_class = {
|
471
460
|
{
|
472
461
|
NULL,
|
473
|
-
|
474
|
-
sizeof(
|
462
|
+
bind_ociinterval_ym_free,
|
463
|
+
sizeof(oci8_bind_t)
|
475
464
|
},
|
476
465
|
bind_ociinterval_ym_get,
|
477
466
|
bind_ociinterval_ym_set,
|
@@ -486,8 +475,8 @@ static const oci8_bind_class_t bind_ociinterval_ym_class = {
|
|
486
475
|
static const oci8_bind_class_t bind_ociinterval_ds_class = {
|
487
476
|
{
|
488
477
|
NULL,
|
489
|
-
|
490
|
-
sizeof(
|
478
|
+
bind_ociinterval_ds_free,
|
479
|
+
sizeof(oci8_bind_t)
|
491
480
|
},
|
492
481
|
bind_ociinterval_ds_get,
|
493
482
|
bind_ociinterval_ds_set,
|
@@ -507,7 +496,7 @@ void Init_oci_datetime(void)
|
|
507
496
|
|
508
497
|
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
|
509
498
|
if (oracle_client_version >= ORAVER_9_0) {
|
510
|
-
oci8_define_bind_class("
|
499
|
+
oci8_define_bind_class("OCITimestampTZ", &bind_ocitimestamp_tz_class);
|
511
500
|
oci8_define_bind_class("OCIIntervalYM", &bind_ociinterval_ym_class);
|
512
501
|
oci8_define_bind_class("OCIIntervalDS", &bind_ociinterval_ds_class);
|
513
502
|
}
|