ruby-oci8 1.0.2

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 (71) hide show
  1. data/ChangeLog +569 -0
  2. data/Makefile +51 -0
  3. data/NEWS +322 -0
  4. data/README +415 -0
  5. data/VERSION +1 -0
  6. data/dist-files +70 -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/MANIFEST +22 -0
  13. data/ext/oci8/attr.c +415 -0
  14. data/ext/oci8/bind.c +194 -0
  15. data/ext/oci8/const.c +165 -0
  16. data/ext/oci8/define.c +53 -0
  17. data/ext/oci8/describe.c +81 -0
  18. data/ext/oci8/descriptor.c +39 -0
  19. data/ext/oci8/env.c +276 -0
  20. data/ext/oci8/error.c +234 -0
  21. data/ext/oci8/extconf.rb +118 -0
  22. data/ext/oci8/handle.c +262 -0
  23. data/ext/oci8/lob.c +386 -0
  24. data/ext/oci8/oci8.c +137 -0
  25. data/ext/oci8/oci8.h +345 -0
  26. data/ext/oci8/ocinumber.c +117 -0
  27. data/ext/oci8/oraconf.rb +1026 -0
  28. data/ext/oci8/oradate.c +426 -0
  29. data/ext/oci8/oranumber.c +445 -0
  30. data/ext/oci8/param.c +37 -0
  31. data/ext/oci8/post-config.rb +5 -0
  32. data/ext/oci8/server.c +182 -0
  33. data/ext/oci8/session.c +99 -0
  34. data/ext/oci8/stmt.c +624 -0
  35. data/ext/oci8/svcctx.c +229 -0
  36. data/lib/DBD/OCI8/OCI8.rb +549 -0
  37. data/lib/oci8.rb.in +1605 -0
  38. data/metaconfig +142 -0
  39. data/pre-distclean.rb +7 -0
  40. data/ruby-oci8.gemspec +54 -0
  41. data/ruby-oci8.spec +62 -0
  42. data/setup.rb +1331 -0
  43. data/support/README +4 -0
  44. data/support/runit/assert.rb +281 -0
  45. data/support/runit/cui/testrunner.rb +101 -0
  46. data/support/runit/error.rb +4 -0
  47. data/support/runit/method_mappable.rb +20 -0
  48. data/support/runit/robserver.rb +25 -0
  49. data/support/runit/setuppable.rb +15 -0
  50. data/support/runit/teardownable.rb +16 -0
  51. data/support/runit/testcase.rb +113 -0
  52. data/support/runit/testfailure.rb +25 -0
  53. data/support/runit/testresult.rb +121 -0
  54. data/support/runit/testsuite.rb +43 -0
  55. data/support/runit/version.rb +3 -0
  56. data/test/README +4 -0
  57. data/test/config.rb +129 -0
  58. data/test/test_all.rb +43 -0
  59. data/test/test_bind_raw.rb +53 -0
  60. data/test/test_bind_time.rb +191 -0
  61. data/test/test_break.rb +81 -0
  62. data/test/test_clob.rb +101 -0
  63. data/test/test_connstr.rb +80 -0
  64. data/test/test_dbi.rb +317 -0
  65. data/test/test_dbi_clob.rb +56 -0
  66. data/test/test_describe.rb +137 -0
  67. data/test/test_metadata.rb +243 -0
  68. data/test/test_oci8.rb +273 -0
  69. data/test/test_oradate.rb +263 -0
  70. data/test/test_oranumber.rb +149 -0
  71. metadata +118 -0
@@ -0,0 +1,137 @@
1
+ /*
2
+ oci8.c - part of ruby-oci8
3
+
4
+ Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
5
+
6
+ =begin
7
+ == class hierarchy
8
+ * ((<OCIHandle>))
9
+ * ((<OCIEnv>)) (OCI environment handle)
10
+ * ((<OCISvcCtx>)) (OCI service context handle)
11
+ * ((<OCIServer>)) (OCI server handle)
12
+ * ((<OCISession>)) (OCI user session handle)
13
+ * ((<OCIStmt>)) (OCI statement handle)
14
+ * ((<OCIDefine>)) (OCI define handle)
15
+ * ((<OCIBind>)) (OCI bind handle)
16
+ * ((<OCIDescribe>)) (OCI descibe handle)
17
+
18
+ * ((<OCIDescriptor>))
19
+ * ((<OCILobLocator>)) (OCI Lob Locator descriptor)
20
+ * ((<OCIParam>)) (read-only parameter descriptor)
21
+ * ((<OCIRowid>)) (OCI ROWID descriptor)
22
+
23
+ * OCIException
24
+ * ((<OCIError>))
25
+ * ((<OCISuccessWithInfo>))
26
+ * OCINoData
27
+ * OCIInvalidHandle
28
+ * OCINeedData
29
+ * OCIStillExecuting
30
+
31
+ * ((<OraDate>))
32
+ * ((<OraNumber>))
33
+
34
+ == object hierarchy
35
+
36
+ * ((<OCIEnv>)) (OCI environment handle)
37
+ * ((<OCISvcCtx>)) (OCI service context handle)
38
+ * ((<OCIServer>)) (OCI server handle)
39
+ * ((<OCISession>)) (OCI user session handle)
40
+ * ((<OCIStmt>)) (OCI statement handle)
41
+ * ((<OCIDefine>)) (OCI define handle)
42
+ * ((<OCIBind>)) (OCI bind handle)
43
+ =end
44
+ */
45
+ #include "oci8.h"
46
+
47
+ /* #define DEBUG_CORE_FILE 1 */
48
+ #ifdef DEBUG_CORE_FILE
49
+ #include <signal.h>
50
+ #endif
51
+
52
+ VALUE cOCIHandle;
53
+ VALUE cOCIEnv;
54
+ VALUE cOCIServer;
55
+ VALUE cOCISession;
56
+ VALUE cOCISvcCtx;
57
+ VALUE cOCIStmt;
58
+ VALUE cOCIDefine;
59
+ VALUE cOCIBind;
60
+ VALUE cOCIDescribe;
61
+
62
+ VALUE cOCIDescriptor;
63
+ VALUE cOCIParam;
64
+ VALUE cOCILobLocator;
65
+ VALUE cOCIFileLocator;
66
+ VALUE cOCIRowid;
67
+
68
+ VALUE eOCIException;
69
+ VALUE eOCINoData;
70
+ VALUE eOCIError;
71
+ VALUE eOCIInvalidHandle;
72
+ VALUE eOCINeedData;
73
+ VALUE eOCIStillExecuting;
74
+ VALUE eOCIContinue;
75
+ VALUE eOCISuccessWithInfo;
76
+
77
+ VALUE cOraDate;
78
+ VALUE cOraNumber;
79
+
80
+ void
81
+ Init_oci8lib()
82
+ {
83
+ /* Handle */
84
+ cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
85
+ cOCIEnv = rb_define_class("OCIEnv", cOCIHandle);
86
+ cOCISvcCtx = rb_define_class("OCISvcCtx", cOCIHandle);
87
+ cOCIServer = rb_define_class("OCIServer", cOCIHandle);
88
+ cOCISession = rb_define_class("OCISession", cOCIHandle);
89
+ cOCIStmt = rb_define_class("OCIStmt", cOCIHandle);
90
+ cOCIDefine = rb_define_class("OCIDefine", cOCIHandle);
91
+ cOCIBind = rb_define_class("OCIBind", cOCIHandle);
92
+ cOCIDescribe = rb_define_class("OCIDescribe", cOCIHandle);
93
+
94
+ /* Descriptor */
95
+ cOCIDescriptor = rb_define_class("OCIDescriptor", rb_cObject);
96
+ cOCILobLocator = rb_define_class("OCILobLocator", cOCIDescriptor);
97
+ cOCIFileLocator = rb_define_class("OCIFileLocator", cOCILobLocator);
98
+ cOCIParam = rb_define_class("OCIParam", cOCIDescriptor);
99
+ cOCIRowid = rb_define_class("OCIRowid", cOCIDescriptor);
100
+
101
+ /* Exception */
102
+ eOCIException = rb_define_class("OCIException", rb_eStandardError);
103
+ eOCINoData = rb_define_class("OCINoData", eOCIException);
104
+ eOCIError = rb_define_class("OCIError", eOCIException);
105
+ eOCIInvalidHandle = rb_define_class("OCIInvalidHandle", eOCIException);
106
+ eOCINeedData = rb_define_class("OCINeedData", eOCIException);
107
+ eOCIStillExecuting = rb_define_class("OCIStillExecuting", eOCIException);
108
+ eOCIContinue = rb_define_class("OCIContinue", eOCIException);
109
+ eOCISuccessWithInfo = rb_define_class("OCISuccessWithInfo", eOCIError);
110
+
111
+ /* oracle specific type */
112
+ cOraDate = rb_define_class("OraDate", rb_cObject);
113
+ cOraNumber = rb_define_class("OraNumber", rb_cObject);
114
+
115
+ Init_oci8_const();
116
+ Init_oci8_handle();
117
+ Init_oci8_env();
118
+ Init_oci8_error();
119
+ Init_oci8_svcctx();
120
+ Init_oci8_server();
121
+ Init_oci8_session();
122
+ Init_oci8_stmt();
123
+ Init_oci8_define();
124
+ Init_oci8_bind();
125
+ Init_oci8_describe();
126
+
127
+ Init_oci8_descriptor();
128
+ Init_oci8_param();
129
+ Init_oci8_lob();
130
+
131
+ Init_ora_date();
132
+ Init_ora_number();
133
+
134
+ #ifdef DEBUG_CORE_FILE
135
+ signal(SIGSEGV, SIG_DFL);
136
+ #endif
137
+ }
@@ -0,0 +1,345 @@
1
+ /*
2
+ oci8.h - part of ruby-oci8
3
+
4
+ Copyright (C) 2002-2006 KUBO Takehiro <kubo@jiubao.org>
5
+ */
6
+ #ifndef _RUBY_OCI_H_
7
+ #define _RUBY_OCI_H_ 1
8
+
9
+ #include "ruby.h"
10
+ #include "rubyio.h"
11
+ #include "intern.h"
12
+
13
+ #include <stdio.h>
14
+ #include <stdlib.h>
15
+ #ifdef __cplusplus
16
+ extern "C" {
17
+ #endif
18
+ #include <oci.h>
19
+ #ifdef __cplusplus
20
+ }
21
+ #endif
22
+ #include "extconf.h"
23
+
24
+ #ifdef StringValue
25
+ /* ruby 1.8 or later */
26
+ #define RBOCI_NORETURN(x) NORETURN(x)
27
+ #else
28
+ /* ruby 1.6 */
29
+ #define RBOCI_NORETURN(x) x NORETURN
30
+ #define rb_cstr_to_dbl(p, ignore) strtod((p), 0)
31
+ #endif
32
+
33
+ #ifndef RSTRING_PTR
34
+ #define RSTRING_PTR(obj) RSTRING(obj)->ptr
35
+ #endif
36
+ #ifndef RSTRING_LEN
37
+ #define RSTRING_LEN(obj) RSTRING(obj)->len
38
+ #endif
39
+
40
+ #ifndef RARRAY_PTR
41
+ #define RARRAY_PTR(obj) RARRAY(obj)->ptr
42
+ #endif
43
+ #ifndef RARRAY_LEN
44
+ #define RARRAY_LEN(obj) RARRAY(obj)->len
45
+ #endif
46
+
47
+ #define IS_OCI_ERROR(v) (((v) != OCI_SUCCESS) && ((v) != OCI_SUCCESS_WITH_INFO))
48
+
49
+ #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
50
+ /* gcc version >= 3.1 */
51
+ #define ALWAYS_INLINE inline __attribute__((always_inline))
52
+ #endif
53
+ #ifdef _MSC_VER
54
+ /* microsoft c */
55
+ #define ALWAYS_INLINE __forceinline
56
+ #endif
57
+
58
+ #ifdef ALWAYS_INLINE
59
+ /*
60
+ * I don't like cast because it can suppress warnings but may hide bugs.
61
+ * These macros make warnings when the source type is invalid.
62
+ */
63
+ #define TO_ORATEXT to_oratext
64
+ #define TO_CHARPTR to_charptr
65
+ static ALWAYS_INLINE OraText *to_oratext(char *c)
66
+ {
67
+ return (OraText*)c;
68
+ }
69
+ static ALWAYS_INLINE char *to_charptr(OraText *c)
70
+ {
71
+ return (char*)c;
72
+ }
73
+ #else
74
+ /* if not gcc, use normal cast. */
75
+ #define TO_ORATEXT(c) ((OraText*)(c))
76
+ #define TO_CHARPTR(c) ((char*)(c))
77
+ #endif
78
+ #define RSTRING_ORATEXT(obj) TO_ORATEXT(RSTRING_PTR(obj))
79
+
80
+ enum oci8_bind_type {
81
+ BIND_STRING,
82
+ BIND_FIXNUM,
83
+ BIND_INTEGER_VIA_ORA_NUMBER,
84
+ BIND_TIME_VIA_ORA_DATE,
85
+ BIND_FLOAT,
86
+ BIND_BINARY_DOUBLE,
87
+ BIND_ORA_DATE,
88
+ BIND_ORA_NUMBER,
89
+ BIND_HANDLE
90
+ };
91
+
92
+ /* OraDate - Internal format of DATE */
93
+ struct ora_date {
94
+ unsigned char century;
95
+ unsigned char year;
96
+ unsigned char month;
97
+ unsigned char day;
98
+ unsigned char hour;
99
+ unsigned char minute;
100
+ unsigned char second;
101
+ };
102
+ typedef struct ora_date ora_date_t;
103
+
104
+ /* Member of ora_vnumber_t and ora_bind_handle_t - Internal format of NUMBER */
105
+ struct ora_number {
106
+ unsigned char exponent;
107
+ unsigned char mantissa[20];
108
+ };
109
+ typedef struct ora_number ora_number_t;
110
+
111
+ /* OraNumber - Internal format of VARNUM */
112
+ struct ora_vnumber {
113
+ unsigned char size;
114
+ struct ora_number num;
115
+ };
116
+ typedef struct ora_vnumber ora_vnumber_t;
117
+
118
+ /* OCIEnv, OCISvcCtx, OCIServer, OCISession, OCIStmt, OCIDescribe, OCIParam */
119
+ struct oci8_handle {
120
+ ub4 type;
121
+ dvoid *hp;
122
+ OCIError *errhp;
123
+ VALUE self;
124
+ struct oci8_handle *parent;
125
+ size_t size;
126
+ struct oci8_handle **children;
127
+ /* End of common part */
128
+ union {
129
+ struct {
130
+ char is_implicit;
131
+ } param;
132
+ #ifndef OCI8_USE_CALLBACK_LOB_READ
133
+ struct {
134
+ int char_width;
135
+ } lob_locator;
136
+ #endif
137
+ } u;
138
+ };
139
+ typedef struct oci8_handle oci8_handle_t;
140
+
141
+ /* OCIBind, OCIDefine */
142
+ struct oci8_bind_handle {
143
+ ub4 type;
144
+ dvoid *hp;
145
+ OCIError *errhp;
146
+ VALUE self;
147
+ struct oci8_handle *parent;
148
+ size_t size;
149
+ struct oci8_handle **children;
150
+ /* End of common part */
151
+ enum oci8_bind_type bind_type;
152
+ sb2 ind;
153
+ ub2 rlen;
154
+ sb4 value_sz; /* sizeof value */
155
+ union {
156
+ struct {
157
+ sb4 len;
158
+ char buf[1];
159
+ } str;
160
+ long lng;
161
+ double dbl;
162
+ ora_date_t od;
163
+ ora_number_t on;
164
+ struct {
165
+ void *hp;
166
+ VALUE v;
167
+ VALUE klass;
168
+ } handle;
169
+ } value;
170
+ };
171
+ typedef struct oci8_bind_handle oci8_bind_handle_t;
172
+
173
+ #define Get_Handle(obj, hp) do { \
174
+ Data_Get_Struct(obj, oci8_handle_t, hp); \
175
+ } while (0);
176
+
177
+ #define Check_Handle(obj, name, hp) do {\
178
+ if (!rb_obj_is_instance_of(obj, c##name)) { \
179
+ rb_raise(rb_eTypeError, "invalid argument %s (expect " #name ")", rb_class2name(CLASS_OF(obj))); \
180
+ } \
181
+ Data_Get_Struct(obj, oci8_handle_t, hp); \
182
+ } while (0)
183
+
184
+ struct oci8_string {
185
+ OraText *ptr;
186
+ ub4 len;
187
+ };
188
+ typedef struct oci8_string oci8_string_t;
189
+
190
+ #define Get_String(obj, s) do { \
191
+ if (!NIL_P(obj)) { \
192
+ Check_Type(obj, T_STRING); \
193
+ s.ptr = RSTRING_ORATEXT(obj); \
194
+ s.len = RSTRING_LEN(obj); \
195
+ } else { \
196
+ s.ptr = NULL; \
197
+ s.len = 0; \
198
+ } \
199
+ } while (0)
200
+
201
+ #define Get_Int_With_Default(argc, pos, vval, cval, def) do { \
202
+ if (argc >= pos) { \
203
+ Check_Type(vval, T_FIXNUM); \
204
+ cval = FIX2INT(vval); \
205
+ } else { \
206
+ cval = def; \
207
+ } \
208
+ } while (0)
209
+
210
+ #define ATTR_FOR_HNDL 1
211
+ #define ATTR_FOR_DESC 2
212
+ #define ATTR_FOR_BOTH (ATTR_FOR_HNDL | ATTR_FOR_DESC)
213
+ struct oci8_attr {
214
+ const char *name;
215
+ ub4 attr;
216
+ char attr_type;
217
+ VALUE (*get)(oci8_handle_t *hp, ub4 attr);
218
+ void (*set)(oci8_handle_t *hp, ub4 attr, VALUE value);
219
+ };
220
+ typedef struct oci8_attr oci8_attr_t;
221
+
222
+ /* Handle */
223
+ extern VALUE cOCIHandle;
224
+ extern VALUE cOCIEnv;
225
+ extern VALUE cOCISvcCtx;
226
+ extern VALUE cOCIServer;
227
+ extern VALUE cOCISession;
228
+ extern VALUE cOCIStmt;
229
+ extern VALUE cOCIDefine;
230
+ extern VALUE cOCIBind;
231
+ extern VALUE cOCIDescribe;
232
+
233
+ /* Descriptor */
234
+ extern VALUE cOCIDescriptor;
235
+ extern VALUE cOCILobLocator;
236
+ extern VALUE cOCIFileLocator;
237
+ extern VALUE cOCIParam;
238
+ extern VALUE cOCIRowid;
239
+
240
+ /* Exception */
241
+ extern VALUE eOCIException;
242
+ extern VALUE eOCINoData;
243
+ extern VALUE eOCIError;
244
+ extern VALUE eOCIInvalidHandle;
245
+ extern VALUE eOCINeedData;
246
+ extern VALUE eOCIStillExecuting;
247
+ extern VALUE eOCIContinue;
248
+ extern VALUE eOCISuccessWithInfo;
249
+
250
+ /* oracle specific type */
251
+ extern VALUE cOraDate;
252
+ extern VALUE cOraNumber;
253
+
254
+ /* const.c */
255
+ void Init_oci8_const(void);
256
+ extern ID oci8_id_code;
257
+ extern ID oci8_id_define_array;
258
+ extern ID oci8_id_bind_hash;
259
+ extern ID oci8_id_message;
260
+ extern ID oci8_id_new;
261
+ extern ID oci8_id_parse_error_offset;
262
+ extern ID oci8_id_server;
263
+ extern ID oci8_id_session;
264
+ extern ID oci8_id_sql;
265
+
266
+ /* handle.c */
267
+ void Init_oci8_handle(void);
268
+ VALUE oci8_handle_free(VALUE self);
269
+ void oci8_handle_cleanup(oci8_handle_t *);
270
+ VALUE oci8_s_new(VALUE self);
271
+ oci8_handle_t *oci8_make_handle(ub4 type, dvoid *hp, OCIError *errhp, oci8_handle_t *chp, sb4 value_sz);
272
+ void oci8_link(oci8_handle_t *parent, oci8_handle_t *child);
273
+ void oci8_unlink(oci8_handle_t *self);
274
+
275
+ /* env.c */
276
+ void Init_oci8_env(void);
277
+
278
+ /* error.c */
279
+ void Init_oci8_error(void);
280
+ #define oci8_raise(errhp, status, stmthp) oci8_do_raise((errhp), (status), (stmthp), __FILE__, __LINE__)
281
+ #define oci8_env_raise(envhp, status) oci8_do_env_raise((envhp), (status), __FILE__, __LINE__)
282
+ RBOCI_NORETURN(void oci8_do_raise(OCIError *, sword status, OCIStmt *, const char *file, int line));
283
+ RBOCI_NORETURN(void oci8_do_env_raise(OCIEnv *, sword status, const char *file, int line));
284
+
285
+ /* svcctx.c */
286
+ void Init_oci8_svcctx(void);
287
+
288
+ /* server.c */
289
+ void Init_oci8_server(void);
290
+ VALUE oci8_server_version(VALUE self);
291
+ #ifdef HAVE_OCISERVERRELEASE
292
+ VALUE oci8_server_release(VALUE self);
293
+ #endif
294
+ VALUE oci8_break(VALUE self);
295
+ VALUE oci8_reset(VALUE self);
296
+
297
+ /* session.c */
298
+ void Init_oci8_session(void);
299
+
300
+ /* stmt.c */
301
+ void Init_oci8_stmt(void);
302
+
303
+ /* bind.c */
304
+ void Init_oci8_bind(void);
305
+ void oci8_set_value(oci8_bind_handle_t *, VALUE);
306
+ VALUE oci8_get_value(oci8_bind_handle_t *);
307
+
308
+ /* define.c */
309
+ void Init_oci8_define(void);
310
+
311
+ /* describe.c */
312
+ void Init_oci8_describe(void);
313
+
314
+ /* descriptor.c */
315
+ void Init_oci8_descriptor(void);
316
+ VALUE oci8_param_get(VALUE self, VALUE pos);
317
+
318
+ /* param.c */
319
+ void Init_oci8_param(void);
320
+
321
+ /* lob.c */
322
+ void Init_oci8_lob(void);
323
+
324
+ /* oradate.c */
325
+ void Init_ora_date(void);
326
+ void oci8_set_ora_date(ora_date_t *, int year, int month, int day, int hour, int minute, int second);
327
+ void oci8_get_ora_date(ora_date_t *, int *year, int *month, int *day, int *hour, int *minute, int *second);
328
+
329
+ /* oranumber.c */
330
+ #define ORA_NUMBER_BUF_SIZE (128 /* max scale */ + 38 /* max precision */ + 1 /* sign */ + 1 /* comma */ + 1 /* nul */)
331
+ void Init_ora_number(void);
332
+ void ora_number_to_str(unsigned char *buf, size_t *lenp, ora_number_t *on, unsigned char size);
333
+
334
+ /* ocinumber.c */
335
+ int set_oci_vnumber(ora_vnumber_t *result, VALUE num, OCIError *errhp);
336
+
337
+ /* attr.c */
338
+ void Init_oci8_attr(void);
339
+ VALUE oci8_attr_get(VALUE self, VALUE vtype);
340
+ VALUE oci8_attr_set(VALUE self, VALUE vtype, VALUE vvalue);
341
+ extern oci8_attr_t oci8_attr_list[];
342
+ extern size_t oci8_attr_size;
343
+
344
+ #define _D_ fprintf(stderr, "%s:%d - %s\n", __FILE__, __LINE__, __FUNCTION__)
345
+ #endif