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/error.c
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
1
2
|
/*
|
2
3
|
error.c - part of ruby-oci8
|
3
4
|
|
4
|
-
Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
|
5
|
+
Copyright (C) 2002-2007 KUBO Takehiro <kubo@jiubao.org>
|
5
6
|
|
6
7
|
=begin
|
7
8
|
== OCIError
|
@@ -9,133 +10,173 @@
|
|
9
10
|
*/
|
10
11
|
#include "oci8.h"
|
11
12
|
|
13
|
+
/* Exception */
|
14
|
+
VALUE eOCIException;
|
15
|
+
VALUE eOCIBreak;
|
16
|
+
static VALUE eOCINoData;
|
17
|
+
static VALUE eOCIError;
|
18
|
+
static VALUE eOCIInvalidHandle;
|
19
|
+
static VALUE eOCINeedData;
|
20
|
+
static VALUE eOCIStillExecuting;
|
21
|
+
static VALUE eOCIContinue;
|
22
|
+
static VALUE eOCISuccessWithInfo;
|
23
|
+
|
24
|
+
static ID oci8_id_code;
|
25
|
+
static ID oci8_id_message;
|
26
|
+
static ID oci8_id_parse_error_offset;
|
27
|
+
static ID oci8_id_sql;
|
12
28
|
static ID oci8_id_caller;
|
13
29
|
static ID oci8_id_set_backtrace;
|
14
30
|
|
15
|
-
|
31
|
+
NORETURN(static void oci8_raise2(dvoid *errhp, sword status, ub4 type, OCIStmt *stmthp, const char *file, int line));
|
32
|
+
NORETURN(static void set_backtrace_and_raise(VALUE exc, const char *file, int line));
|
16
33
|
|
17
34
|
static void oci8_raise2(dvoid *errhp, sword status, ub4 type, OCIStmt *stmthp, const char *file, int line)
|
18
35
|
{
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
36
|
+
VALUE vcodes = Qnil;
|
37
|
+
VALUE vmessages = Qnil;
|
38
|
+
VALUE exc;
|
39
|
+
char errmsg[1024];
|
40
|
+
sb4 errcode;
|
41
|
+
ub4 recodeno;
|
42
|
+
VALUE msg;
|
26
43
|
#ifdef OCI_ATTR_PARSE_ERROR_OFFSET
|
27
|
-
|
44
|
+
VALUE vparse_error_offset = Qnil;
|
28
45
|
#endif
|
29
46
|
#ifdef OCI_ATTR_STATEMENT
|
30
|
-
|
31
|
-
#endif
|
32
|
-
int i;
|
33
|
-
int rv;
|
34
|
-
VALUE backtrace;
|
35
|
-
#if defined(_WIN32) || defined(WIN32)
|
36
|
-
char *p = strrchr(file, '\\');
|
37
|
-
if (p != NULL)
|
38
|
-
file = p + 1;
|
47
|
+
VALUE vsql = Qnil;
|
39
48
|
#endif
|
49
|
+
int i;
|
50
|
+
int rv;
|
40
51
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
switch (status) {
|
53
|
+
case OCI_ERROR:
|
54
|
+
case OCI_SUCCESS_WITH_INFO:
|
55
|
+
vcodes = rb_ary_new();
|
56
|
+
vmessages = rb_ary_new();
|
57
|
+
for (recodeno = 1;;recodeno++) {
|
58
|
+
/* get error string */
|
59
|
+
rv = OCIErrorGet(errhp, recodeno, NULL, &errcode, TO_ORATEXT(errmsg), sizeof(errmsg), type);
|
60
|
+
if (rv != OCI_SUCCESS) {
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
/* chop error string */
|
64
|
+
for (i = strlen(errmsg) - 1;i >= 0;i--) {
|
65
|
+
if (errmsg[i] == '\n' || errmsg[i] == '\r') {
|
66
|
+
errmsg[i] = '\0';
|
67
|
+
} else {
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
rb_ary_push(vcodes, INT2FIX(errcode));
|
72
|
+
rb_ary_push(vmessages, rb_external_str_new_with_enc(errmsg, strlen(errmsg), oci8_encoding));
|
73
|
+
}
|
74
|
+
if (RARRAY_LEN(vmessages) > 0) {
|
75
|
+
msg = RARRAY_PTR(vmessages)[0];
|
76
|
+
} else {
|
77
|
+
msg = rb_usascii_str_new_cstr("ERROR");
|
78
|
+
}
|
79
|
+
if (status == OCI_ERROR) {
|
80
|
+
exc = eOCIError;
|
81
|
+
} else {
|
82
|
+
exc = eOCISuccessWithInfo;
|
83
|
+
}
|
84
|
+
#ifdef OCI_ATTR_PARSE_ERROR_OFFSET
|
85
|
+
if (stmthp != NULL) {
|
86
|
+
ub2 offset;
|
87
|
+
rv = OCIAttrGet(stmthp, OCI_HTYPE_STMT, &offset, 0, OCI_ATTR_PARSE_ERROR_OFFSET, errhp);
|
88
|
+
if (rv == OCI_SUCCESS) {
|
89
|
+
vparse_error_offset = INT2FIX(offset);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
#endif
|
93
|
+
#ifdef OCI_ATTR_STATEMENT
|
94
|
+
if (stmthp != NULL) {
|
95
|
+
text *sql;
|
96
|
+
ub4 size;
|
97
|
+
rv = OCIAttrGet(stmthp, OCI_HTYPE_STMT, &sql, &size, OCI_ATTR_STATEMENT, errhp);
|
98
|
+
if (rv == OCI_SUCCESS) {
|
99
|
+
vsql = rb_external_str_new_with_enc(TO_CHARPTR(sql), size, oci8_encoding);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
#endif
|
103
|
+
break;
|
104
|
+
case OCI_NO_DATA:
|
105
|
+
exc = eOCINoData;
|
106
|
+
msg = rb_usascii_str_new_cstr("No Data");
|
107
|
+
break;
|
108
|
+
case OCI_INVALID_HANDLE:
|
109
|
+
exc = eOCIInvalidHandle;
|
110
|
+
msg = rb_usascii_str_new_cstr("Invalid Handle");
|
111
|
+
break;
|
112
|
+
case OCI_NEED_DATA:
|
113
|
+
exc = eOCINeedData;
|
114
|
+
msg = rb_usascii_str_new_cstr("Need Data");
|
50
115
|
break;
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
116
|
+
case OCI_STILL_EXECUTING:
|
117
|
+
exc = eOCIStillExecuting;
|
118
|
+
msg = rb_usascii_str_new_cstr("Still Executing");
|
119
|
+
break;
|
120
|
+
case OCI_CONTINUE:
|
121
|
+
exc = eOCIContinue;
|
122
|
+
msg = rb_usascii_str_new_cstr("Continue");
|
123
|
+
break;
|
124
|
+
default:
|
125
|
+
sprintf(errmsg, "Unknown error (%d)", status);
|
126
|
+
exc = rb_eStandardError;
|
127
|
+
msg = rb_usascii_str_new_cstr(errmsg);
|
62
128
|
}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
msg = rb_str_new2("ERROR");
|
129
|
+
exc = rb_funcall(exc, oci8_id_new, 1, msg);
|
130
|
+
if (!NIL_P(vcodes)) {
|
131
|
+
rb_ivar_set(exc, oci8_id_code, vcodes);
|
67
132
|
}
|
68
|
-
if (
|
69
|
-
|
70
|
-
} else {
|
71
|
-
exc = eOCISuccessWithInfo;
|
133
|
+
if (!NIL_P(vmessages)) {
|
134
|
+
rb_ivar_set(exc, oci8_id_message, vmessages);
|
72
135
|
}
|
73
|
-
break;
|
74
|
-
case OCI_NO_DATA:
|
75
|
-
exc = eOCINoData;
|
76
|
-
msg = rb_str_new2("No Data");
|
77
|
-
break;
|
78
|
-
case OCI_INVALID_HANDLE:
|
79
|
-
exc = eOCIInvalidHandle;
|
80
|
-
msg = rb_str_new2("Invalid Handle");
|
81
|
-
break;
|
82
|
-
case OCI_NEED_DATA:
|
83
|
-
exc = eOCINeedData;
|
84
|
-
msg = rb_str_new2("Need Data");
|
85
|
-
break;
|
86
|
-
case OCI_STILL_EXECUTING:
|
87
|
-
exc = eOCIStillExecuting;
|
88
|
-
msg = rb_str_new2("Still Executing");
|
89
|
-
break;
|
90
|
-
case OCI_CONTINUE:
|
91
|
-
exc = eOCIContinue;
|
92
|
-
msg = rb_str_new2("Continue");
|
93
|
-
break;
|
94
|
-
default:
|
95
|
-
sprintf(errmsg, "Unknown error (%d)", status);
|
96
|
-
exc = rb_eStandardError;
|
97
|
-
msg = rb_str_new2(errmsg);
|
98
|
-
}
|
99
|
-
exc = rb_funcall(exc, oci8_id_new, 1, msg);
|
100
|
-
if (!NIL_P(vcodes)) {
|
101
|
-
rb_ivar_set(exc, oci8_id_code, vcodes);
|
102
|
-
}
|
103
|
-
if (!NIL_P(vmessages)) {
|
104
|
-
rb_ivar_set(exc, oci8_id_message, vmessages);
|
105
|
-
}
|
106
136
|
#ifdef OCI_ATTR_PARSE_ERROR_OFFSET
|
107
|
-
|
108
|
-
|
109
|
-
|
137
|
+
if (!NIL_P(vparse_error_offset)) {
|
138
|
+
rb_ivar_set(exc, oci8_id_parse_error_offset, vparse_error_offset);
|
139
|
+
}
|
110
140
|
#endif
|
111
141
|
#ifdef OCI_ATTR_STATEMENT
|
112
|
-
|
113
|
-
|
114
|
-
|
142
|
+
if (!NIL_P(vsql)) {
|
143
|
+
rb_ivar_set(exc, oci8_id_sql, vsql);
|
144
|
+
}
|
115
145
|
#endif
|
116
|
-
|
117
|
-
* make error line in C code.
|
118
|
-
*/
|
119
|
-
backtrace = rb_funcall(rb_cObject, rb_intern("caller"), 0);
|
120
|
-
sprintf(errmsg, "%s:%d:in oci8lib.so", file, line);
|
121
|
-
rb_ary_unshift(backtrace, rb_str_new2(errmsg));
|
122
|
-
rb_funcall(exc, rb_intern("set_backtrace"), 1, backtrace);
|
123
|
-
rb_exc_raise(exc);
|
146
|
+
set_backtrace_and_raise(exc, file, line);
|
124
147
|
}
|
125
148
|
|
126
|
-
static
|
149
|
+
static void set_backtrace_and_raise(VALUE exc, const char *file, int line)
|
127
150
|
{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
151
|
+
char errmsg[64];
|
152
|
+
VALUE backtrace;
|
153
|
+
#ifdef _WIN32
|
154
|
+
char *p = strrchr(file, '\\');
|
155
|
+
if (p != NULL)
|
156
|
+
file = p + 1;
|
157
|
+
#endif
|
158
|
+
backtrace = rb_funcall(rb_cObject, oci8_id_caller, 0);
|
159
|
+
if (TYPE(backtrace) == T_ARRAY) {
|
160
|
+
snprintf(errmsg, sizeof(errmsg), "%s:%d:in oci8lib.so", file, line);
|
161
|
+
errmsg[sizeof(errmsg) - 1] = '\0';
|
162
|
+
rb_ary_unshift(backtrace, rb_usascii_str_new_cstr(errmsg));
|
163
|
+
rb_funcall(exc, oci8_id_set_backtrace, 1, backtrace);
|
164
|
+
}
|
165
|
+
rb_exc_raise(exc);
|
137
166
|
}
|
138
167
|
|
168
|
+
static VALUE oci8_error_initialize(int argc, VALUE *argv, VALUE self)
|
169
|
+
{
|
170
|
+
VALUE msg;
|
171
|
+
VALUE code;
|
172
|
+
|
173
|
+
rb_scan_args(argc, argv, "02", &msg, &code);
|
174
|
+
rb_call_super(argc > 1 ? 1 : argc, argv);
|
175
|
+
if (!NIL_P(code)) {
|
176
|
+
rb_ivar_set(self, oci8_id_code, rb_ary_new3(1, code));
|
177
|
+
}
|
178
|
+
return Qnil;
|
179
|
+
}
|
139
180
|
|
140
181
|
/*
|
141
182
|
=begin
|
@@ -144,15 +185,11 @@ static VALUE oci8_error_initialize(int argc, VALUE *argv, VALUE self)
|
|
144
185
|
*/
|
145
186
|
static VALUE oci8_error_code(VALUE self)
|
146
187
|
{
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
if (RARRAY_LEN(ary) == 0) {
|
153
|
-
return Qnil;
|
154
|
-
}
|
155
|
-
return RARRAY_PTR(ary)[0];
|
188
|
+
VALUE ary = rb_ivar_get(self, oci8_id_code);
|
189
|
+
if (RARRAY_LEN(ary) == 0) {
|
190
|
+
return Qnil;
|
191
|
+
}
|
192
|
+
return RARRAY_PTR(ary)[0];
|
156
193
|
}
|
157
194
|
|
158
195
|
/*
|
@@ -162,7 +199,7 @@ static VALUE oci8_error_code(VALUE self)
|
|
162
199
|
*/
|
163
200
|
static VALUE oci8_error_code_array(VALUE self)
|
164
201
|
{
|
165
|
-
|
202
|
+
return rb_ivar_get(self, oci8_id_code);
|
166
203
|
}
|
167
204
|
|
168
205
|
/*
|
@@ -178,7 +215,7 @@ static VALUE oci8_error_code_array(VALUE self)
|
|
178
215
|
*/
|
179
216
|
static VALUE oci8_error_message_array(VALUE self)
|
180
217
|
{
|
181
|
-
|
218
|
+
return rb_ivar_get(self, oci8_id_message);
|
182
219
|
}
|
183
220
|
|
184
221
|
#ifdef OCI_ATTR_PARSE_ERROR_OFFSET
|
@@ -189,7 +226,7 @@ static VALUE oci8_error_message_array(VALUE self)
|
|
189
226
|
*/
|
190
227
|
static VALUE oci8_error_parse_error_offset(VALUE self)
|
191
228
|
{
|
192
|
-
|
229
|
+
return rb_ivar_get(self, oci8_id_parse_error_offset);
|
193
230
|
}
|
194
231
|
#endif
|
195
232
|
|
@@ -202,33 +239,65 @@ static VALUE oci8_error_parse_error_offset(VALUE self)
|
|
202
239
|
*/
|
203
240
|
static VALUE oci8_error_sql(VALUE self)
|
204
241
|
{
|
205
|
-
|
242
|
+
return rb_ivar_get(self, oci8_id_sql);
|
206
243
|
}
|
207
244
|
#endif
|
208
245
|
|
246
|
+
sb4 oci8_get_error_code(OCIError *errhp)
|
247
|
+
{
|
248
|
+
sb4 errcode = -1;
|
249
|
+
OCIErrorGet(oci8_errhp, 1, NULL, &errcode, NULL, 0, OCI_HTYPE_ERROR);
|
250
|
+
return errcode;
|
251
|
+
}
|
252
|
+
|
209
253
|
void Init_oci8_error(void)
|
210
254
|
{
|
211
|
-
|
212
|
-
|
255
|
+
oci8_id_code = rb_intern("code");
|
256
|
+
oci8_id_message = rb_intern("message");
|
257
|
+
oci8_id_parse_error_offset = rb_intern("parse_error_offset");
|
258
|
+
oci8_id_sql = rb_intern("sql");
|
259
|
+
oci8_id_caller = rb_intern("caller");
|
260
|
+
oci8_id_set_backtrace = rb_intern("set_backtrace");
|
261
|
+
|
262
|
+
eOCIException = rb_define_class("OCIException", rb_eStandardError);
|
263
|
+
eOCIBreak = rb_define_class("OCIBreak", eOCIException);
|
264
|
+
|
265
|
+
eOCINoData = rb_define_class("OCINoData", eOCIException);
|
266
|
+
eOCIError = rb_define_class("OCIError", eOCIException);
|
267
|
+
eOCIInvalidHandle = rb_define_class("OCIInvalidHandle", eOCIException);
|
268
|
+
eOCINeedData = rb_define_class("OCINeedData", eOCIException);
|
269
|
+
eOCIStillExecuting = rb_define_class("OCIStillExecuting", eOCIException);
|
270
|
+
eOCIContinue = rb_define_class("OCIContinue", eOCIException);
|
271
|
+
eOCISuccessWithInfo = rb_define_class("OCISuccessWithInfo", eOCIError);
|
213
272
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
273
|
+
rb_define_method(eOCIError, "initialize", oci8_error_initialize, -1);
|
274
|
+
rb_define_method(eOCIError, "code", oci8_error_code, 0);
|
275
|
+
rb_define_method(eOCIError, "codes", oci8_error_code_array, 0);
|
276
|
+
rb_define_method(eOCIError, "messages", oci8_error_message_array, 0);
|
218
277
|
#ifdef OCI_ATTR_PARSE_ERROR_OFFSET
|
219
|
-
|
278
|
+
rb_define_method(eOCIError, "parseErrorOffset", oci8_error_parse_error_offset, 0);
|
220
279
|
#endif
|
221
280
|
#ifdef OCI_ATTR_STATEMENT
|
222
|
-
|
281
|
+
rb_define_method(eOCIError, "sql", oci8_error_sql, 0);
|
223
282
|
#endif
|
224
283
|
}
|
225
284
|
|
226
285
|
void oci8_do_raise(OCIError *errhp, sword status, OCIStmt *stmthp, const char *file, int line)
|
227
286
|
{
|
228
|
-
|
287
|
+
oci8_raise2(errhp, status, OCI_HTYPE_ERROR, stmthp, file, line);
|
229
288
|
}
|
230
289
|
|
231
290
|
void oci8_do_env_raise(OCIEnv *envhp, sword status, const char *file, int line)
|
232
291
|
{
|
233
|
-
|
292
|
+
oci8_raise2(envhp, status, OCI_HTYPE_ENV, NULL, file, line);
|
293
|
+
}
|
294
|
+
|
295
|
+
void oci8_do_raise_init_error(const char *file, int line)
|
296
|
+
{
|
297
|
+
VALUE msg = rb_usascii_str_new_cstr("OCI Library Initialization Error");
|
298
|
+
VALUE exc = rb_funcall(eOCIError, oci8_id_new, 1, msg);
|
299
|
+
|
300
|
+
rb_ivar_set(exc, oci8_id_code, rb_ary_new3(1, INT2FIX(-1)));
|
301
|
+
rb_ivar_set(exc, oci8_id_message, rb_ary_new3(1, msg));
|
302
|
+
set_backtrace_and_raise(exc, file, line);
|
234
303
|
}
|
data/ext/oci8/extconf.rb
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
raise <<EOS if RUBY_VERSION.index("1.9") == 0
|
2
|
-
---------------------------------------------------
|
3
|
-
error message:
|
4
|
-
ruby-oci8 1.0 is not supported by ruby #{RUBY_VERSION}.
|
5
|
-
Use ruby-oci8 2.0 in SVN trunk.
|
6
|
-
---------------------------------------------------
|
7
|
-
EOS
|
8
|
-
|
9
1
|
begin
|
10
2
|
require 'mkmf'
|
11
3
|
rescue LoadError
|
@@ -18,8 +10,9 @@ EOS
|
|
18
10
|
end
|
19
11
|
|
20
12
|
require File.dirname(__FILE__) + '/oraconf'
|
13
|
+
require File.dirname(__FILE__) + '/apiwrap'
|
21
14
|
|
22
|
-
RUBY_OCI8_VERSION =
|
15
|
+
RUBY_OCI8_VERSION = File.read("#{File.dirname(__FILE__)}/../../VERSION").chomp
|
23
16
|
|
24
17
|
oraconf = OraConf.get()
|
25
18
|
|
@@ -36,58 +29,81 @@ def replace_keyword(source, target, replace)
|
|
36
29
|
}
|
37
30
|
end
|
38
31
|
|
39
|
-
$objs = ["oci8.o", "handle.o", "const.o", "env.o", "error.o", "svcctx.o",
|
40
|
-
"server.o", "session.o", "stmt.o", "define.o", "bind.o",
|
41
|
-
"describe.o", "descriptor.o", "param.o", "lob.o",
|
42
|
-
"oradate.o", "oranumber.o", "ocinumber.o", "attr.o"]
|
43
|
-
|
44
32
|
$CFLAGS += oraconf.cflags
|
33
|
+
saved_libs = $libs
|
45
34
|
$libs += oraconf.libs
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
36
|
+
oci_actual_client_version = 0x08000000
|
37
|
+
funcs = {}
|
38
|
+
YAML.load(open(File.dirname(__FILE__) + '/apiwrap.yml')).each do |key, val|
|
39
|
+
key = key[0..-4] if key[-3..-1] == '_nb'
|
40
|
+
ver = val[:version]
|
41
|
+
ver_major = (ver / 100)
|
42
|
+
ver_minor = (ver / 10) % 10
|
43
|
+
ver_update = ver % 10
|
44
|
+
ver = ((ver_major << 24) | (ver_minor << 20) | (ver_update << 12))
|
45
|
+
funcs[ver] ||= []
|
46
|
+
funcs[ver] << key
|
47
|
+
end
|
48
|
+
funcs.keys.sort.each do |version|
|
49
|
+
next if version == 0x08000000
|
50
|
+
verstr = format('%d.%d.%d', ((version >> 24) & 0xFF), ((version >> 20) & 0xF), ((version >> 12) & 0xFF))
|
51
|
+
puts "checking for Oracle #{verstr} API - start"
|
52
|
+
result = catch :result do
|
53
|
+
funcs[version].sort.each do |func|
|
54
|
+
unless have_func(func)
|
55
|
+
throw :result, "fail"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
oci_actual_client_version = version
|
59
|
+
"pass"
|
60
|
+
end
|
61
|
+
puts "checking for Oracle #{verstr} API - #{result}"
|
62
|
+
break if result == 'fail'
|
63
|
+
end
|
64
|
+
$defs << "-DACTUAL_ORACLE_CLIENT_VERSION=#{format('0x%08x', oci_actual_client_version)}"
|
73
65
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
66
|
+
if with_config('oracle-version')
|
67
|
+
oci_client_version = with_config('oracle-version').to_i
|
68
|
+
else
|
69
|
+
oci_client_version = oci_actual_client_version
|
70
|
+
end
|
71
|
+
$defs << "-DORACLE_CLIENT_VERSION=#{format('0x%08x', oci_client_version)}"
|
78
72
|
|
79
|
-
|
80
|
-
|
73
|
+
if with_config('runtime-check')
|
74
|
+
$defs << "-DRUNTIME_API_CHECK=1"
|
75
|
+
$libs = saved_libs
|
76
|
+
end
|
81
77
|
|
82
|
-
|
78
|
+
$objs = ["oci8lib.o", "env.o", "error.o", "oci8.o",
|
79
|
+
"stmt.o", "bind.o", "metadata.o", "attr.o",
|
80
|
+
"lob.o", "oradate.o",
|
81
|
+
"ocinumber.o", "ocidatetime.o", "object.o", "apiwrap.o",
|
82
|
+
"encoding.o", "xmldb.o"]
|
83
83
|
|
84
|
-
|
84
|
+
if RUBY_PLATFORM =~ /mswin32|cygwin|mingw32|bccwin32/
|
85
|
+
$defs << "-DUSE_WIN32_C"
|
86
|
+
$objs << "win32.o"
|
87
|
+
end
|
85
88
|
|
86
89
|
# Checking gcc or not
|
87
90
|
if oraconf.cc_is_gcc
|
88
91
|
$CFLAGS += " -Wall"
|
89
92
|
end
|
90
93
|
|
94
|
+
have_func("localtime_r")
|
95
|
+
|
96
|
+
# ruby 1.8 headers
|
97
|
+
have_header("intern.h")
|
98
|
+
have_header("util.h")
|
99
|
+
# ruby 1.9 headers
|
100
|
+
have_header("ruby/util.h")
|
101
|
+
have_type('rb_encoding', ['ruby/ruby.h', 'ruby/encoding.h'])
|
102
|
+
|
103
|
+
# $! in C API
|
104
|
+
have_var("ruby_errinfo", "ruby.h") # ruby 1.8
|
105
|
+
have_func("rb_errinfo", "ruby.h") # ruby 1.9
|
106
|
+
|
91
107
|
# replace files
|
92
108
|
replace = {
|
93
109
|
'OCI8_CLIENT_VERSION' => oraconf.version,
|
@@ -98,25 +114,32 @@ replace = {
|
|
98
114
|
replace_keyword(File.dirname(__FILE__) + '/../../lib/oci8.rb.in', '../../lib/oci8.rb', replace)
|
99
115
|
|
100
116
|
create_header()
|
101
|
-
$defs = []
|
102
117
|
|
103
118
|
# make dependency file
|
104
119
|
open("depend", "w") do |f|
|
105
|
-
|
106
|
-
|
120
|
+
extconf_opt = ''
|
121
|
+
['oracle-version', 'runtime-check'].each do |arg|
|
122
|
+
opt = with_config(arg)
|
123
|
+
case opt
|
124
|
+
when String
|
125
|
+
extconf_opt += " --with-#{arg}=#{opt}"
|
126
|
+
when true
|
127
|
+
extconf_opt += " --with-#{arg}=yes"
|
128
|
+
when false
|
129
|
+
extconf_opt += " --with-#{arg}=no"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
f.puts("Makefile: $(srcdir)/extconf.rb $(srcdir)/oraconf.rb")
|
133
|
+
f.puts("\t$(RUBY) $(srcdir)/extconf.rb#{extconf_opt}")
|
107
134
|
$objs.each do |obj|
|
108
|
-
f.puts("#{obj}: $(srcdir)/#{obj.sub(/\.o$/, ".c")} $(srcdir)/oci8.h Makefile")
|
135
|
+
f.puts("#{obj}: $(srcdir)/#{obj.sub(/\.o$/, ".c")} $(srcdir)/oci8.h apiwrap.h Makefile")
|
109
136
|
end
|
137
|
+
f.puts("apiwrap.c apiwrap.h: $(srcdir)/apiwrap.c.tmpl $(srcdir)/apiwrap.h.tmpl $(srcdir)/apiwrap.yml $(srcdir)/apiwrap.rb")
|
138
|
+
f.puts("\t$(RUBY) $(srcdir)/apiwrap.rb")
|
110
139
|
end
|
111
140
|
|
141
|
+
create_apiwrap()
|
112
142
|
|
113
143
|
create_makefile("oci8lib")
|
114
144
|
|
115
|
-
# append version info to extconf.h
|
116
|
-
open("extconf.h", "a") do |f|
|
117
|
-
replace.each do |key, value|
|
118
|
-
f.puts("#define #{key} \"#{value}\"")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
145
|
exit 0
|