ruby-oci8-master 2.0.7

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.
Files changed (84) hide show
  1. data/ChangeLog +2321 -0
  2. data/Makefile +88 -0
  3. data/NEWS +303 -0
  4. data/README +76 -0
  5. data/VERSION +1 -0
  6. data/dist-files +83 -0
  7. data/doc/api.en.html +527 -0
  8. data/doc/api.en.rd +554 -0
  9. data/doc/api.ja.html +525 -0
  10. data/doc/api.ja.rd +557 -0
  11. data/doc/manual.css +35 -0
  12. data/ext/oci8/.document +18 -0
  13. data/ext/oci8/MANIFEST +18 -0
  14. data/ext/oci8/apiwrap.c.tmpl +182 -0
  15. data/ext/oci8/apiwrap.h.tmpl +61 -0
  16. data/ext/oci8/apiwrap.rb +91 -0
  17. data/ext/oci8/apiwrap.yml +1455 -0
  18. data/ext/oci8/attr.c +105 -0
  19. data/ext/oci8/bind.c +366 -0
  20. data/ext/oci8/connection_pool.c +199 -0
  21. data/ext/oci8/encoding.c +289 -0
  22. data/ext/oci8/env.c +178 -0
  23. data/ext/oci8/error.c +378 -0
  24. data/ext/oci8/extconf.rb +179 -0
  25. data/ext/oci8/lob.c +805 -0
  26. data/ext/oci8/metadata.c +232 -0
  27. data/ext/oci8/object.c +727 -0
  28. data/ext/oci8/oci8.c +1156 -0
  29. data/ext/oci8/oci8.h +574 -0
  30. data/ext/oci8/oci8lib.c +527 -0
  31. data/ext/oci8/ocidatetime.c +484 -0
  32. data/ext/oci8/ocihandle.c +751 -0
  33. data/ext/oci8/ocinumber.c +1612 -0
  34. data/ext/oci8/oraconf.rb +1119 -0
  35. data/ext/oci8/oradate.c +611 -0
  36. data/ext/oci8/oranumber_util.c +352 -0
  37. data/ext/oci8/oranumber_util.h +24 -0
  38. data/ext/oci8/post-config.rb +5 -0
  39. data/ext/oci8/stmt.c +673 -0
  40. data/ext/oci8/thread_util.c +85 -0
  41. data/ext/oci8/thread_util.h +30 -0
  42. data/ext/oci8/win32.c +137 -0
  43. data/lib/.document +1 -0
  44. data/lib/dbd/OCI8.rb +591 -0
  45. data/lib/oci8.rb.in +94 -0
  46. data/lib/oci8/.document +8 -0
  47. data/lib/oci8/bindtype.rb +349 -0
  48. data/lib/oci8/compat.rb +113 -0
  49. data/lib/oci8/connection_pool.rb +99 -0
  50. data/lib/oci8/datetime.rb +611 -0
  51. data/lib/oci8/encoding-init.rb +74 -0
  52. data/lib/oci8/encoding.yml +537 -0
  53. data/lib/oci8/metadata.rb +2132 -0
  54. data/lib/oci8/object.rb +581 -0
  55. data/lib/oci8/oci8.rb +721 -0
  56. data/lib/oci8/ocihandle.rb +425 -0
  57. data/lib/oci8/oracle_version.rb +144 -0
  58. data/lib/oci8/properties.rb +73 -0
  59. data/metaconfig +142 -0
  60. data/pre-distclean.rb +7 -0
  61. data/ruby-oci8.gemspec +63 -0
  62. data/setup.rb +1331 -0
  63. data/test/README +4 -0
  64. data/test/config.rb +122 -0
  65. data/test/test_all.rb +51 -0
  66. data/test/test_appinfo.rb +63 -0
  67. data/test/test_array_dml.rb +333 -0
  68. data/test/test_bind_raw.rb +46 -0
  69. data/test/test_bind_time.rb +178 -0
  70. data/test/test_break.rb +96 -0
  71. data/test/test_clob.rb +82 -0
  72. data/test/test_connstr.rb +81 -0
  73. data/test/test_datetime.rb +582 -0
  74. data/test/test_dbi.rb +366 -0
  75. data/test/test_dbi_clob.rb +53 -0
  76. data/test/test_encoding.rb +100 -0
  77. data/test/test_error.rb +88 -0
  78. data/test/test_metadata.rb +1399 -0
  79. data/test/test_oci8.rb +434 -0
  80. data/test/test_oracle_version.rb +70 -0
  81. data/test/test_oradate.rb +256 -0
  82. data/test/test_oranumber.rb +746 -0
  83. data/test/test_rowid.rb +33 -0
  84. metadata +137 -0
@@ -0,0 +1,574 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * oci8.h - part of ruby-oci8
4
+ *
5
+ * Copyright (C) 2002-2011 KUBO Takehiro <kubo@jiubao.org>
6
+ */
7
+ #ifndef _RUBY_OCI_H_
8
+ #define _RUBY_OCI_H_ 1
9
+
10
+ #include "ruby.h"
11
+
12
+ #ifndef rb_pid_t
13
+ #ifdef WIN32
14
+ #define rb_pid_t int
15
+ #else
16
+ #define rb_pid_t pid_t
17
+ #endif
18
+ #endif
19
+
20
+ #include <stdio.h>
21
+ #include <stdlib.h>
22
+ #include <assert.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C"
26
+ {
27
+ #endif
28
+ #include <oci.h>
29
+ #ifdef __cplusplus
30
+ }
31
+ #endif
32
+
33
+ #define ORAVERNUM(major, minor, update, patch, port_update) \
34
+ (((major) << 24) | ((minor) << 20) | ((update) << 12) | ((patch) << 8) | (port_update))
35
+
36
+ #define ORAVER_8_0 ORAVERNUM(8, 0, 0, 0, 0)
37
+ #define ORAVER_8_1 ORAVERNUM(8, 1, 0, 0, 0)
38
+ #define ORAVER_9_0 ORAVERNUM(9, 0, 0, 0, 0)
39
+ #define ORAVER_9_2 ORAVERNUM(9, 2, 0, 0, 0)
40
+ #define ORAVER_10_1 ORAVERNUM(10, 1, 0, 0, 0)
41
+ #define ORAVER_10_2 ORAVERNUM(10, 2, 0, 0, 0)
42
+ #define ORAVER_11_1 ORAVERNUM(11, 1, 0, 0, 0)
43
+
44
+ #include "extconf.h"
45
+ #ifdef HAVE_TYPE_RB_ENCODING
46
+ #include <ruby/encoding.h>
47
+ #endif
48
+
49
+ #ifndef OCI_TEMP_CLOB
50
+ #define OCI_TEMP_CLOB 1
51
+ #endif
52
+ #ifndef OCI_TEMP_BLOB
53
+ #define OCI_TEMP_BLOB 2
54
+ #endif
55
+
56
+ #ifndef ORAXB8_DEFINED
57
+ #if SIZEOF_LONG == 8
58
+ typedef unsigned long oraub8;
59
+ typedef signed long orasb8;
60
+ #elif SIZEOF_LONG_LONG == 8
61
+ typedef unsigned long long oraub8;
62
+ typedef signed long long orasb8;
63
+ #elif SIZEOF___INT64 == 8
64
+ typedef unsigned __int64 oraub8;
65
+ typedef signed __int64 orasb8;
66
+ #endif
67
+ typedef oraub8 ub8;
68
+ typedef orasb8 sb8;
69
+ #endif /* ORAXB8_DEFINED */
70
+
71
+ #ifndef HAVE_TYPE_ORATEXT
72
+ typedef unsigned char oratext;
73
+ #endif
74
+ #if !defined HAVE_TYPE_OCIDATETIME_ && !defined HAVE_TYPE_OCIDATETIMEP
75
+ typedef struct OCIDateTime OCIDateTime;
76
+ #endif
77
+ #if !defined HAVE_TYPE_OCIINTERVAL_ && !defined HAVE_TYPE_OCIINTERVALP
78
+ typedef struct OCIInterval OCIInterval;
79
+ #endif
80
+ #ifndef HAVE_TYPE_OCICALLBACKLOBREAD2
81
+ typedef sb4 (*OCICallbackLobRead2)(dvoid *ctxp, CONST dvoid *bufp, oraub8 len,
82
+ ub1 piece, dvoid **changed_bufpp,
83
+ oraub8 *changed_lenp);
84
+ #endif
85
+ #ifndef HAVE_TYPE_OCICALLBACKLOBWRITE2
86
+ typedef sb4 (*OCICallbackLobWrite2)(dvoid *ctxp, dvoid *bufp, oraub8 *lenp,
87
+ ub1 *piece, dvoid **changed_bufpp,
88
+ oraub8 *changed_lenp);
89
+ #endif
90
+ #if !defined HAVE_TYPE_OCIADMIN_ && !defined HAVE_TYPE_OCIADMINP
91
+ typedef struct OCIAdmin OCIAdmin;
92
+ #endif
93
+ #if !defined HAVE_TYPE_OCIAUTHINFO_ && !defined HAVE_TYPE_OCIAUTHINFOP
94
+ typedef struct OCIAuthInfo OCIAuthInfo;
95
+ #endif
96
+ #if !defined HAVE_TYPE_OCIMSG_ && !defined HAVE_TYPE_OCIMSGP
97
+ typedef struct OCIMsg OCIMsg;
98
+ #endif
99
+ #if !defined HAVE_TYPE_OCICPOOL_ && !defined HAVE_TYPE_OCICPOOLP
100
+ typedef struct OCICPool OCICPool;
101
+ #endif
102
+
103
+ /* new macros in ruby 1.8.6.
104
+ * define compatible macros for ruby 1.8.5 or lower.
105
+ */
106
+ #ifndef RSTRING_PTR
107
+ #define RSTRING_PTR(obj) RSTRING(obj)->ptr
108
+ #endif
109
+ #ifndef RSTRING_LEN
110
+ #define RSTRING_LEN(obj) RSTRING(obj)->len
111
+ #endif
112
+ #ifndef RARRAY_PTR
113
+ #define RARRAY_PTR(obj) RARRAY(obj)->ptr
114
+ #endif
115
+ #ifndef RARRAY_LEN
116
+ #define RARRAY_LEN(obj) RARRAY(obj)->len
117
+ #endif
118
+
119
+ /* new macros in ruby 1.9.
120
+ * define compatible macros for ruby 1.8 or lower.
121
+ */
122
+ #ifndef RFLOAT_VALUE
123
+ #define RFLOAT_VALUE(obj) RFLOAT(obj)->value
124
+ #endif
125
+ #ifndef STRINGIZE
126
+ #define STRINGIZE(name) #name
127
+ #endif
128
+ #ifndef RB_GC_GUARD
129
+ #define RB_GC_GUARD(v) (*(volatile VALUE *)&(v))
130
+ #endif
131
+
132
+ /* new functions in ruby 1.9.
133
+ * define compatible macros for ruby 1.8 or lower.
134
+ */
135
+ #if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO)
136
+ #define rb_errinfo() ruby_errinfo
137
+ #endif
138
+ #if !defined HAVE_TYPE_RB_BLOCKING_FUNCTION_T_ && !defined HAVE_TYPE_RB_BLOCKING_FUNCTION_TP
139
+ typedef VALUE rb_blocking_function_t(void *);
140
+ #endif
141
+
142
+ #ifndef HAVE_TYPE_RB_ENCODING
143
+ #define rb_enc_associate(str, enc) do {} while(0)
144
+ #define rb_external_str_new_with_enc(ptr, len, enc) rb_tainted_str_new((ptr), (len))
145
+ #define rb_locale_str_new_cstr(ptr) rb_str_new2(ptr)
146
+ #define rb_str_conv_enc(str, from, to) (str)
147
+ #define rb_str_export_to_enc(str, enc) (str)
148
+ #define rb_usascii_str_new(ptr, len) rb_str_new((ptr), (len))
149
+ #define rb_usascii_str_new_cstr(ptr) rb_str_new2(ptr)
150
+ #endif
151
+
152
+ /* a new function in ruby 1.9.3.
153
+ * define a compatible macro for ruby 1.9.2 or lower.
154
+ */
155
+ #ifndef HAVE_RB_CLASS_SUPERCLASS
156
+ #ifdef RCLASS_SUPER
157
+ #define rb_class_superclass(cls) RCLASS_SUPER(cls)
158
+ #else
159
+ #define rb_class_superclass(cls) (RCLASS(cls)->super)
160
+ #endif
161
+ #endif
162
+
163
+ #if defined(HAVE_NATIVETHREAD) || defined(HAVE_RB_THREAD_BLOCKING_REGION)
164
+ /*
165
+ * oci8_errhp is a thread local object in ruby 1.9, rubinius
166
+ * and ruby 1.8 configured with --enable-pthread.
167
+ */
168
+ #define USE_THREAD_LOCAL_ERRHP 1
169
+ #endif
170
+
171
+ /* macros depends on the compiler.
172
+ * LIKELY(x) hint for the compiler that 'x' is 1(TRUE) in many cases.
173
+ * UNLIKELY(x) hint for the compiler that 'x' is 0(FALSE) in many cases.
174
+ * ALWAYS_INLINE forcely inline the function.
175
+ */
176
+ #if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
177
+ /* gcc version >= 2.96 */
178
+ #define LIKELY(x) (__builtin_expect((x), 1))
179
+ #define UNLIKELY(x) (__builtin_expect((x), 0))
180
+ #else
181
+ /* other compilers */
182
+ #define LIKELY(x) (x)
183
+ #define UNLIKELY(x) (x)
184
+ #endif
185
+ #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
186
+ /* gcc version >= 3.1 */
187
+ #define ALWAYS_INLINE inline __attribute__((always_inline))
188
+ #endif
189
+ #ifdef _MSC_VER
190
+ /* microsoft c */
191
+ #define ALWAYS_INLINE __forceinline
192
+ #endif
193
+
194
+ /* macros to access thread-local storage.
195
+ *
196
+ * void *oci8_tls_get(oci8_tls_key_t key);
197
+ * get a value associated with the key.
198
+ *
199
+ * void oci8_tls_set(oci8_tls_key_t key, void *value);
200
+ * set a value to the key.
201
+ *
202
+ */
203
+ #ifdef USE_THREAD_LOCAL_ERRHP
204
+ /* rubies with native-thread support. */
205
+ #if defined(_WIN32)
206
+ #include <windows.h>
207
+ #define oci8_tls_key_t DWORD
208
+ #define oci8_tls_get(key) TlsGetValue(key)
209
+ #define oci8_tls_set(key, val) TlsSetValue((key), (val))
210
+ #else
211
+ #include <pthread.h>
212
+ #define oci8_tls_key_t pthread_key_t
213
+ #define oci8_tls_get(key) pthread_getspecific(key)
214
+ #define oci8_tls_set(key, val) pthread_setspecific((key), (val))
215
+ #endif
216
+ #endif /* HAVE_RB_THREAD_BLOCKING_REGION */
217
+
218
+ /* utility macros
219
+ */
220
+ #define IS_OCI_ERROR(v) (((v) != OCI_SUCCESS) && ((v) != OCI_SUCCESS_WITH_INFO))
221
+ #ifdef ALWAYS_INLINE
222
+ #define TO_ORATEXT to_oratext
223
+ #define TO_CHARPTR to_charptr
224
+ static ALWAYS_INLINE OraText *to_oratext(char *c)
225
+ {
226
+ return (OraText*)c;
227
+ }
228
+ static ALWAYS_INLINE char *to_charptr(OraText *c)
229
+ {
230
+ return (char*)c;
231
+ }
232
+ #else
233
+ #define TO_ORATEXT(c) ((OraText*)(c))
234
+ #define TO_CHARPTR(c) ((char*)(c))
235
+ #endif
236
+ #define RSTRING_ORATEXT(obj) TO_ORATEXT(RSTRING_PTR(obj))
237
+ #define rb_str_new2_ora(str) rb_str_new2(TO_CHARPTR(str))
238
+
239
+ /*
240
+ * prevent rdoc from gathering the specified method.
241
+ */
242
+ #define rb_define_method_nodoc rb_define_method
243
+ #define rb_define_singleton_method_nodoc rb_define_singleton_method
244
+
245
+ /* data structure for SQLT_LVC and SQLT_LVB. */
246
+ typedef struct {
247
+ sb4 size;
248
+ char buf[1];
249
+ } oci8_vstr_t;
250
+
251
+ typedef struct oci8_base_vtable oci8_base_vtable_t;
252
+ typedef struct oci8_bind_vtable oci8_bind_vtable_t;
253
+
254
+ typedef struct oci8_base oci8_base_t;
255
+ typedef struct oci8_bind oci8_bind_t;
256
+
257
+ /* The virtual method table of oci8_base_t */
258
+ struct oci8_base_vtable {
259
+ void (*mark)(oci8_base_t *base);
260
+ void (*free)(oci8_base_t *base);
261
+ size_t size;
262
+ void (*init)(oci8_base_t *base);
263
+ };
264
+
265
+ /* The virtual method table of oci8_bind_t */
266
+ struct oci8_bind_vtable {
267
+ oci8_base_vtable_t base;
268
+ VALUE (*get)(oci8_bind_t *obind, void *data, void *null_struct);
269
+ void (*set)(oci8_bind_t *obind, void *data, void **null_structp, VALUE val);
270
+ void (*init)(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length);
271
+ void (*init_elem)(oci8_bind_t *obind, VALUE svc);
272
+ void (*pre_fetch_hook)(oci8_bind_t *obind, VALUE svc);
273
+ ub2 dty;
274
+ void (*post_bind_hook)(oci8_bind_t *obind);
275
+ };
276
+
277
+ /* Class structure implemented by C language.
278
+ * oci8_base_t represents OCIHandle and its subclasses.
279
+ *
280
+ * The vptr member points to a virtual method table.
281
+ * See: http://en.wikipedia.org/wiki/Virtual_method_table
282
+ */
283
+ struct oci8_base {
284
+ const oci8_base_vtable_t *vptr;
285
+ ub4 type;
286
+ union {
287
+ dvoid *ptr;
288
+ OCISvcCtx *svc;
289
+ OCICPool *poolhp;
290
+ OCIServer *srvhp;
291
+ OCISession *usrhp;
292
+ OCIStmt *stmt;
293
+ OCIDefine *dfn;
294
+ OCIBind *bnd;
295
+ OCIParam *prm;
296
+ OCILobLocator *lob;
297
+ OCIType *tdo;
298
+ OCIDescribe *dschp;
299
+ } hp;
300
+ VALUE self;
301
+ oci8_base_t *parent;
302
+ oci8_base_t *next;
303
+ oci8_base_t *prev;
304
+ oci8_base_t *children;
305
+ };
306
+
307
+ /* Class structure implemented by C language.
308
+ * This represents OCI8::BindType::Base's subclasses.
309
+ *
310
+ * This is a subclass of oci8_base_t because the first member
311
+ * base is oci8_base_t itself.
312
+ */
313
+ struct oci8_bind {
314
+ oci8_base_t base;
315
+ void *valuep;
316
+ sb4 value_sz; /* size to define or bind. */
317
+ sb4 alloc_sz; /* size of a element. */
318
+ ub4 maxar_sz; /* maximum array size. */
319
+ ub4 curar_sz; /* current array size. */
320
+ ub4 curar_idx;/* current array index. */
321
+ VALUE tdo;
322
+ union {
323
+ void **null_structs;
324
+ sb2 *inds;
325
+ } u;
326
+ };
327
+
328
+ typedef struct oci8_logoff_strategy oci8_logoff_strategy_t;
329
+
330
+ typedef struct oci8_svcctx {
331
+ oci8_base_t base;
332
+ volatile VALUE executing_thread;
333
+ const oci8_logoff_strategy_t *logoff_strategy;
334
+ OCISession *usrhp;
335
+ OCIServer *srvhp;
336
+ rb_pid_t pid;
337
+ unsigned char state;
338
+ char is_autocommit;
339
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
340
+ char non_blocking;
341
+ #endif
342
+ VALUE long_read_len;
343
+ } oci8_svcctx_t;
344
+
345
+ struct oci8_logoff_strategy {
346
+ void *(*prepare)(oci8_svcctx_t *svcctx);
347
+ rb_blocking_function_t *execute;
348
+ };
349
+
350
+ typedef struct {
351
+ dvoid *hp; /* OCIBind* or OCIDefine* */
352
+ dvoid *valuep;
353
+ sb4 value_sz;
354
+ ub2 dty;
355
+ sb2 *indp;
356
+ ub2 *alenp;
357
+ } oci8_exec_sql_var_t;
358
+
359
+ #define Check_Handle(obj, klass, hp) do { \
360
+ if (!rb_obj_is_kind_of(obj, klass)) { \
361
+ rb_raise(rb_eTypeError, "invalid argument %s (expect %s)", rb_class2name(CLASS_OF(obj)), rb_class2name(klass)); \
362
+ } \
363
+ Data_Get_Struct(obj, oci8_base_t, hp); \
364
+ } while (0)
365
+
366
+ #define Check_Object(obj, klass) do {\
367
+ if (!rb_obj_is_kind_of(obj, klass)) { \
368
+ rb_raise(rb_eTypeError, "invalid argument %s (expect %s)", rb_class2name(CLASS_OF(obj)), rb_class2name(klass)); \
369
+ } \
370
+ } while (0)
371
+
372
+ #define oci8_raise(err, status, stmt) oci8_do_raise(err, status, stmt, __FILE__, __LINE__)
373
+ #define oci8_env_raise(err, status) oci8_do_env_raise(err, status, __FILE__, __LINE__)
374
+ #define oci8_raise_init_error() oci8_do_raise_init_error(__FILE__, __LINE__)
375
+ #define oci8_raise_by_msgno(msgno, default_msg) oci8_do_raise_by_msgno(msgno, default_msg, __FILE__, __LINE__)
376
+
377
+ #define chkerr(status) oci8_check_error_((status), NULL, NULL, __FILE__, __LINE__)
378
+ #define chker2(status, base) oci8_check_error_((status), (base), NULL, __FILE__, __LINE__)
379
+ #define chker3(status, base, stmt) oci8_check_error_((status), (base), (stmt), __FILE__, __LINE__)
380
+
381
+ #if SIZEOF_LONG > 4
382
+ #define UB4_TO_NUM INT2FIX
383
+ #else
384
+ #define UB4_TO_NUM UINT2NUM
385
+ #endif
386
+
387
+ /* The folloiwng macros oci8_envhp and oci8_errhp are used
388
+ * as if they are defined as follows:
389
+ *
390
+ * extern OCIEnv *oci8_envhp;
391
+ * extern OCIError *oci8_errhp;
392
+ */
393
+ #define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp())
394
+ #ifdef USE_THREAD_LOCAL_ERRHP
395
+ #define oci8_errhp oci8_get_errhp()
396
+ #else
397
+ #define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp())
398
+ #endif
399
+
400
+ /* env.c */
401
+ extern ub4 oci8_env_mode;
402
+ extern OCIEnv *oci8_global_envhp;
403
+ OCIEnv *oci8_make_envhp(void);
404
+ #ifdef USE_THREAD_LOCAL_ERRHP
405
+ extern oci8_tls_key_t oci8_tls_key; /* native thread key */
406
+ OCIError *oci8_make_errhp(void);
407
+
408
+ static inline OCIError *oci8_get_errhp()
409
+ {
410
+ OCIError *errhp = (OCIError *)oci8_tls_get(oci8_tls_key);
411
+ return LIKELY(errhp != NULL) ? errhp : oci8_make_errhp();
412
+ }
413
+
414
+ #else
415
+ extern OCIError *oci8_global_errhp;
416
+ OCIError *oci8_make_errhp(void);
417
+ #endif
418
+ void Init_oci8_env(void);
419
+
420
+ /* oci8lib.c */
421
+ extern ID oci8_id_at_last_error;
422
+ extern ID oci8_id_new;
423
+ extern ID oci8_id_get;
424
+ extern ID oci8_id_set;
425
+ extern ID oci8_id_keys;
426
+ extern ID oci8_id_oci8_vtable;
427
+ #ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
428
+ extern ID oci8_id_add_op; /* ID of the addition operator '+' */
429
+ extern ID oci8_id_sub_op; /* ID of the subtraction operator '-' */
430
+ extern ID oci8_id_mul_op; /* ID of the multiplication operator '*' */
431
+ extern ID oci8_id_div_op; /* ID of the division operator '/' */
432
+ #else
433
+ #define oci8_id_add_op '+'
434
+ #define oci8_id_sub_op '-'
435
+ #define oci8_id_mul_op '*'
436
+ #define oci8_id_div_op '/'
437
+ #endif
438
+ extern int oci8_in_finalizer;
439
+ extern VALUE oci8_cOCIHandle;
440
+ void oci8_base_free(oci8_base_t *base);
441
+ VALUE oci8_define_class(const char *name, oci8_base_vtable_t *vptr);
442
+ VALUE oci8_define_class_under(VALUE outer, const char *name, oci8_base_vtable_t *vptr);
443
+ VALUE oci8_define_bind_class(const char *name, const oci8_bind_vtable_t *vptr);
444
+ void oci8_link_to_parent(oci8_base_t *base, oci8_base_t *parent);
445
+ void oci8_unlink_from_parent(oci8_base_t *base);
446
+ sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data);
447
+ 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);
448
+ #if defined RUNTIME_API_CHECK
449
+ void *oci8_find_symbol(const char *symbol_name);
450
+ #endif
451
+ oci8_base_t *oci8_get_handle(VALUE obj, VALUE klass);
452
+
453
+ /* error.c */
454
+ extern VALUE eOCIException;
455
+ extern VALUE eOCIBreak;
456
+ void Init_oci8_error(void);
457
+ NORETURN(void oci8_do_env_raise(OCIEnv *, sword status, const char *file, int line));
458
+ NORETURN(void oci8_do_raise_init_error(const char *file, int line));
459
+ sb4 oci8_get_error_code(OCIError *errhp);
460
+ VALUE oci8_get_error_message(ub4 msgno, const char *default_msg);
461
+ NORETURN(void oci8_do_raise_by_msgno(ub4 msgno, const char *default_msg, const char *file, int line));
462
+ void oci8_check_error_(sword status, oci8_base_t *base, OCIStmt *stmthp, const char *file, int line);
463
+
464
+ /* ocihandle.c */
465
+ void Init_oci8_handle(void);
466
+
467
+ /* oci8.c */
468
+ VALUE Init_oci8(void);
469
+ void oci8_do_parse_connect_string(VALUE conn_str, VALUE *user, VALUE *pass, VALUE *dbname, VALUE *mode);
470
+ oci8_svcctx_t *oci8_get_svcctx(VALUE obj);
471
+ OCISvcCtx *oci8_get_oci_svcctx(VALUE obj);
472
+ OCISession *oci8_get_oci_session(VALUE obj);
473
+ void oci8_check_pid_consistency(oci8_svcctx_t *svcctx);
474
+ #define TO_SVCCTX oci8_get_oci_svcctx
475
+ #define TO_SESSION oci8_get_oci_session
476
+
477
+ /* connection_pool.c */
478
+ void Init_oci8_connection_pool(VALUE cOCI8);
479
+
480
+ /* stmt.c */
481
+ extern VALUE cOCIStmt;
482
+ void Init_oci8_stmt(VALUE cOCI8);
483
+
484
+ /* bind.c */
485
+ typedef struct {
486
+ void *hp;
487
+ VALUE obj;
488
+ } oci8_hp_obj_t;
489
+ void oci8_bind_free(oci8_base_t *base);
490
+ void oci8_bind_hp_obj_mark(oci8_base_t *base);
491
+ void Init_oci8_bind(VALUE cOCI8BindTypeBase);
492
+ oci8_bind_t *oci8_get_bind(VALUE obj);
493
+ void oci8_bind_set_data(VALUE self, VALUE val);
494
+ VALUE oci8_bind_get_data(VALUE self);
495
+
496
+ /* metadata.c */
497
+ extern VALUE cOCI8MetadataBase;
498
+ void Init_oci8_metadata(VALUE cOCI8);
499
+ VALUE oci8_metadata_create(OCIParam *parmhp, VALUE svc, VALUE parent);
500
+
501
+ /* lob.c */
502
+ void Init_oci8_lob(VALUE cOCI8);
503
+ VALUE oci8_make_clob(oci8_svcctx_t *svcctx, OCILobLocator *s);
504
+ VALUE oci8_make_nclob(oci8_svcctx_t *svcctx, OCILobLocator *s);
505
+ VALUE oci8_make_blob(oci8_svcctx_t *svcctx, OCILobLocator *s);
506
+ VALUE oci8_make_bfile(oci8_svcctx_t *svcctx, OCILobLocator *s);
507
+ void oci8_assign_clob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
508
+ void oci8_assign_nclob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
509
+ void oci8_assign_blob(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
510
+ void oci8_assign_bfile(oci8_svcctx_t *svcctx, VALUE lob, OCILobLocator **dest);
511
+
512
+ /* oradate.c */
513
+ void Init_ora_date(void);
514
+
515
+ /* ocinumber.c */
516
+ extern int oci8_float_conversion_type_is_ruby;
517
+ void Init_oci_number(VALUE mOCI, OCIError *errhp);
518
+ OCINumber *oci8_get_ocinumber(VALUE num);
519
+ VALUE oci8_make_ocinumber(OCINumber *s, OCIError *errhp);
520
+ VALUE oci8_make_integer(OCINumber *s, OCIError *errhp);
521
+ VALUE oci8_make_float(OCINumber *s, OCIError *errhp);
522
+ OCINumber *oci8_set_ocinumber(OCINumber *result, VALUE self, OCIError *errhp);
523
+ OCINumber *oci8_set_integer(OCINumber *result, VALUE self, OCIError *errhp);
524
+ double oci8_onum_to_dbl(OCINumber *s, OCIError *errhp);
525
+ OCINumber *oci8_dbl_to_onum(OCINumber *result, double dbl, OCIError *errhp);
526
+
527
+ /* ocidatetim.c */
528
+ void Init_oci_datetime(void);
529
+ VALUE oci8_make_ocidate(OCIDate *od);
530
+ OCIDate *oci8_set_ocidate(OCIDate *od, VALUE val);
531
+ VALUE oci8_make_ocidatetime(OCIDateTime *dttm);
532
+ OCIDateTime *oci8_set_ocidatetime(OCIDateTime *dttm, VALUE val);
533
+ VALUE oci8_make_interval_ym(OCIInterval *s);
534
+ VALUE oci8_make_interval_ds(OCIInterval *s);
535
+
536
+ /* object.c */
537
+ void Init_oci_object(VALUE mOCI);
538
+
539
+ /* attr.c */
540
+ VALUE oci8_get_sb1_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
541
+ VALUE oci8_get_ub2_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
542
+ VALUE oci8_get_sb2_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
543
+ VALUE oci8_get_ub4_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
544
+ VALUE oci8_get_string_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
545
+ VALUE oci8_get_rowid_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
546
+
547
+ /* encoding.c */
548
+ void Init_oci8_encoding(VALUE cOCI8);
549
+ VALUE oci8_charset_id2name(VALUE svc, VALUE charset_id);
550
+ extern int oci8_nls_ratio;
551
+
552
+ /* win32.c */
553
+ void Init_oci8_win32(VALUE cOCI8);
554
+
555
+ #ifdef HAVE_TYPE_RB_ENCODING
556
+ extern rb_encoding *oci8_encoding;
557
+
558
+ #define OCI8StringValue(v) do { \
559
+ StringValue(v); \
560
+ (v) = rb_str_export_to_enc(v, oci8_encoding); \
561
+ } while (0)
562
+ #define OCI8SafeStringValue(v) do { \
563
+ SafeStringValue(v); \
564
+ (v) = rb_str_export_to_enc(v, oci8_encoding); \
565
+ } while (0)
566
+ #else
567
+ #define OCI8StringValue(v) StringValue(v)
568
+ #define OCI8SafeStringValue(v) SafeStringValue(v)
569
+ #endif
570
+
571
+ #include "thread_util.h"
572
+ #include "apiwrap.h"
573
+
574
+ #endif