ruby-oci8 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1254 -390
- data/Makefile +10 -13
- data/README +56 -385
- data/VERSION +1 -1
- data/dist-files +26 -27
- data/ext/oci8/.document +1 -0
- data/ext/oci8/MANIFEST +0 -4
- data/ext/oci8/apiwrap.c.tmpl +172 -0
- data/ext/oci8/apiwrap.h.tmpl +61 -0
- data/ext/oci8/apiwrap.rb +91 -0
- data/ext/oci8/apiwrap.yml +1243 -0
- data/ext/oci8/attr.c +124 -384
- data/ext/oci8/bind.c +472 -164
- data/ext/oci8/encoding.c +196 -0
- data/ext/oci8/env.c +84 -253
- data/ext/oci8/error.c +196 -127
- data/ext/oci8/extconf.rb +82 -59
- data/ext/oci8/lob.c +710 -370
- data/ext/oci8/metadata.c +359 -0
- data/ext/oci8/object.c +622 -0
- data/ext/oci8/oci8.c +577 -161
- data/ext/oci8/oci8.h +354 -258
- data/ext/oci8/oci8lib.c +493 -0
- data/ext/oci8/ocidatetime.c +473 -0
- data/ext/oci8/ocinumber.c +1123 -24
- data/ext/oci8/oraconf.rb +72 -106
- data/ext/oci8/oradate.c +511 -321
- data/ext/oci8/stmt.c +752 -572
- data/ext/oci8/win32.c +131 -0
- data/ext/oci8/xmldb.c +383 -0
- data/lib/.document +2 -0
- data/lib/dbd/OCI8.rb +2 -17
- data/lib/oci8.rb.in +41 -1622
- data/lib/oci8/.document +5 -0
- data/lib/oci8/compat.rb +108 -0
- data/lib/oci8/datetime.rb +489 -0
- data/lib/oci8/encoding-init.rb +40 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2077 -0
- data/lib/oci8/object.rb +548 -0
- data/lib/oci8/oci8.rb +773 -0
- data/lib/oci8/oracle_version.rb +144 -0
- data/metaconfig +3 -3
- data/ruby-oci8.gemspec +5 -5
- data/setup.rb +4 -4
- data/test/config.rb +64 -84
- data/test/test_all.rb +14 -21
- data/test/test_array_dml.rb +317 -0
- data/test/test_bind_raw.rb +18 -25
- data/test/test_bind_time.rb +78 -91
- data/test/test_break.rb +37 -35
- data/test/test_clob.rb +33 -89
- data/test/test_connstr.rb +5 -4
- data/test/test_datetime.rb +469 -0
- data/test/test_dbi.rb +99 -60
- data/test/test_dbi_clob.rb +3 -8
- data/test/test_metadata.rb +65 -51
- data/test/test_oci8.rb +151 -55
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +76 -83
- data/test/test_oranumber.rb +405 -71
- data/test/test_rowid.rb +6 -11
- metadata +31 -32
- data/NEWS +0 -420
- data/ext/oci8/const.c +0 -165
- data/ext/oci8/define.c +0 -53
- data/ext/oci8/describe.c +0 -81
- data/ext/oci8/descriptor.c +0 -39
- data/ext/oci8/handle.c +0 -273
- data/ext/oci8/oranumber.c +0 -445
- data/ext/oci8/param.c +0 -37
- data/ext/oci8/server.c +0 -182
- data/ext/oci8/session.c +0 -99
- data/ext/oci8/svcctx.c +0 -238
- data/ruby-oci8.spec +0 -62
- data/support/README +0 -4
- data/support/runit/assert.rb +0 -281
- data/support/runit/cui/testrunner.rb +0 -101
- data/support/runit/error.rb +0 -4
- data/support/runit/method_mappable.rb +0 -20
- data/support/runit/robserver.rb +0 -25
- data/support/runit/setuppable.rb +0 -15
- data/support/runit/teardownable.rb +0 -16
- data/support/runit/testcase.rb +0 -113
- data/support/runit/testfailure.rb +0 -25
- data/support/runit/testresult.rb +0 -121
- data/support/runit/testsuite.rb +0 -43
- data/support/runit/version.rb +0 -3
- data/test/test_describe.rb +0 -137
data/ext/oci8/oci8.h
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
1
2
|
/*
|
2
3
|
oci8.h - part of ruby-oci8
|
3
4
|
|
4
|
-
Copyright (C) 2002-
|
5
|
+
Copyright (C) 2002-2009 KUBO Takehiro <kubo@jiubao.org>
|
5
6
|
*/
|
6
7
|
#ifndef _RUBY_OCI_H_
|
7
8
|
#define _RUBY_OCI_H_ 1
|
8
9
|
|
9
10
|
#include "ruby.h"
|
10
|
-
#include "rubyio.h"
|
11
|
-
#include "intern.h"
|
12
11
|
|
13
12
|
#ifndef rb_pid_t
|
14
13
|
#ifdef WIN32
|
@@ -20,31 +19,49 @@
|
|
20
19
|
|
21
20
|
#include <stdio.h>
|
22
21
|
#include <stdlib.h>
|
22
|
+
#include <assert.h>
|
23
|
+
|
23
24
|
#ifdef __cplusplus
|
24
|
-
extern "C"
|
25
|
+
extern "C"
|
26
|
+
{
|
25
27
|
#endif
|
26
28
|
#include <oci.h>
|
27
29
|
#ifdef __cplusplus
|
28
30
|
}
|
29
31
|
#endif
|
32
|
+
#ifdef HAVE_XMLOTN_H
|
33
|
+
#include "xmlotn.h"
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#define ORAVERNUM(major, minor, update, patch, port_update) \
|
37
|
+
(((major) << 24) | ((minor) << 20) | ((update) << 12) | ((patch) << 8) | (port_update))
|
38
|
+
|
39
|
+
#define ORAVER_8_0 ORAVERNUM(8, 0, 0, 0, 0)
|
40
|
+
#define ORAVER_8_1 ORAVERNUM(8, 1, 0, 0, 0)
|
41
|
+
#define ORAVER_9_0 ORAVERNUM(9, 0, 0, 0, 0)
|
42
|
+
#define ORAVER_9_2 ORAVERNUM(9, 2, 0, 0, 0)
|
43
|
+
#define ORAVER_10_1 ORAVERNUM(10, 1, 0, 0, 0)
|
44
|
+
#define ORAVER_10_2 ORAVERNUM(10, 2, 0, 0, 0)
|
45
|
+
#define ORAVER_11_1 ORAVERNUM(11, 1, 0, 0, 0)
|
46
|
+
|
30
47
|
#include "extconf.h"
|
48
|
+
#ifdef HAVE_TYPE_RB_ENCODING
|
49
|
+
#include <ruby/encoding.h>
|
50
|
+
#endif
|
31
51
|
|
32
|
-
#
|
33
|
-
|
34
|
-
#define RBOCI_NORETURN(x) NORETURN(x)
|
35
|
-
#else
|
36
|
-
/* ruby 1.6 */
|
37
|
-
#define RBOCI_NORETURN(x) x NORETURN
|
38
|
-
#define rb_cstr_to_dbl(p, ignore) strtod((p), 0)
|
52
|
+
#if ACTUAL_ORACLE_CLIENT_VERSION < ORAVER_10_2
|
53
|
+
typedef struct OCIAdmin OCIAdmin;
|
39
54
|
#endif
|
40
55
|
|
56
|
+
/* new macros in ruby 1.8.6.
|
57
|
+
* define compatible macros for ruby 1.8.5 or lower.
|
58
|
+
*/
|
41
59
|
#ifndef RSTRING_PTR
|
42
60
|
#define RSTRING_PTR(obj) RSTRING(obj)->ptr
|
43
61
|
#endif
|
44
62
|
#ifndef RSTRING_LEN
|
45
63
|
#define RSTRING_LEN(obj) RSTRING(obj)->len
|
46
64
|
#endif
|
47
|
-
|
48
65
|
#ifndef RARRAY_PTR
|
49
66
|
#define RARRAY_PTR(obj) RARRAY(obj)->ptr
|
50
67
|
#endif
|
@@ -52,16 +69,49 @@ extern "C" {
|
|
52
69
|
#define RARRAY_LEN(obj) RARRAY(obj)->len
|
53
70
|
#endif
|
54
71
|
|
55
|
-
|
56
|
-
|
72
|
+
/* new macros in ruby 1.9.
|
73
|
+
* define compatible macros for ruby 1.8 or lower.
|
74
|
+
*/
|
75
|
+
#ifndef RCLASS_SUPER
|
76
|
+
#define RCLASS_SUPER(c) RCLASS(c)->super
|
77
|
+
#endif
|
78
|
+
#ifndef RFLOAT_VALUE
|
79
|
+
#define RFLOAT_VALUE(obj) RFLOAT(obj)->value
|
57
80
|
#endif
|
58
81
|
|
59
|
-
|
60
|
-
|
82
|
+
/* new functions in ruby 1.9.
|
83
|
+
* define compatible macros for ruby 1.8 or lower.
|
84
|
+
*/
|
85
|
+
#if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO)
|
86
|
+
#define rb_errinfo() ruby_errinfo
|
87
|
+
#endif
|
88
|
+
#ifndef RUBY_VM
|
89
|
+
typedef VALUE rb_blocking_function_t(void *);
|
61
90
|
#endif
|
62
91
|
|
63
|
-
#
|
92
|
+
#ifndef HAVE_TYPE_RB_ENCODING
|
93
|
+
#define rb_enc_associate(str, enc) do {} while(0)
|
94
|
+
#define rb_external_str_new_with_enc(ptr, len, enc) rb_tainted_str_new((ptr), (len))
|
95
|
+
#define rb_locale_str_new_cstr(ptr) rb_str_new2(ptr)
|
96
|
+
#define rb_str_conv_enc(str, from, to) (str)
|
97
|
+
#define rb_usascii_str_new(ptr, len) rb_str_new((ptr), (len))
|
98
|
+
#define rb_usascii_str_new_cstr(ptr) rb_str_new2(ptr)
|
99
|
+
#endif
|
64
100
|
|
101
|
+
/* macros depends on the compiler.
|
102
|
+
* LIKELY(x) hint for the compiler that 'x' is 1(TRUE) in many cases.
|
103
|
+
* UNLIKELY(x) hint for the compiler that 'x' is 0(FALSE) in many cases.
|
104
|
+
* ALWAYS_INLINE forcely inline the function.
|
105
|
+
*/
|
106
|
+
#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
|
107
|
+
/* gcc version >= 2.96 */
|
108
|
+
#define LIKELY(x) (__builtin_expect((x), 1))
|
109
|
+
#define UNLIKELY(x) (__builtin_expect((x), 0))
|
110
|
+
#else
|
111
|
+
/* other compilers */
|
112
|
+
#define LIKELY(x) (x)
|
113
|
+
#define UNLIKELY(x) (x)
|
114
|
+
#endif
|
65
115
|
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
66
116
|
/* gcc version >= 3.1 */
|
67
117
|
#define ALWAYS_INLINE inline __attribute__((always_inline))
|
@@ -71,294 +121,340 @@ typedef unsigned char oratext;
|
|
71
121
|
#define ALWAYS_INLINE __forceinline
|
72
122
|
#endif
|
73
123
|
|
74
|
-
|
75
|
-
|
76
|
-
*
|
77
|
-
*
|
124
|
+
/* macros to access thread-local storage.
|
125
|
+
*
|
126
|
+
* int oci8_tls_key_init(oci8_tls_key_t *key);
|
127
|
+
* initialie a key to access thread-local storege
|
128
|
+
* This returns 0 on success or error number.
|
129
|
+
*
|
130
|
+
* void *oci8_tls_get(oci8_tls_key_t key);
|
131
|
+
* get a value associated with the key.
|
132
|
+
*
|
133
|
+
* void oci8_tls_set(oci8_tls_key_t key, void *value);
|
134
|
+
* set a value to the key.
|
135
|
+
*
|
136
|
+
*/
|
137
|
+
#ifdef RUBY_VM
|
138
|
+
/* ruby 1.9 */
|
139
|
+
#if defined(_WIN32)
|
140
|
+
#include <windows.h>
|
141
|
+
#define oci8_tls_key_t DWORD
|
142
|
+
#define oci8_tls_key_init(key_p) \
|
143
|
+
((*(key_p) = TlsAlloc()), \
|
144
|
+
(*(key_p) == 0xFFFFFFFF) ? GetLastError() : 0)
|
145
|
+
#define oci8_tls_get(key) TlsGetValue(key)
|
146
|
+
#define oci8_tls_set(key, val) TlsSetValue((key), (val))
|
147
|
+
#elif defined(HAVE_PTHREAD_H)
|
148
|
+
#include <pthread.h>
|
149
|
+
#define oci8_tls_key_t pthread_key_t
|
150
|
+
#define oci8_tls_key_init(key_p) pthread_key_create((key_p), NULL)
|
151
|
+
#define oci8_tls_get(key) pthread_getspecific(key)
|
152
|
+
#define oci8_tls_set(key, val) pthread_setspecific((key), (val))
|
153
|
+
#else
|
154
|
+
#error unsupported thread API
|
155
|
+
#endif
|
156
|
+
#endif /* RUBY_VM */
|
157
|
+
|
158
|
+
/* utility macros
|
78
159
|
*/
|
160
|
+
#define IS_OCI_ERROR(v) (((v) != OCI_SUCCESS) && ((v) != OCI_SUCCESS_WITH_INFO))
|
161
|
+
#ifdef ALWAYS_INLINE
|
79
162
|
#define TO_ORATEXT to_oratext
|
80
163
|
#define TO_CHARPTR to_charptr
|
81
164
|
static ALWAYS_INLINE OraText *to_oratext(char *c)
|
82
165
|
{
|
83
|
-
|
166
|
+
return (OraText*)c;
|
84
167
|
}
|
85
168
|
static ALWAYS_INLINE char *to_charptr(OraText *c)
|
86
169
|
{
|
87
|
-
|
170
|
+
return (char*)c;
|
88
171
|
}
|
89
172
|
#else
|
90
|
-
/* if not gcc, use normal cast. */
|
91
173
|
#define TO_ORATEXT(c) ((OraText*)(c))
|
92
174
|
#define TO_CHARPTR(c) ((char*)(c))
|
93
175
|
#endif
|
94
176
|
#define RSTRING_ORATEXT(obj) TO_ORATEXT(RSTRING_PTR(obj))
|
177
|
+
#define rb_str_new2_ora(str) rb_str_new2(TO_CHARPTR(str))
|
95
178
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
BIND_FLOAT,
|
102
|
-
BIND_BINARY_DOUBLE,
|
103
|
-
BIND_ORA_DATE,
|
104
|
-
BIND_ORA_NUMBER,
|
105
|
-
BIND_HANDLE
|
106
|
-
};
|
179
|
+
/*
|
180
|
+
* prevent rdoc from gathering the specified method.
|
181
|
+
*/
|
182
|
+
#define rb_define_method_nodoc rb_define_method
|
183
|
+
#define rb_define_singleton_method_nodoc rb_define_singleton_method
|
107
184
|
|
108
|
-
/*
|
109
|
-
struct
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
unsigned char day;
|
114
|
-
unsigned char hour;
|
115
|
-
unsigned char minute;
|
116
|
-
unsigned char second;
|
117
|
-
};
|
118
|
-
typedef struct ora_date ora_date_t;
|
185
|
+
/* data structure for SQLT_LVC and SQLT_LVB. */
|
186
|
+
typedef struct {
|
187
|
+
sb4 size;
|
188
|
+
char buf[1];
|
189
|
+
} oci8_vstr_t;
|
119
190
|
|
120
|
-
|
121
|
-
struct
|
122
|
-
unsigned char exponent;
|
123
|
-
unsigned char mantissa[20];
|
124
|
-
};
|
125
|
-
typedef struct ora_number ora_number_t;
|
191
|
+
typedef struct oci8_base_class oci8_base_class_t;
|
192
|
+
typedef struct oci8_bind_class oci8_bind_class_t;
|
126
193
|
|
127
|
-
|
128
|
-
struct
|
129
|
-
|
130
|
-
|
194
|
+
typedef struct oci8_base oci8_base_t;
|
195
|
+
typedef struct oci8_bind oci8_bind_t;
|
196
|
+
|
197
|
+
struct oci8_base_class {
|
198
|
+
void (*mark)(oci8_base_t *base);
|
199
|
+
void (*free)(oci8_base_t *base);
|
200
|
+
size_t size;
|
131
201
|
};
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
union {
|
145
|
-
struct {
|
146
|
-
char is_implicit;
|
147
|
-
} param;
|
148
|
-
#ifndef OCI8_USE_CALLBACK_LOB_READ
|
149
|
-
struct {
|
150
|
-
int char_width;
|
151
|
-
} lob_locator;
|
152
|
-
#endif
|
153
|
-
struct {
|
154
|
-
rb_pid_t pid;
|
155
|
-
} svcctx;
|
156
|
-
} u;
|
202
|
+
|
203
|
+
struct oci8_bind_class {
|
204
|
+
oci8_base_class_t base;
|
205
|
+
VALUE (*get)(oci8_bind_t *obind, void *data, void *null_struct);
|
206
|
+
void (*set)(oci8_bind_t *obind, void *data, void **null_structp, VALUE val);
|
207
|
+
void (*init)(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length);
|
208
|
+
void (*init_elem)(oci8_bind_t *obind, VALUE svc);
|
209
|
+
ub1 (*in)(oci8_bind_t *obind, ub4 idx, ub1 piece, void **valuepp, ub4 **alenpp, void **indpp);
|
210
|
+
void (*out)(oci8_bind_t *obind, ub4 idx, ub1 piece, void **valuepp, ub4 **alenpp, void **indpp);
|
211
|
+
void (*pre_fetch_hook)(oci8_bind_t *obind, VALUE svc);
|
212
|
+
ub2 dty;
|
213
|
+
ub1 csfrm;
|
157
214
|
};
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
} str;
|
179
|
-
long lng;
|
180
|
-
double dbl;
|
181
|
-
ora_date_t od;
|
182
|
-
ora_number_t on;
|
183
|
-
struct {
|
184
|
-
void *hp;
|
185
|
-
VALUE v;
|
186
|
-
VALUE klass;
|
187
|
-
} handle;
|
188
|
-
} value;
|
215
|
+
|
216
|
+
struct oci8_base {
|
217
|
+
ub4 type;
|
218
|
+
union {
|
219
|
+
dvoid *ptr;
|
220
|
+
OCISvcCtx *svc;
|
221
|
+
OCIStmt *stmt;
|
222
|
+
OCIDefine *dfn;
|
223
|
+
OCIBind *bnd;
|
224
|
+
OCIParam *prm;
|
225
|
+
OCILobLocator *lob;
|
226
|
+
OCIType *tdo;
|
227
|
+
OCIDescribe *dschp;
|
228
|
+
} hp;
|
229
|
+
VALUE self;
|
230
|
+
const oci8_base_class_t *klass;
|
231
|
+
oci8_base_t *parent;
|
232
|
+
oci8_base_t *next;
|
233
|
+
oci8_base_t *prev;
|
234
|
+
oci8_base_t *children;
|
189
235
|
};
|
190
|
-
typedef struct oci8_bind_handle oci8_bind_handle_t;
|
191
236
|
|
192
|
-
|
193
|
-
|
194
|
-
|
237
|
+
struct oci8_bind {
|
238
|
+
oci8_base_t base;
|
239
|
+
void *valuep;
|
240
|
+
sb4 value_sz; /* size to define or bind. */
|
241
|
+
sb4 alloc_sz; /* size of a element. */
|
242
|
+
ub4 maxar_sz; /* maximum array size. */
|
243
|
+
ub4 curar_sz; /* current array size. */
|
244
|
+
VALUE tdo;
|
245
|
+
union {
|
246
|
+
void **null_structs;
|
247
|
+
sb2 *inds;
|
248
|
+
} u;
|
249
|
+
};
|
195
250
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
251
|
+
enum logon_type_t {T_NOT_LOGIN = 0, T_IMPLICIT, T_EXPLICIT};
|
252
|
+
|
253
|
+
typedef struct {
|
254
|
+
oci8_base_t base;
|
255
|
+
volatile VALUE executing_thread;
|
256
|
+
enum logon_type_t logon_type;
|
257
|
+
OCISession *authhp;
|
258
|
+
OCIServer *srvhp;
|
259
|
+
rb_pid_t pid;
|
260
|
+
char is_autocommit;
|
261
|
+
#ifdef RUBY_VM
|
262
|
+
char non_blocking;
|
263
|
+
#endif
|
264
|
+
VALUE long_read_len;
|
265
|
+
} oci8_svcctx_t;
|
266
|
+
|
267
|
+
typedef struct {
|
268
|
+
dvoid *hp; /* OCIBind* or OCIDefine* */
|
269
|
+
dvoid *valuep;
|
270
|
+
sb4 value_sz;
|
271
|
+
ub2 dty;
|
272
|
+
sb2 *indp;
|
273
|
+
ub2 *alenp;
|
274
|
+
} oci8_exec_sql_var_t;
|
275
|
+
|
276
|
+
#define Check_Handle(obj, klass, hp) do { \
|
277
|
+
if (!rb_obj_is_kind_of(obj, klass)) { \
|
278
|
+
rb_raise(rb_eTypeError, "invalid argument %s (expect %s)", rb_class2name(CLASS_OF(obj)), rb_class2name(klass)); \
|
279
|
+
} \
|
280
|
+
Data_Get_Struct(obj, oci8_base_t, hp); \
|
201
281
|
} while (0)
|
202
282
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
};
|
207
|
-
typedef struct oci8_string oci8_string_t;
|
208
|
-
|
209
|
-
#define Get_String(obj, s) do { \
|
210
|
-
if (!NIL_P(obj)) { \
|
211
|
-
Check_Type(obj, T_STRING); \
|
212
|
-
s.ptr = RSTRING_ORATEXT(obj); \
|
213
|
-
s.len = RSTRING_LEN(obj); \
|
214
|
-
} else { \
|
215
|
-
s.ptr = NULL; \
|
216
|
-
s.len = 0; \
|
283
|
+
#define Check_Object(obj, klass) do {\
|
284
|
+
if (!rb_obj_is_kind_of(obj, klass)) { \
|
285
|
+
rb_raise(rb_eTypeError, "invalid argument %s (expect %s)", rb_class2name(CLASS_OF(obj)), rb_class2name(klass)); \
|
217
286
|
} \
|
218
287
|
} while (0)
|
219
288
|
|
220
|
-
#define
|
221
|
-
|
222
|
-
|
223
|
-
cval = FIX2INT(vval); \
|
224
|
-
} else { \
|
225
|
-
cval = def; \
|
226
|
-
} \
|
227
|
-
} while (0)
|
289
|
+
#define oci8_raise(err, status, stmt) oci8_do_raise(err, status, stmt, __FILE__, __LINE__)
|
290
|
+
#define oci8_env_raise(err, status) oci8_do_env_raise(err, status, __FILE__, __LINE__)
|
291
|
+
#define oci8_raise_init_error() oci8_do_raise_init_error(__FILE__, __LINE__)
|
228
292
|
|
229
|
-
|
230
|
-
#define
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
extern VALUE cOCIHandle;
|
243
|
-
extern VALUE cOCIEnv;
|
244
|
-
extern VALUE cOCISvcCtx;
|
245
|
-
extern VALUE cOCIServer;
|
246
|
-
extern VALUE cOCISession;
|
247
|
-
extern VALUE cOCIStmt;
|
248
|
-
extern VALUE cOCIDefine;
|
249
|
-
extern VALUE cOCIBind;
|
250
|
-
extern VALUE cOCIDescribe;
|
251
|
-
|
252
|
-
/* Descriptor */
|
253
|
-
extern VALUE cOCIDescriptor;
|
254
|
-
extern VALUE cOCILobLocator;
|
255
|
-
extern VALUE cOCIFileLocator;
|
256
|
-
extern VALUE cOCIParam;
|
257
|
-
extern VALUE cOCIRowid;
|
258
|
-
|
259
|
-
/* Exception */
|
260
|
-
extern VALUE eOCIException;
|
261
|
-
extern VALUE eOCINoData;
|
262
|
-
extern VALUE eOCIError;
|
263
|
-
extern VALUE eOCIInvalidHandle;
|
264
|
-
extern VALUE eOCINeedData;
|
265
|
-
extern VALUE eOCIStillExecuting;
|
266
|
-
extern VALUE eOCIContinue;
|
267
|
-
extern VALUE eOCISuccessWithInfo;
|
268
|
-
|
269
|
-
/* oracle specific type */
|
270
|
-
extern VALUE cOraDate;
|
271
|
-
extern VALUE cOraNumber;
|
272
|
-
|
273
|
-
/* const.c */
|
274
|
-
void Init_oci8_const(void);
|
275
|
-
extern ID oci8_id_code;
|
276
|
-
extern ID oci8_id_define_array;
|
277
|
-
extern ID oci8_id_bind_hash;
|
278
|
-
extern ID oci8_id_message;
|
279
|
-
extern ID oci8_id_new;
|
280
|
-
extern ID oci8_id_parse_error_offset;
|
281
|
-
extern ID oci8_id_server;
|
282
|
-
extern ID oci8_id_session;
|
283
|
-
extern ID oci8_id_sql;
|
284
|
-
|
285
|
-
/* handle.c */
|
286
|
-
void Init_oci8_handle(void);
|
287
|
-
VALUE oci8_handle_free(VALUE self);
|
288
|
-
void oci8_handle_cleanup(oci8_handle_t *);
|
289
|
-
VALUE oci8_s_new(VALUE self);
|
290
|
-
oci8_handle_t *oci8_make_handle(ub4 type, dvoid *hp, OCIError *errhp, oci8_handle_t *chp, sb4 value_sz);
|
291
|
-
void oci8_link(oci8_handle_t *parent, oci8_handle_t *child);
|
292
|
-
void oci8_unlink(oci8_handle_t *self);
|
293
|
+
/* raise on error */
|
294
|
+
#define oci_lc(rv) do { \
|
295
|
+
sword __rv = (rv); \
|
296
|
+
if (__rv != OCI_SUCCESS) { \
|
297
|
+
oci8_raise(oci8_errhp, __rv, NULL); \
|
298
|
+
} \
|
299
|
+
} while(0)
|
300
|
+
|
301
|
+
#if SIZEOF_LONG > 4
|
302
|
+
#define UB4_TO_NUM INT2FIX
|
303
|
+
#else
|
304
|
+
#define UB4_TO_NUM UINT2NUM
|
305
|
+
#endif
|
293
306
|
|
294
307
|
/* env.c */
|
308
|
+
extern OCIEnv *oci8_envhp;
|
309
|
+
#ifdef RUBY_VM
|
310
|
+
/* oci8_errhp is a thread local object in ruby 1.9. */
|
311
|
+
#define oci8_errhp oci8_get_errhp()
|
312
|
+
|
313
|
+
extern oci8_tls_key_t oci8_tls_key; /* native thread key */
|
314
|
+
OCIError *oci8_make_errhp(void);
|
315
|
+
|
316
|
+
static inline OCIError *oci8_get_errhp()
|
317
|
+
{
|
318
|
+
OCIError *errhp = (OCIError *)oci8_tls_get(oci8_tls_key);
|
319
|
+
return LIKELY(errhp != NULL) ? errhp : oci8_make_errhp();
|
320
|
+
}
|
321
|
+
|
322
|
+
#else
|
323
|
+
/* oci8_errhp is global in ruby 1.8. */
|
324
|
+
extern OCIError *oci8_errhp;
|
325
|
+
#endif
|
295
326
|
void Init_oci8_env(void);
|
296
327
|
|
297
|
-
/*
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
void
|
309
|
-
|
310
|
-
|
311
|
-
|
328
|
+
/* oci8lib.c */
|
329
|
+
extern ID oci8_id_new;
|
330
|
+
extern ID oci8_id_get;
|
331
|
+
extern ID oci8_id_set;
|
332
|
+
extern ID oci8_id_keys;
|
333
|
+
extern int oci8_in_finalizer;
|
334
|
+
extern VALUE oci8_cOCIHandle;
|
335
|
+
void oci8_base_free(oci8_base_t *base);
|
336
|
+
VALUE oci8_define_class(const char *name, oci8_base_class_t *klass);
|
337
|
+
VALUE oci8_define_class_under(VALUE outer, const char *name, oci8_base_class_t *klass);
|
338
|
+
VALUE oci8_define_bind_class(const char *name, const oci8_bind_class_t *oci8_bind_class);
|
339
|
+
void oci8_link_to_parent(oci8_base_t *base, oci8_base_t *parent);
|
340
|
+
void oci8_unlink_from_parent(oci8_base_t *base);
|
341
|
+
sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data);
|
342
|
+
sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_vars, oci8_exec_sql_var_t *define_vars, ub4 num_bind_vars, oci8_exec_sql_var_t *bind_vars, int raise_on_error);
|
343
|
+
#if defined RUNTIME_API_CHECK
|
344
|
+
void *oci8_find_symbol(const char *symbol_name);
|
312
345
|
#endif
|
313
|
-
VALUE oci8_break(VALUE self);
|
314
|
-
VALUE oci8_reset(VALUE self);
|
315
346
|
|
316
|
-
/*
|
317
|
-
|
347
|
+
/* error.c */
|
348
|
+
extern VALUE eOCIException;
|
349
|
+
extern VALUE eOCIBreak;
|
350
|
+
void Init_oci8_error(void);
|
351
|
+
NORETURN(void oci8_do_raise(OCIError *, sword status, OCIStmt *, const char *file, int line));
|
352
|
+
NORETURN(void oci8_do_env_raise(OCIEnv *, sword status, const char *file, int line));
|
353
|
+
NORETURN(void oci8_do_raise_init_error(const char *file, int line));
|
354
|
+
sb4 oci8_get_error_code(OCIError *errhp);
|
355
|
+
|
356
|
+
/* oci8.c */
|
357
|
+
VALUE Init_oci8(void);
|
358
|
+
oci8_svcctx_t *oci8_get_svcctx(VALUE obj);
|
359
|
+
OCISvcCtx *oci8_get_oci_svcctx(VALUE obj);
|
360
|
+
OCISession *oci8_get_oci_session(VALUE obj);
|
361
|
+
void oci8_check_pid_consistency(oci8_svcctx_t *svcctx);
|
362
|
+
#define TO_SVCCTX oci8_get_oci_svcctx
|
363
|
+
#define TO_SESSION oci8_get_oci_session
|
318
364
|
|
319
365
|
/* stmt.c */
|
320
|
-
|
366
|
+
extern VALUE cOCIStmt;
|
367
|
+
void Init_oci8_stmt(VALUE cOCI8);
|
321
368
|
|
322
369
|
/* bind.c */
|
323
|
-
|
324
|
-
void
|
325
|
-
VALUE
|
326
|
-
|
327
|
-
|
328
|
-
void
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
void
|
335
|
-
VALUE
|
336
|
-
|
337
|
-
/* param.c */
|
338
|
-
void Init_oci8_param(void);
|
370
|
+
typedef struct {
|
371
|
+
void *hp;
|
372
|
+
VALUE obj;
|
373
|
+
} oci8_hp_obj_t;
|
374
|
+
void oci8_bind_free(oci8_base_t *base);
|
375
|
+
void oci8_bind_hp_obj_mark(oci8_base_t *base);
|
376
|
+
void Init_oci8_bind(VALUE cOCI8BindTypeBase);
|
377
|
+
oci8_bind_t *oci8_get_bind(VALUE obj);
|
378
|
+
|
379
|
+
/* metadata.c */
|
380
|
+
extern VALUE cOCI8MetadataBase;
|
381
|
+
void Init_oci8_metadata(VALUE cOCI8);
|
382
|
+
VALUE oci8_metadata_create(OCIParam *parmhp, VALUE svc, VALUE parent);
|
339
383
|
|
340
384
|
/* lob.c */
|
341
|
-
void Init_oci8_lob(
|
385
|
+
void Init_oci8_lob(VALUE cOCI8);
|
386
|
+
VALUE oci8_make_clob(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
387
|
+
VALUE oci8_make_nclob(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
388
|
+
VALUE oci8_make_blob(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
389
|
+
VALUE oci8_make_bfile(oci8_svcctx_t *svcctx, OCILobLocator *s);
|
342
390
|
|
343
391
|
/* oradate.c */
|
344
392
|
void Init_ora_date(void);
|
345
|
-
void oci8_set_ora_date(ora_date_t *, int year, int month, int day, int hour, int minute, int second);
|
346
|
-
void oci8_get_ora_date(ora_date_t *, int *year, int *month, int *day, int *hour, int *minute, int *second);
|
347
|
-
|
348
|
-
/* oranumber.c */
|
349
|
-
#define ORA_NUMBER_BUF_SIZE (128 /* max scale */ + 38 /* max precision */ + 1 /* sign */ + 1 /* comma */ + 1 /* nul */)
|
350
|
-
void Init_ora_number(void);
|
351
|
-
void ora_number_to_str(unsigned char *buf, size_t *lenp, ora_number_t *on, unsigned char size);
|
352
393
|
|
353
394
|
/* ocinumber.c */
|
354
|
-
|
395
|
+
void Init_oci_number(VALUE mOCI);
|
396
|
+
OCINumber *oci8_get_ocinumber(VALUE num);
|
397
|
+
VALUE oci8_make_ocinumber(OCINumber *s);
|
398
|
+
VALUE oci8_make_integer(OCINumber *s);
|
399
|
+
VALUE oci8_make_float(OCINumber *s);
|
400
|
+
OCINumber *oci8_set_ocinumber(OCINumber *result, VALUE self);
|
401
|
+
OCINumber *oci8_set_integer(OCINumber *result, VALUE self);
|
402
|
+
|
403
|
+
/* ocidatetim.c */
|
404
|
+
void Init_oci_datetime(void);
|
405
|
+
VALUE oci8_make_ocidate(OCIDate *od);
|
406
|
+
OCIDate *oci8_set_ocidate(OCIDate *od, VALUE val);
|
407
|
+
VALUE oci8_make_ocidatetime(OCIDateTime *dttm);
|
408
|
+
OCIDateTime *oci8_set_ocidatetime(OCIDateTime *dttm, VALUE val);
|
409
|
+
VALUE oci8_make_interval_ym(OCIInterval *s);
|
410
|
+
VALUE oci8_make_interval_ds(OCIInterval *s);
|
411
|
+
|
412
|
+
/* object.c */
|
413
|
+
void Init_oci_object(VALUE mOCI);
|
414
|
+
|
415
|
+
/* xmldb.c */
|
416
|
+
#ifndef XMLCTX_DEFINED
|
417
|
+
#define XMLCTX_DEFINED
|
418
|
+
struct xmlctx;
|
419
|
+
typedef struct xmlctx xmlctx;
|
420
|
+
#endif
|
421
|
+
#ifndef XML_TYPES
|
422
|
+
typedef struct xmlnode xmlnode;
|
423
|
+
#endif
|
424
|
+
void Init_oci_xmldb(void);
|
425
|
+
VALUE oci8_make_rexml(struct xmlctx *xctx, xmlnode *node);
|
355
426
|
|
356
427
|
/* attr.c */
|
357
|
-
|
358
|
-
VALUE
|
359
|
-
VALUE
|
360
|
-
|
361
|
-
|
428
|
+
VALUE oci8_get_sb1_attr(oci8_base_t *base, ub4 attrtype);
|
429
|
+
VALUE oci8_get_ub2_attr(oci8_base_t *base, ub4 attrtype);
|
430
|
+
VALUE oci8_get_sb2_attr(oci8_base_t *base, ub4 attrtype);
|
431
|
+
VALUE oci8_get_ub4_attr(oci8_base_t *base, ub4 attrtype);
|
432
|
+
VALUE oci8_get_string_attr(oci8_base_t *base, ub4 attrtype);
|
433
|
+
VALUE oci8_get_rowid_attr(oci8_base_t *base, ub4 attrtype);
|
434
|
+
|
435
|
+
/* encoding.c */
|
436
|
+
void Init_oci8_encoding(VALUE cOCI8);
|
437
|
+
VALUE oci8_charset_id2name(VALUE svc, VALUE charset_id);
|
438
|
+
|
439
|
+
/* win32.c */
|
440
|
+
void Init_oci8_win32(VALUE cOCI8);
|
441
|
+
|
442
|
+
#ifdef HAVE_TYPE_RB_ENCODING
|
443
|
+
extern rb_encoding *oci8_encoding;
|
444
|
+
|
445
|
+
#define OCI8StringValue(v) do { \
|
446
|
+
StringValue(v); \
|
447
|
+
(v) = rb_str_export_to_enc(v, oci8_encoding); \
|
448
|
+
} while (0)
|
449
|
+
#define OCI8SafeStringValue(v) do { \
|
450
|
+
SafeStringValue(v); \
|
451
|
+
(v) = rb_str_export_to_enc(v, oci8_encoding); \
|
452
|
+
} while (0)
|
453
|
+
#else
|
454
|
+
#define OCI8StringValue(v) StringValue(v)
|
455
|
+
#define OCI8SafeStringValue(v) SafeStringValue(v)
|
456
|
+
#endif
|
457
|
+
|
458
|
+
#include "apiwrap.h"
|
362
459
|
|
363
|
-
#define _D_ fprintf(stderr, "%s:%d - %s\n", __FILE__, __LINE__, __FUNCTION__)
|
364
460
|
#endif
|