do_oracle 0.10.10-java → 0.10.11-java

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.10.11 2012-12-29
2
+
3
+ * Rename C symbols to prevent name collitions
4
+
1
5
  ## 0.10.10 2012-10-11
2
6
 
3
7
  No changes
@@ -10,12 +10,12 @@
10
10
  #include <ctype.h>
11
11
  #include <time.h>
12
12
 
13
- #define ID_CONST_GET rb_intern("const_get")
13
+ #define DO_ID_CONST_GET rb_intern("const_get")
14
14
 
15
15
  #define RUBY_STRING(char_ptr) rb_str_new2(char_ptr)
16
16
  #define TAINTED_STRING(name, length) rb_tainted_str_new(name, length)
17
- #define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
18
- #define ORACLE_CLASS(klass, parent) (rb_define_class_under(mOracle, klass, parent))
17
+ #define CONST_GET(scope, constant) (rb_funcall(scope, DO_ID_CONST_GET, 1, rb_str_new2(constant)))
18
+ #define ORACLE_CLASS(klass, parent) (rb_define_class_under(mDO_Oracle, klass, parent))
19
19
  #define DEBUG(value) data_objects_debug(value)
20
20
  #define RUBY_CLASS(name) rb_const_get(rb_cObject, rb_intern(name))
21
21
 
@@ -33,56 +33,56 @@
33
33
 
34
34
 
35
35
  // To store rb_intern values
36
- static ID ID_NEW;
37
- static ID ID_LOGGER;
38
- static ID ID_DEBUG;
39
- static ID ID_LEVEL;
40
- static ID ID_LOG;
41
- static ID ID_TO_S;
42
- static ID ID_RATIONAL;
43
-
44
- static ID ID_NAME;
45
-
46
- static ID ID_NUMBER;
47
- static ID ID_VARCHAR2;
48
- static ID ID_CHAR;
49
- static ID ID_DATE;
50
- static ID ID_TIMESTAMP;
51
- static ID ID_TIMESTAMP_TZ;
52
- static ID ID_TIMESTAMP_LTZ;
53
- static ID ID_CLOB;
54
- static ID ID_BLOB;
55
- static ID ID_LONG;
56
- static ID ID_RAW;
57
- static ID ID_LONG_RAW;
58
- static ID ID_BFILE;
59
- static ID ID_BINARY_FLOAT;
60
- static ID ID_BINARY_DOUBLE;
61
-
62
- static ID ID_TO_A;
63
- static ID ID_TO_I;
64
- static ID ID_TO_S;
65
- static ID ID_TO_F;
66
-
67
- static ID ID_UTC_OFFSET;
68
- static ID ID_FULL_CONST_GET;
69
-
70
- static ID ID_PARSE;
71
- static ID ID_FETCH;
72
- static ID ID_TYPE;
73
- static ID ID_EXECUTE;
74
- static ID ID_EXEC;
75
-
76
- static ID ID_SELECT_STMT;
77
- static ID ID_COLUMN_METADATA;
78
- static ID ID_PRECISION;
79
- static ID ID_SCALE;
80
- static ID ID_BIND_PARAM;
81
- static ID ID_ELEM;
82
- static ID ID_READ;
83
-
84
- static ID ID_CLOSE;
85
- static ID ID_LOGOFF;
36
+ static ID DO_ID_NEW;
37
+ static ID DO_ID_LOGGER;
38
+ static ID DO_ID_DEBUG;
39
+ static ID DO_ID_LEVEL;
40
+ static ID DO_ID_LOG;
41
+ static ID DO_ID_TO_S;
42
+ static ID DO_ID_RATIONAL;
43
+
44
+ static ID DO_ID_NAME;
45
+
46
+ static ID DO_ID_NUMBER;
47
+ static ID DO_ID_VARCHAR2;
48
+ static ID DO_ID_CHAR;
49
+ static ID DO_ID_DATE;
50
+ static ID DO_ID_TIMESTAMP;
51
+ static ID DO_ID_TIMESTAMP_TZ;
52
+ static ID DO_ID_TIMESTAMP_LTZ;
53
+ static ID DO_ID_CLOB;
54
+ static ID DO_ID_BLOB;
55
+ static ID DO_ID_LONG;
56
+ static ID DO_ID_RAW;
57
+ static ID DO_ID_LONG_RAW;
58
+ static ID DO_ID_BFILE;
59
+ static ID DO_ID_BINARY_FLOAT;
60
+ static ID DO_ID_BINARY_DOUBLE;
61
+
62
+ static ID DO_ID_TO_A;
63
+ static ID DO_ID_TO_I;
64
+ static ID DO_ID_TO_S;
65
+ static ID DO_ID_TO_F;
66
+
67
+ static ID DO_ID_UTC_OFFSET;
68
+ static ID DO_ID_FULL_CONST_GET;
69
+
70
+ static ID DO_ID_PARSE;
71
+ static ID DO_ID_FETCH;
72
+ static ID DO_ID_TYPE;
73
+ static ID DO_ID_EXECUTE;
74
+ static ID DO_ID_EXEC;
75
+
76
+ static ID DO_ID_SELECT_STMT;
77
+ static ID DO_ID_COLUMN_METADATA;
78
+ static ID DO_ID_PRECISION;
79
+ static ID DO_ID_SCALE;
80
+ static ID DO_ID_BIND_PARAM;
81
+ static ID DO_ID_ELEM;
82
+ static ID DO_ID_READ;
83
+
84
+ static ID DO_ID_CLOSE;
85
+ static ID DO_ID_LOGOFF;
86
86
 
87
87
  static VALUE mExtlib;
88
88
  static VALUE mDO;
@@ -104,16 +104,16 @@ static VALUE cOCI8_Cursor;
104
104
  static VALUE cOCI8_BLOB;
105
105
  static VALUE cOCI8_CLOB;
106
106
 
107
- static VALUE mOracle;
108
- static VALUE cConnection;
109
- static VALUE cCommand;
110
- static VALUE cResult;
111
- static VALUE cReader;
107
+ static VALUE mDO_Oracle;
108
+ static VALUE cDO_OracleConnection;
109
+ static VALUE cDO_OracleCommand;
110
+ static VALUE cDO_OracleResult;
111
+ static VALUE cDO_OracleReader;
112
112
 
113
113
  static VALUE eArgumentError;
114
- static VALUE eSQLError;
115
- static VALUE eConnectionError;
116
- static VALUE eDataError;
114
+ static VALUE eDO_SQLError;
115
+ static VALUE eDO_ConnectionError;
116
+ static VALUE eDO_DataError;
117
117
 
118
118
  static void data_objects_debug(VALUE connection, VALUE string, struct timeval* start) {
119
119
  struct timeval stop;
@@ -122,9 +122,9 @@ static void data_objects_debug(VALUE connection, VALUE string, struct timeval* s
122
122
  gettimeofday(&stop, NULL);
123
123
  do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
124
124
 
125
- message = rb_funcall(cDO_Logger_Message, ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
125
+ message = rb_funcall(cDO_Logger_Message, DO_ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
126
126
 
127
- rb_funcall(connection, ID_LOG, 1, message);
127
+ rb_funcall(connection, DO_ID_LOG, 1, message);
128
128
  }
129
129
 
130
130
 
@@ -155,10 +155,10 @@ static VALUE parse_date(VALUE r_value) {
155
155
  year = NUM2INT(rb_funcall(r_value, rb_intern("year"), 0));
156
156
  month = NUM2INT(rb_funcall(r_value, rb_intern("month"), 0));
157
157
  day = NUM2INT(rb_funcall(r_value, rb_intern("day"), 0));
158
- return rb_funcall(rb_cDate, ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
158
+ return rb_funcall(rb_cDate, DO_ID_NEW, 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
159
159
  } else {
160
160
  // Something went terribly wrong
161
- rb_raise(eDataError, "Couldn't parse date from class %s object", rb_obj_classname(r_value));
161
+ rb_raise(eDO_DataError, "Couldn't parse date from class %s object", rb_obj_classname(r_value));
162
162
  }
163
163
  }
164
164
 
@@ -178,7 +178,7 @@ static VALUE parse_date_time(VALUE r_value) {
178
178
  if (rb_obj_class(r_value) == rb_cDateTime) {
179
179
  return r_value;
180
180
  } else if (rb_obj_class(r_value) == rb_cTime) {
181
- time_array = rb_funcall(r_value, ID_TO_A, 0);
181
+ time_array = rb_funcall(r_value, DO_ID_TO_A, 0);
182
182
  year = NUM2INT(rb_ary_entry(time_array, 5));
183
183
  month = NUM2INT(rb_ary_entry(time_array, 4));
184
184
  day = NUM2INT(rb_ary_entry(time_array, 3));
@@ -186,13 +186,13 @@ static VALUE parse_date_time(VALUE r_value) {
186
186
  min = NUM2INT(rb_ary_entry(time_array, 1));
187
187
  sec = NUM2INT(rb_ary_entry(time_array, 0));
188
188
 
189
- gmt_offset = NUM2INT(rb_funcall(r_value, ID_UTC_OFFSET, 0 ));
189
+ gmt_offset = NUM2INT(rb_funcall(r_value, DO_ID_UTC_OFFSET, 0 ));
190
190
 
191
- return rb_funcall(rb_cDateTime, ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
191
+ return rb_funcall(rb_cDateTime, DO_ID_NEW, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day),
192
192
  INT2NUM(hour), INT2NUM(min), INT2NUM(sec), INT2NUM(gmt_offset));
193
193
  } else {
194
194
  // Something went terribly wrong
195
- rb_raise(eDataError, "Couldn't parse datetime from class %s object", rb_obj_classname(r_value));
195
+ rb_raise(eDO_DataError, "Couldn't parse datetime from class %s object", rb_obj_classname(r_value));
196
196
  }
197
197
 
198
198
  }
@@ -202,7 +202,7 @@ static VALUE parse_time(VALUE r_value) {
202
202
  return r_value;
203
203
  } else {
204
204
  // Something went terribly wrong
205
- rb_raise(eDataError, "Couldn't parse time from class %s object", rb_obj_classname(r_value));
205
+ rb_raise(eDO_DataError, "Couldn't parse time from class %s object", rb_obj_classname(r_value));
206
206
  }
207
207
  }
208
208
 
@@ -214,7 +214,7 @@ static VALUE parse_boolean(VALUE r_value) {
214
214
  return value == 'Y' || value == 'y' || value == 'T' || value == 't' ? Qtrue : Qfalse;
215
215
  } else {
216
216
  // Something went terribly wrong
217
- rb_raise(eDataError, "Couldn't parse boolean from class %s object", rb_obj_classname(r_value));
217
+ rb_raise(eDO_DataError, "Couldn't parse boolean from class %s object", rb_obj_classname(r_value));
218
218
  }
219
219
  }
220
220
 
@@ -223,22 +223,22 @@ static VALUE parse_boolean(VALUE r_value) {
223
223
  static VALUE infer_ruby_type(VALUE type, VALUE precision, VALUE scale) {
224
224
  ID type_id = SYM2ID(type);
225
225
 
226
- if (type_id == ID_NUMBER)
226
+ if (type_id == DO_ID_NUMBER)
227
227
  return scale != Qnil && NUM2INT(scale) == 0 ?
228
228
  (NUM2INT(precision) == 1 ? rb_cTrueClass : rb_cInteger) : rb_cBigDecimal;
229
- else if (type_id == ID_VARCHAR2 || type_id == ID_CHAR || type_id == ID_CLOB || type_id == ID_LONG)
229
+ else if (type_id == DO_ID_VARCHAR2 || type_id == DO_ID_CHAR || type_id == DO_ID_CLOB || type_id == DO_ID_LONG)
230
230
  return rb_cString;
231
- else if (type_id == ID_DATE)
231
+ else if (type_id == DO_ID_DATE)
232
232
  // return rb_cDateTime;
233
233
  // by default map DATE type to Time class as it is much faster than DateTime class
234
234
  return rb_cTime;
235
- else if (type_id == ID_TIMESTAMP || type_id == ID_TIMESTAMP_TZ || type_id == ID_TIMESTAMP_LTZ)
235
+ else if (type_id == DO_ID_TIMESTAMP || type_id == DO_ID_TIMESTAMP_TZ || type_id == DO_ID_TIMESTAMP_LTZ)
236
236
  // return rb_cDateTime;
237
237
  // by default map TIMESTAMP type to Time class as it is much faster than DateTime class
238
238
  return rb_cTime;
239
- else if (type_id == ID_BLOB || type_id == ID_RAW || type_id == ID_LONG_RAW || type_id == ID_BFILE)
239
+ else if (type_id == DO_ID_BLOB || type_id == DO_ID_RAW || type_id == DO_ID_LONG_RAW || type_id == DO_ID_BFILE)
240
240
  return rb_cByteArray;
241
- else if (type_id == ID_BINARY_FLOAT || type_id == ID_BINARY_DOUBLE)
241
+ else if (type_id == DO_ID_BINARY_FLOAT || type_id == DO_ID_BINARY_DOUBLE)
242
242
  return rb_cFloat;
243
243
  else
244
244
  return rb_cString;
@@ -248,22 +248,22 @@ static VALUE typecast(VALUE r_value, const VALUE type) {
248
248
  VALUE r_data;
249
249
 
250
250
  if (type == rb_cInteger) {
251
- return TYPE(r_value) == T_FIXNUM || TYPE(r_value) == T_BIGNUM ? r_value : rb_funcall(r_value, ID_TO_I, 0);
251
+ return TYPE(r_value) == T_FIXNUM || TYPE(r_value) == T_BIGNUM ? r_value : rb_funcall(r_value, DO_ID_TO_I, 0);
252
252
 
253
253
  } else if (type == rb_cString) {
254
254
  if (TYPE(r_value) == T_STRING)
255
255
  return r_value;
256
256
  else if (rb_obj_class(r_value) == cOCI8_CLOB)
257
- return rb_funcall(r_value, ID_READ, 0);
257
+ return rb_funcall(r_value, DO_ID_READ, 0);
258
258
  else
259
- return rb_funcall(r_value, ID_TO_S, 0);
259
+ return rb_funcall(r_value, DO_ID_TO_S, 0);
260
260
 
261
261
  } else if (type == rb_cFloat) {
262
- return TYPE(r_value) == T_FLOAT ? r_value : rb_funcall(r_value, ID_TO_F, 0);
262
+ return TYPE(r_value) == T_FLOAT ? r_value : rb_funcall(r_value, DO_ID_TO_F, 0);
263
263
 
264
264
  } else if (type == rb_cBigDecimal) {
265
- VALUE r_string = TYPE(r_value) == T_STRING ? r_value : rb_funcall(r_value, ID_TO_S, 0);
266
- return rb_funcall(rb_cBigDecimal, ID_NEW, 1, r_string);
265
+ VALUE r_string = TYPE(r_value) == T_STRING ? r_value : rb_funcall(r_value, DO_ID_TO_S, 0);
266
+ return rb_funcall(rb_cBigDecimal, DO_ID_NEW, 1, r_string);
267
267
 
268
268
  } else if (type == rb_cDate) {
269
269
  return parse_date(r_value);
@@ -279,20 +279,20 @@ static VALUE typecast(VALUE r_value, const VALUE type) {
279
279
 
280
280
  } else if (type == rb_cByteArray) {
281
281
  if (rb_obj_class(r_value) == cOCI8_BLOB)
282
- r_data = rb_funcall(r_value, ID_READ, 0);
282
+ r_data = rb_funcall(r_value, DO_ID_READ, 0);
283
283
  else
284
284
  r_data = r_value;
285
- return rb_funcall(rb_cByteArray, ID_NEW, 1, r_data);
285
+ return rb_funcall(rb_cByteArray, DO_ID_NEW, 1, r_data);
286
286
 
287
287
  } else if (type == rb_cClass) {
288
- return rb_funcall(mDO, ID_FULL_CONST_GET, 1, r_value);
288
+ return rb_funcall(mDO, DO_ID_FULL_CONST_GET, 1, r_value);
289
289
 
290
290
  } else if (type == rb_cNilClass) {
291
291
  return Qnil;
292
292
 
293
293
  } else {
294
294
  if (rb_obj_class(r_value) == cOCI8_CLOB)
295
- return rb_funcall(r_value, ID_READ, 0);
295
+ return rb_funcall(r_value, DO_ID_READ, 0);
296
296
  else
297
297
  return r_value;
298
298
  }
@@ -308,36 +308,36 @@ static VALUE typecast_bind_value(VALUE connection, VALUE r_value) {
308
308
  return RUBY_STRING("");
309
309
  else if (r_class == rb_cString)
310
310
  // if string is longer than 4000 characters then convert to CLOB
311
- return RSTRING_LEN(r_value) <= 4000 ? r_value : rb_funcall(cOCI8_CLOB, ID_NEW, 2, oci8_conn, r_value);
311
+ return RSTRING_LEN(r_value) <= 4000 ? r_value : rb_funcall(cOCI8_CLOB, DO_ID_NEW, 2, oci8_conn, r_value);
312
312
  else if (r_class == rb_cBigDecimal)
313
- return rb_funcall(r_value, ID_TO_S, 1, RUBY_STRING("F"));
313
+ return rb_funcall(r_value, DO_ID_TO_S, 1, RUBY_STRING("F"));
314
314
  else if (r_class == rb_cTrueClass)
315
315
  return INT2NUM(1);
316
316
  else if (r_class == rb_cFalseClass)
317
317
  return INT2NUM(0);
318
318
  else if (r_class == rb_cByteArray)
319
- return rb_funcall(cOCI8_BLOB, ID_NEW, 2, oci8_conn, r_value);
319
+ return rb_funcall(cOCI8_BLOB, DO_ID_NEW, 2, oci8_conn, r_value);
320
320
  else if (r_class == rb_cClass)
321
- return rb_funcall(r_value, ID_TO_S, 0);
321
+ return rb_funcall(r_value, DO_ID_TO_S, 0);
322
322
  else
323
323
  return r_value;
324
324
  }
325
325
 
326
326
  /* ====== Public API ======= */
327
- static VALUE cConnection_dispose(VALUE self) {
327
+ static VALUE cDO_OracleConnection_dispose(VALUE self) {
328
328
  VALUE oci8_conn = rb_iv_get(self, "@connection");
329
329
 
330
330
  if (Qnil == oci8_conn)
331
331
  return Qfalse;
332
332
 
333
- rb_funcall(oci8_conn, ID_LOGOFF, 0);
333
+ rb_funcall(oci8_conn, DO_ID_LOGOFF, 0);
334
334
 
335
335
  rb_iv_set(self, "@connection", Qnil);
336
336
 
337
337
  return Qtrue;
338
338
  }
339
339
 
340
- static VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self) {
340
+ static VALUE cDO_OracleCommand_set_types(int argc, VALUE *argv, VALUE self) {
341
341
  VALUE type_strings = rb_ary_new();
342
342
  VALUE array = rb_ary_new();
343
343
 
@@ -378,48 +378,48 @@ typedef struct {
378
378
  VALUE args;
379
379
  VALUE sql;
380
380
  struct timeval start;
381
- } cCommand_execute_try_t;
381
+ } cDO_OracleCommand_execute_try_t;
382
382
 
383
- static VALUE cCommand_execute_try(cCommand_execute_try_t *arg);
384
- static VALUE cCommand_execute_ensure(cCommand_execute_try_t *arg);
383
+ static VALUE cDO_OracleCommand_execute_try(cDO_OracleCommand_execute_try_t *arg);
384
+ static VALUE cDO_OracleCommand_execute_ensure(cDO_OracleCommand_execute_try_t *arg);
385
385
 
386
386
  // called by Command#execute that is written in Ruby
387
- static VALUE cCommand_execute_internal(VALUE self, VALUE connection, VALUE sql, VALUE args) {
388
- cCommand_execute_try_t arg;
387
+ static VALUE cDO_OracleCommand_execute_internal(VALUE self, VALUE connection, VALUE sql, VALUE args) {
388
+ cDO_OracleCommand_execute_try_t arg;
389
389
  arg.self = self;
390
390
  arg.connection = connection;
391
391
  arg.sql = sql;
392
392
  // store start time before SQL parsing
393
393
  VALUE oci8_conn = rb_iv_get(connection, "@connection");
394
394
  if (Qnil == oci8_conn) {
395
- rb_raise(eConnectionError, "This connection has already been closed.");
395
+ rb_raise(eDO_ConnectionError, "This connection has already been closed.");
396
396
  }
397
397
  gettimeofday(&arg.start, NULL);
398
- arg.cursor = rb_funcall(oci8_conn, ID_PARSE, 1, sql);
399
- arg.statement_type = rb_funcall(arg.cursor, ID_TYPE, 0);
398
+ arg.cursor = rb_funcall(oci8_conn, DO_ID_PARSE, 1, sql);
399
+ arg.statement_type = rb_funcall(arg.cursor, DO_ID_TYPE, 0);
400
400
  arg.args = args;
401
401
 
402
- return rb_ensure(cCommand_execute_try, (VALUE)&arg, cCommand_execute_ensure, (VALUE)&arg);
402
+ return rb_ensure(cDO_OracleCommand_execute_try, (VALUE)&arg, cDO_OracleCommand_execute_ensure, (VALUE)&arg);
403
403
  }
404
404
 
405
405
  // wrapper for simple SQL calls without arguments
406
406
  static VALUE execute_sql(VALUE connection, VALUE sql) {
407
- return cCommand_execute_internal(Qnil, connection, sql, Qnil);
407
+ return cDO_OracleCommand_execute_internal(Qnil, connection, sql, Qnil);
408
408
  }
409
409
 
410
- static VALUE cCommand_execute_try(cCommand_execute_try_t *arg) {
410
+ static VALUE cDO_OracleCommand_execute_try(cDO_OracleCommand_execute_try_t *arg) {
411
411
  VALUE result = Qnil;
412
412
  int insert_id_present;
413
413
 
414
414
  // no arguments given
415
415
  if NIL_P(arg->args) {
416
- result = rb_funcall(arg->cursor, ID_EXEC, 0);
416
+ result = rb_funcall(arg->cursor, DO_ID_EXEC, 0);
417
417
  // arguments given - need to typecast
418
418
  } else {
419
419
  insert_id_present = (!NIL_P(arg->self) && rb_iv_get(arg->self, "@insert_id_present") == Qtrue);
420
420
 
421
421
  if (insert_id_present)
422
- rb_funcall(arg->cursor, ID_BIND_PARAM, 2, RUBY_STRING(":insert_id"), INT2NUM(0));
422
+ rb_funcall(arg->cursor, DO_ID_BIND_PARAM, 2, RUBY_STRING(":insert_id"), INT2NUM(0));
423
423
 
424
424
  int i;
425
425
  VALUE r_orig_value, r_new_value;
@@ -430,15 +430,15 @@ static VALUE cCommand_execute_try(cCommand_execute_try_t *arg) {
430
430
  rb_ary_store(arg->args, i, r_new_value);
431
431
  }
432
432
 
433
- result = rb_apply(arg->cursor, ID_EXEC, arg->args);
433
+ result = rb_apply(arg->cursor, DO_ID_EXEC, arg->args);
434
434
 
435
435
  if (insert_id_present) {
436
- VALUE insert_id = rb_funcall(arg->cursor, ID_ELEM, 1, RUBY_STRING(":insert_id"));
436
+ VALUE insert_id = rb_funcall(arg->cursor, DO_ID_ELEM, 1, RUBY_STRING(":insert_id"));
437
437
  rb_iv_set(arg->self, "@insert_id", insert_id);
438
438
  }
439
439
  }
440
440
 
441
- if (SYM2ID(arg->statement_type) == ID_SELECT_STMT)
441
+ if (SYM2ID(arg->statement_type) == DO_ID_SELECT_STMT)
442
442
  return arg->cursor;
443
443
  else {
444
444
  return result;
@@ -446,15 +446,15 @@ static VALUE cCommand_execute_try(cCommand_execute_try_t *arg) {
446
446
 
447
447
  }
448
448
 
449
- static VALUE cCommand_execute_ensure(cCommand_execute_try_t *arg) {
450
- if (SYM2ID(arg->statement_type) != ID_SELECT_STMT)
451
- rb_funcall(arg->cursor, ID_CLOSE, 0);
449
+ static VALUE cDO_OracleCommand_execute_ensure(cDO_OracleCommand_execute_try_t *arg) {
450
+ if (SYM2ID(arg->statement_type) != DO_ID_SELECT_STMT)
451
+ rb_funcall(arg->cursor, DO_ID_CLOSE, 0);
452
452
  // Log SQL and execution time
453
453
  data_objects_debug(arg->connection, arg->sql, &(arg->start));
454
454
  return Qnil;
455
455
  }
456
456
 
457
- static VALUE cConnection_initialize(VALUE self, VALUE uri) {
457
+ static VALUE cDO_OracleConnection_initialize(VALUE self, VALUE uri) {
458
458
  VALUE r_host, r_port, r_path, r_user, r_password;
459
459
  VALUE r_query, r_time_zone;
460
460
  char *non_blocking = NULL;
@@ -476,7 +476,7 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
476
476
 
477
477
  r_port = rb_funcall(uri, rb_intern("port"), 0);
478
478
  if ( Qnil != r_port ) {
479
- r_port = rb_funcall(r_port, ID_TO_S, 0);
479
+ r_port = rb_funcall(r_port, DO_ID_TO_S, 0);
480
480
  port = StringValuePtr(r_port);
481
481
  }
482
482
 
@@ -496,11 +496,11 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
496
496
  connect_string = (char *)calloc(connect_string_length, sizeof(char));
497
497
  snprintf(connect_string, connect_string_length, "//%s:%s%s", host, port, path);
498
498
  } else {
499
- rb_raise(eConnectionError, "Database must be specified");
499
+ rb_raise(eDO_ConnectionError, "Database must be specified");
500
500
  }
501
501
 
502
- // oci8_conn = rb_funcall(cOCI8, ID_NEW, 3, r_user, r_password, RUBY_STRING(connect_string));
503
- oci8_conn = rb_funcall(cConnection, rb_intern("oci8_new"), 3, r_user, r_password, RUBY_STRING(connect_string));
502
+ // oci8_conn = rb_funcall(cOCI8, DO_ID_NEW, 3, r_user, r_password, RUBY_STRING(connect_string));
503
+ oci8_conn = rb_funcall(cDO_OracleConnection, rb_intern("oci8_new"), 3, r_user, r_password, RUBY_STRING(connect_string));
504
504
 
505
505
  // Pull the querystring off the URI
506
506
  r_query = rb_funcall(uri, rb_intern("query"), 0);
@@ -523,7 +523,7 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
523
523
 
524
524
  // if no option specified then look in ENV['TZ']
525
525
  if (time_zone == NULL) {
526
- r_time_zone = rb_funcall(cConnection, rb_intern("ruby_time_zone"), 0);
526
+ r_time_zone = rb_funcall(cDO_OracleConnection, rb_intern("ruby_time_zone"), 0);
527
527
  if (!NIL_P(r_time_zone))
528
528
  time_zone = StringValuePtr(r_time_zone);
529
529
  }
@@ -539,17 +539,17 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
539
539
  return Qtrue;
540
540
  }
541
541
 
542
- static VALUE cCommand_execute_non_query(int argc, VALUE *argv[], VALUE self) {
543
- VALUE affected_rows = rb_funcall2(self, ID_EXECUTE, argc, (VALUE *)argv);
542
+ static VALUE cDO_OracleCommand_execute_non_query(int argc, VALUE *argv[], VALUE self) {
543
+ VALUE affected_rows = rb_funcall2(self, DO_ID_EXECUTE, argc, (VALUE *)argv);
544
544
  if (affected_rows == Qtrue)
545
545
  affected_rows = INT2NUM(0);
546
546
 
547
547
  VALUE insert_id = rb_iv_get(self, "@insert_id");
548
548
 
549
- return rb_funcall(cResult, ID_NEW, 3, self, affected_rows, insert_id);
549
+ return rb_funcall(cDO_OracleResult, DO_ID_NEW, 3, self, affected_rows, insert_id);
550
550
  }
551
551
 
552
- static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
552
+ static VALUE cDO_OracleCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
553
553
  VALUE reader, query;
554
554
  VALUE field_names, field_types;
555
555
  VALUE column_metadata, column, column_name;
@@ -558,22 +558,22 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
558
558
  int field_count;
559
559
  int infer_types = 0;
560
560
 
561
- VALUE cursor = rb_funcall2(self, ID_EXECUTE, argc, (VALUE *)argv);
561
+ VALUE cursor = rb_funcall2(self, DO_ID_EXECUTE, argc, (VALUE *)argv);
562
562
 
563
563
  if (rb_obj_class(cursor) != cOCI8_Cursor) {
564
564
  rb_raise(eArgumentError, "\"%s\" is invalid SELECT query", StringValuePtr(query));
565
565
  }
566
566
 
567
- column_metadata = rb_funcall(cursor, ID_COLUMN_METADATA, 0);
567
+ column_metadata = rb_funcall(cursor, DO_ID_COLUMN_METADATA, 0);
568
568
  field_count = RARRAY_LEN(column_metadata);
569
569
  // reduce field_count by 1 if RAW_RNUM_ is present as last column
570
570
  // (generated by DataMapper to simulate LIMIT and OFFSET)
571
571
  column = rb_ary_entry(column_metadata, field_count-1);
572
- column_name = rb_funcall(column, ID_NAME, 0);
572
+ column_name = rb_funcall(column, DO_ID_NAME, 0);
573
573
  if (strncmp(RSTRING_PTR(column_name), "RAW_RNUM_", RSTRING_LEN(column_name)) == 0)
574
574
  field_count--;
575
575
 
576
- reader = rb_funcall(cReader, ID_NEW, 0);
576
+ reader = rb_funcall(cDO_OracleReader, DO_ID_NEW, 0);
577
577
  rb_iv_set(reader, "@reader", cursor);
578
578
  rb_iv_set(reader, "@field_count", INT2NUM(field_count));
579
579
 
@@ -586,19 +586,19 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
586
586
  } else if (RARRAY_LEN(field_types) != field_count) {
587
587
  // Whoops... wrong number of types passed to set_types. Close the reader and raise
588
588
  // and error
589
- rb_funcall(reader, ID_CLOSE, 0);
589
+ rb_funcall(reader, DO_ID_CLOSE, 0);
590
590
  rb_raise(eArgumentError, "Field-count mismatch. Expected %ld fields, but the query yielded %d", RARRAY_LEN(field_types), field_count);
591
591
  }
592
592
 
593
593
  for ( i = 0; i < field_count; i++ ) {
594
594
  column = rb_ary_entry(column_metadata, i);
595
- column_name = rb_funcall(column, ID_NAME, 0);
595
+ column_name = rb_funcall(column, DO_ID_NAME, 0);
596
596
  rb_ary_push(field_names, column_name);
597
597
  if ( infer_types == 1 ) {
598
598
  rb_ary_push(field_types,
599
599
  infer_ruby_type(rb_iv_get(column, "@data_type"),
600
- rb_funcall(column, ID_PRECISION, 0),
601
- rb_funcall(column, ID_SCALE, 0))
600
+ rb_funcall(column, DO_ID_PRECISION, 0),
601
+ rb_funcall(column, DO_ID_SCALE, 0))
602
602
  );
603
603
  }
604
604
  }
@@ -612,19 +612,19 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) {
612
612
  return reader;
613
613
  }
614
614
 
615
- static VALUE cReader_close(VALUE self) {
615
+ static VALUE cDO_OracleReader_close(VALUE self) {
616
616
  VALUE cursor = rb_iv_get(self, "@reader");
617
617
 
618
618
  if (Qnil == cursor)
619
619
  return Qfalse;
620
620
 
621
- rb_funcall(cursor, ID_CLOSE, 0);
621
+ rb_funcall(cursor, DO_ID_CLOSE, 0);
622
622
 
623
623
  rb_iv_set(self, "@reader", Qnil);
624
624
  return Qtrue;
625
625
  }
626
626
 
627
- static VALUE cReader_next(VALUE self) {
627
+ static VALUE cDO_OracleReader_next(VALUE self) {
628
628
  VALUE cursor = rb_iv_get(self, "@reader");
629
629
 
630
630
  int field_count;
@@ -637,7 +637,7 @@ static VALUE cReader_next(VALUE self) {
637
637
  VALUE field_types, field_type;
638
638
  VALUE value;
639
639
 
640
- VALUE fetch_result = rb_funcall(cursor, ID_FETCH, 0);
640
+ VALUE fetch_result = rb_funcall(cursor, DO_ID_FETCH, 0);
641
641
 
642
642
  if (Qnil == fetch_result) {
643
643
  rb_iv_set(self, "@values", Qnil);
@@ -663,22 +663,22 @@ static VALUE cReader_next(VALUE self) {
663
663
  return Qtrue;
664
664
  }
665
665
 
666
- static VALUE cReader_values(VALUE self) {
666
+ static VALUE cDO_OracleReader_values(VALUE self) {
667
667
 
668
668
  VALUE values = rb_iv_get(self, "@values");
669
669
  if(values == Qnil) {
670
- rb_raise(eDataError, "Reader not initialized");
670
+ rb_raise(eDO_DataError, "Reader not initialized");
671
671
  return Qnil;
672
672
  } else {
673
673
  return values;
674
674
  }
675
675
  }
676
676
 
677
- static VALUE cReader_fields(VALUE self) {
677
+ static VALUE cDO_OracleReader_fields(VALUE self) {
678
678
  return rb_iv_get(self, "@fields");
679
679
  }
680
680
 
681
- static VALUE cReader_field_count(VALUE self) {
681
+ static VALUE cDO_OracleReader_field_count(VALUE self) {
682
682
  return rb_iv_get(self, "@field_count");
683
683
  }
684
684
 
@@ -697,56 +697,56 @@ void Init_do_oracle() {
697
697
 
698
698
  rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects"));
699
699
 
700
- ID_NEW = rb_intern("new");
701
- ID_LOGGER = rb_intern("logger");
702
- ID_DEBUG = rb_intern("debug");
703
- ID_LEVEL = rb_intern("level");
704
- ID_LOG = rb_intern("log");
705
- ID_TO_S = rb_intern("to_s");
706
- ID_RATIONAL = rb_intern("Rational");
707
-
708
- ID_NAME = rb_intern("name");
709
-
710
- ID_NUMBER = rb_intern("number");
711
- ID_VARCHAR2 = rb_intern("varchar2");
712
- ID_CHAR = rb_intern("char");
713
- ID_DATE = rb_intern("date");
714
- ID_TIMESTAMP = rb_intern("timestamp");
715
- ID_TIMESTAMP_TZ = rb_intern("timestamp_tz");
716
- ID_TIMESTAMP_LTZ = rb_intern("timestamp_ltz");
717
- ID_CLOB = rb_intern("clob");
718
- ID_BLOB = rb_intern("blob");
719
- ID_LONG = rb_intern("long");
720
- ID_RAW = rb_intern("raw");
721
- ID_LONG_RAW = rb_intern("long_raw");
722
- ID_BFILE = rb_intern("bfile");
723
- ID_BINARY_FLOAT = rb_intern("binary_float");
724
- ID_BINARY_DOUBLE = rb_intern("binary_double");
725
-
726
- ID_TO_A = rb_intern("to_a");
727
- ID_TO_I = rb_intern("to_i");
728
- ID_TO_S = rb_intern("to_s");
729
- ID_TO_F = rb_intern("to_f");
730
-
731
- ID_UTC_OFFSET = rb_intern("utc_offset");
732
- ID_FULL_CONST_GET = rb_intern("full_const_get");
733
-
734
- ID_PARSE = rb_intern("parse");
735
- ID_FETCH = rb_intern("fetch");
736
- ID_TYPE = rb_intern("type");
737
- ID_EXECUTE = rb_intern("execute");
738
- ID_EXEC = rb_intern("exec");
739
-
740
- ID_SELECT_STMT = rb_intern("select_stmt");
741
- ID_COLUMN_METADATA = rb_intern("column_metadata");
742
- ID_PRECISION = rb_intern("precision");
743
- ID_SCALE = rb_intern("scale");
744
- ID_BIND_PARAM = rb_intern("bind_param");
745
- ID_ELEM = rb_intern("[]");
746
- ID_READ = rb_intern("read");
747
-
748
- ID_CLOSE = rb_intern("close");
749
- ID_LOGOFF = rb_intern("logoff");
700
+ DO_ID_NEW = rb_intern("new");
701
+ DO_ID_LOGGER = rb_intern("logger");
702
+ DO_ID_DEBUG = rb_intern("debug");
703
+ DO_ID_LEVEL = rb_intern("level");
704
+ DO_ID_LOG = rb_intern("log");
705
+ DO_ID_TO_S = rb_intern("to_s");
706
+ DO_ID_RATIONAL = rb_intern("Rational");
707
+
708
+ DO_ID_NAME = rb_intern("name");
709
+
710
+ DO_ID_NUMBER = rb_intern("number");
711
+ DO_ID_VARCHAR2 = rb_intern("varchar2");
712
+ DO_ID_CHAR = rb_intern("char");
713
+ DO_ID_DATE = rb_intern("date");
714
+ DO_ID_TIMESTAMP = rb_intern("timestamp");
715
+ DO_ID_TIMESTAMP_TZ = rb_intern("timestamp_tz");
716
+ DO_ID_TIMESTAMP_LTZ = rb_intern("timestamp_ltz");
717
+ DO_ID_CLOB = rb_intern("clob");
718
+ DO_ID_BLOB = rb_intern("blob");
719
+ DO_ID_LONG = rb_intern("long");
720
+ DO_ID_RAW = rb_intern("raw");
721
+ DO_ID_LONG_RAW = rb_intern("long_raw");
722
+ DO_ID_BFILE = rb_intern("bfile");
723
+ DO_ID_BINARY_FLOAT = rb_intern("binary_float");
724
+ DO_ID_BINARY_DOUBLE = rb_intern("binary_double");
725
+
726
+ DO_ID_TO_A = rb_intern("to_a");
727
+ DO_ID_TO_I = rb_intern("to_i");
728
+ DO_ID_TO_S = rb_intern("to_s");
729
+ DO_ID_TO_F = rb_intern("to_f");
730
+
731
+ DO_ID_UTC_OFFSET = rb_intern("utc_offset");
732
+ DO_ID_FULL_CONST_GET = rb_intern("full_const_get");
733
+
734
+ DO_ID_PARSE = rb_intern("parse");
735
+ DO_ID_FETCH = rb_intern("fetch");
736
+ DO_ID_TYPE = rb_intern("type");
737
+ DO_ID_EXECUTE = rb_intern("execute");
738
+ DO_ID_EXEC = rb_intern("exec");
739
+
740
+ DO_ID_SELECT_STMT = rb_intern("select_stmt");
741
+ DO_ID_COLUMN_METADATA = rb_intern("column_metadata");
742
+ DO_ID_PRECISION = rb_intern("precision");
743
+ DO_ID_SCALE = rb_intern("scale");
744
+ DO_ID_BIND_PARAM = rb_intern("bind_param");
745
+ DO_ID_ELEM = rb_intern("[]");
746
+ DO_ID_READ = rb_intern("read");
747
+
748
+ DO_ID_CLOSE = rb_intern("close");
749
+ DO_ID_LOGOFF = rb_intern("logoff");
750
750
 
751
751
  // Get references to the Extlib module
752
752
  mExtlib = CONST_GET(rb_mKernel, "Extlib");
@@ -769,31 +769,31 @@ void Init_do_oracle() {
769
769
  cDO_Logger_Message = CONST_GET(cDO_Logger, "Message");
770
770
 
771
771
  // Top Level Module that all the classes live under
772
- mOracle = rb_define_module_under(mDO, "Oracle");
772
+ mDO_Oracle = rb_define_module_under(mDO, "Oracle");
773
773
 
774
774
  eArgumentError = CONST_GET(rb_mKernel, "ArgumentError");
775
- eSQLError = CONST_GET(mDO, "SQLError");
776
- eConnectionError = CONST_GET(mDO, "ConnectionError");
777
- eDataError = CONST_GET(mDO, "DataError");
775
+ eDO_SQLError = CONST_GET(mDO, "SQLError");
776
+ eDO_ConnectionError = CONST_GET(mDO, "ConnectionError");
777
+ eDO_DataError = CONST_GET(mDO, "DataError");
778
778
  // eOracleError = rb_define_class("OracleError", rb_eStandardError);
779
779
 
780
- cConnection = ORACLE_CLASS("Connection", cDO_Connection);
781
- rb_define_method(cConnection, "initialize", cConnection_initialize, 1);
782
- rb_define_method(cConnection, "dispose", cConnection_dispose, 0);
780
+ cDO_OracleConnection = ORACLE_CLASS("Connection", cDO_Connection);
781
+ rb_define_method(cDO_OracleConnection, "initialize", cDO_OracleConnection_initialize, 1);
782
+ rb_define_method(cDO_OracleConnection, "dispose", cDO_OracleConnection_dispose, 0);
783
783
 
784
- cCommand = ORACLE_CLASS("Command", cDO_Command);
785
- rb_define_method(cCommand, "set_types", cCommand_set_types, -1);
786
- rb_define_method(cCommand, "execute_non_query", cCommand_execute_non_query, -1);
787
- rb_define_method(cCommand, "execute_reader", cCommand_execute_reader, -1);
788
- rb_define_method(cCommand, "execute_internal", cCommand_execute_internal, 3);
784
+ cDO_OracleCommand = ORACLE_CLASS("Command", cDO_Command);
785
+ rb_define_method(cDO_OracleCommand, "set_types", cDO_OracleCommand_set_types, -1);
786
+ rb_define_method(cDO_OracleCommand, "execute_non_query", cDO_OracleCommand_execute_non_query, -1);
787
+ rb_define_method(cDO_OracleCommand, "execute_reader", cDO_OracleCommand_execute_reader, -1);
788
+ rb_define_method(cDO_OracleCommand, "execute_internal", cDO_OracleCommand_execute_internal, 3);
789
789
 
790
- cResult = ORACLE_CLASS("Result", cDO_Result);
790
+ cDO_OracleResult = ORACLE_CLASS("Result", cDO_Result);
791
791
 
792
- cReader = ORACLE_CLASS("Reader", cDO_Reader);
793
- rb_define_method(cReader, "close", cReader_close, 0);
794
- rb_define_method(cReader, "next!", cReader_next, 0);
795
- rb_define_method(cReader, "values", cReader_values, 0);
796
- rb_define_method(cReader, "fields", cReader_fields, 0);
797
- rb_define_method(cReader, "field_count", cReader_field_count, 0);
792
+ cDO_OracleReader = ORACLE_CLASS("Reader", cDO_Reader);
793
+ rb_define_method(cDO_OracleReader, "close", cDO_OracleReader_close, 0);
794
+ rb_define_method(cDO_OracleReader, "next!", cDO_OracleReader_next, 0);
795
+ rb_define_method(cDO_OracleReader, "values", cDO_OracleReader_values, 0);
796
+ rb_define_method(cDO_OracleReader, "fields", cDO_OracleReader_fields, 0);
797
+ rb_define_method(cDO_OracleReader, "field_count", cDO_OracleReader_field_count, 0);
798
798
 
799
799
  }
Binary file
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Oracle
3
- VERSION = '0.10.10'
3
+ VERSION = '0.10.11'
4
4
  end
5
5
  end
data/tasks/compile.rake CHANGED
@@ -32,7 +32,7 @@ begin
32
32
  # Gem::Specification API.
33
33
  gem.dependencies.delete_if { |d| d.name == 'ruby-oci8'}
34
34
 
35
- gem.add_dependency "do_jdbc", '0.10.10'
35
+ gem.add_dependency "do_jdbc", '0.10.11'
36
36
  end
37
37
  end
38
38
  rescue LoadError
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 10
8
- - 10
9
- version: 0.10.10
8
+ - 11
9
+ version: 0.10.11
10
10
  platform: java
11
11
  authors:
12
12
  - Raimonds Simanovskis
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-29 00:00:00 +02:00
17
+ date: 2012-12-29 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -28,8 +28,8 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  - 10
31
- - 10
32
- version: 0.10.10
31
+ - 11
32
+ version: 0.10.11
33
33
  requirement: *id001
34
34
  - !ruby/object:Gem::Dependency
35
35
  prerelease: false
@@ -68,8 +68,8 @@ dependencies:
68
68
  segments:
69
69
  - 0
70
70
  - 10
71
- - 10
72
- version: 0.10.10
71
+ - 11
72
+ version: 0.10.11
73
73
  requirement: *id004
74
74
  description: Implements the DataObjects API for Oracle
75
75
  email: raimonds.simanovskis@gmail.com