do_oracle 0.10.1-x86-mswin32-60 → 0.10.2-x86-mswin32-60
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.
- data/ChangeLog.markdown +4 -1
- data/ext/do_oracle/do_oracle.c +38 -43
- data/lib/do_oracle.rb +1 -4
- data/lib/do_oracle/1.8/do_oracle.so +0 -0
- data/lib/do_oracle/1.9/do_oracle.so +0 -0
- data/lib/do_oracle/version.rb +1 -1
- data/tasks/compile.rake +1 -1
- metadata +42 -22
data/ChangeLog.markdown
CHANGED
data/ext/do_oracle/do_oracle.c
CHANGED
@@ -38,6 +38,7 @@ static ID ID_NEW_DATE;
|
|
38
38
|
static ID ID_LOGGER;
|
39
39
|
static ID ID_DEBUG;
|
40
40
|
static ID ID_LEVEL;
|
41
|
+
static ID ID_LOG;
|
41
42
|
static ID ID_TO_S;
|
42
43
|
static ID ID_RATIONAL;
|
43
44
|
|
@@ -91,6 +92,8 @@ static VALUE cDO_Connection;
|
|
91
92
|
static VALUE cDO_Command;
|
92
93
|
static VALUE cDO_Result;
|
93
94
|
static VALUE cDO_Reader;
|
95
|
+
static VALUE cDO_Logger;
|
96
|
+
static VALUE cDO_Logger_Message;
|
94
97
|
|
95
98
|
static VALUE rb_cDate;
|
96
99
|
static VALUE rb_cDateTime;
|
@@ -113,31 +116,19 @@ static VALUE eSQLError;
|
|
113
116
|
static VALUE eConnectionError;
|
114
117
|
static VALUE eDataError;
|
115
118
|
|
116
|
-
static void data_objects_debug(VALUE string, struct timeval* start) {
|
119
|
+
static void data_objects_debug(VALUE connection, VALUE string, struct timeval* start) {
|
117
120
|
struct timeval stop;
|
118
|
-
|
121
|
+
VALUE message;
|
119
122
|
|
120
|
-
|
121
|
-
|
122
|
-
char total_time[32];
|
123
|
-
do_int64 duration = 0;
|
123
|
+
gettimeofday(&stop, NULL);
|
124
|
+
do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
|
124
125
|
|
125
|
-
|
126
|
-
int log_level = NUM2INT(rb_funcall(logger, ID_LEVEL, 0));
|
126
|
+
message = rb_funcall(cDO_Logger_Message, ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
|
127
127
|
|
128
|
-
|
129
|
-
gettimeofday(&stop, NULL);
|
130
|
-
|
131
|
-
duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
|
132
|
-
|
133
|
-
snprintf(total_time, 32, "%.6f", duration / 1000000.0);
|
134
|
-
message = (char *)calloc(length + strlen(total_time) + 4, sizeof(char));
|
135
|
-
snprintf(message, length + strlen(total_time) + 4, "(%s) %s", total_time, query);
|
136
|
-
rb_funcall(logger, ID_DEBUG, 1, rb_str_new(message, length + strlen(total_time) + 3));
|
137
|
-
free(message);
|
138
|
-
}
|
128
|
+
rb_funcall(connection, ID_LOG, 1, message);
|
139
129
|
}
|
140
130
|
|
131
|
+
|
141
132
|
static char * get_uri_option(VALUE query_hash, char * key) {
|
142
133
|
VALUE query_value;
|
143
134
|
char * value = NULL;
|
@@ -392,13 +383,6 @@ static VALUE typecast(VALUE r_value, const VALUE type) {
|
|
392
383
|
} else if (type == rb_cClass) {
|
393
384
|
return rb_funcall(mDO, ID_FULL_CONST_GET, 1, r_value);
|
394
385
|
|
395
|
-
// TODO: where are tests for this mapping?
|
396
|
-
} else if (type == rb_cObject) {
|
397
|
-
if (rb_obj_class(r_value) == cOCI8_CLOB)
|
398
|
-
return rb_marshal_load(rb_funcall(r_value, ID_READ, 0));
|
399
|
-
else
|
400
|
-
return rb_marshal_load(r_value);
|
401
|
-
|
402
386
|
} else if (type == rb_cNilClass) {
|
403
387
|
return Qnil;
|
404
388
|
|
@@ -411,8 +395,9 @@ static VALUE typecast(VALUE r_value, const VALUE type) {
|
|
411
395
|
|
412
396
|
}
|
413
397
|
|
414
|
-
static VALUE typecast_bind_value(VALUE
|
398
|
+
static VALUE typecast_bind_value(VALUE connection, VALUE r_value) {
|
415
399
|
VALUE r_class = rb_obj_class(r_value);
|
400
|
+
VALUE oci8_conn = rb_iv_get(connection, "@connection");
|
416
401
|
// replace nil value with '' as otherwise OCI8 cannot get bind variable type
|
417
402
|
// '' will be inserted as NULL by Oracle
|
418
403
|
if (NIL_P(r_value))
|
@@ -483,7 +468,7 @@ static VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self) {
|
|
483
468
|
|
484
469
|
typedef struct {
|
485
470
|
VALUE self;
|
486
|
-
VALUE
|
471
|
+
VALUE connection;
|
487
472
|
VALUE cursor;
|
488
473
|
VALUE statement_type;
|
489
474
|
VALUE args;
|
@@ -495,12 +480,16 @@ static VALUE cCommand_execute_try(cCommand_execute_try_t *arg);
|
|
495
480
|
static VALUE cCommand_execute_ensure(cCommand_execute_try_t *arg);
|
496
481
|
|
497
482
|
// called by Command#execute that is written in Ruby
|
498
|
-
static VALUE cCommand_execute_internal(VALUE self, VALUE
|
483
|
+
static VALUE cCommand_execute_internal(VALUE self, VALUE connection, VALUE sql, VALUE args) {
|
499
484
|
cCommand_execute_try_t arg;
|
500
485
|
arg.self = self;
|
501
|
-
arg.
|
486
|
+
arg.connection = connection;
|
502
487
|
arg.sql = sql;
|
503
488
|
// store start time before SQL parsing
|
489
|
+
VALUE oci8_conn = rb_iv_get(connection, "@connection");
|
490
|
+
if (Qnil == oci8_conn) {
|
491
|
+
rb_raise(eConnectionError, "This connection has already been closed.");
|
492
|
+
}
|
504
493
|
gettimeofday(&arg.start, NULL);
|
505
494
|
arg.cursor = rb_funcall(oci8_conn, ID_PARSE, 1, sql);
|
506
495
|
arg.statement_type = rb_funcall(arg.cursor, ID_TYPE, 0);
|
@@ -510,8 +499,8 @@ static VALUE cCommand_execute_internal(VALUE self, VALUE oci8_conn, VALUE sql, V
|
|
510
499
|
}
|
511
500
|
|
512
501
|
// wrapper for simple SQL calls without arguments
|
513
|
-
static VALUE execute_sql(VALUE
|
514
|
-
return cCommand_execute_internal(Qnil,
|
502
|
+
static VALUE execute_sql(VALUE connection, VALUE sql) {
|
503
|
+
return cCommand_execute_internal(Qnil, connection, sql, Qnil);
|
515
504
|
}
|
516
505
|
|
517
506
|
static VALUE cCommand_execute_try(cCommand_execute_try_t *arg) {
|
@@ -532,7 +521,7 @@ static VALUE cCommand_execute_try(cCommand_execute_try_t *arg) {
|
|
532
521
|
VALUE r_orig_value, r_new_value;
|
533
522
|
for (i = 0; i < RARRAY_LEN(arg->args); i++) {
|
534
523
|
r_orig_value = rb_ary_entry(arg->args, i);
|
535
|
-
r_new_value = typecast_bind_value(arg->
|
524
|
+
r_new_value = typecast_bind_value(arg->connection, r_orig_value);
|
536
525
|
if (r_orig_value != r_new_value)
|
537
526
|
rb_ary_store(arg->args, i, r_new_value);
|
538
527
|
}
|
@@ -557,7 +546,7 @@ static VALUE cCommand_execute_ensure(cCommand_execute_try_t *arg) {
|
|
557
546
|
if (SYM2ID(arg->statement_type) != ID_SELECT_STMT)
|
558
547
|
rb_funcall(arg->cursor, ID_CLOSE, 0);
|
559
548
|
// Log SQL and execution time
|
560
|
-
data_objects_debug(arg->sql, &(arg->start));
|
549
|
+
data_objects_debug(arg->connection, arg->sql, &(arg->start));
|
561
550
|
return Qnil;
|
562
551
|
}
|
563
552
|
|
@@ -588,7 +577,9 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
|
|
588
577
|
}
|
589
578
|
|
590
579
|
r_path = rb_funcall(uri, rb_intern("path"), 0);
|
591
|
-
|
580
|
+
if ( Qnil != r_path ) {
|
581
|
+
path = StringValuePtr(r_path);
|
582
|
+
}
|
592
583
|
|
593
584
|
// If just host name is specified then use it as TNS names alias
|
594
585
|
if ((r_host != Qnil && RSTRING_LEN(r_host) > 0) &&
|
@@ -596,7 +587,7 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
|
|
596
587
|
(r_path == Qnil || RSTRING_LEN(r_path) == 0)) {
|
597
588
|
connect_string = host;
|
598
589
|
// If database name is specified in path (in format "/database")
|
599
|
-
} else if (strlen(path) > 1) {
|
590
|
+
} else if (path != NULL && strlen(path) > 1) {
|
600
591
|
connect_string_length = strlen(host) + strlen(port) + strlen(path) + 4;
|
601
592
|
connect_string = (char *)calloc(connect_string_length, sizeof(char));
|
602
593
|
snprintf(connect_string, connect_string_length, "//%s:%s%s", host, port, path);
|
@@ -622,6 +613,10 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
|
|
622
613
|
// Set session time zone
|
623
614
|
// at first look for option in connection string
|
624
615
|
time_zone = get_uri_option(r_query, "time_zone");
|
616
|
+
|
617
|
+
rb_iv_set(self, "@uri", uri);
|
618
|
+
rb_iv_set(self, "@connection", oci8_conn);
|
619
|
+
|
625
620
|
// if no option specified then look in ENV['TZ']
|
626
621
|
if (time_zone == NULL) {
|
627
622
|
r_time_zone = rb_funcall(cConnection, rb_intern("ruby_time_zone"), 0);
|
@@ -630,15 +625,12 @@ static VALUE cConnection_initialize(VALUE self, VALUE uri) {
|
|
630
625
|
}
|
631
626
|
if (time_zone) {
|
632
627
|
snprintf(set_time_zone_command, 80, "alter session set time_zone = '%s'", time_zone);
|
633
|
-
execute_sql(
|
628
|
+
execute_sql(self, RUBY_STRING(set_time_zone_command));
|
634
629
|
}
|
635
630
|
|
636
|
-
execute_sql(
|
637
|
-
execute_sql(
|
638
|
-
execute_sql(
|
639
|
-
|
640
|
-
rb_iv_set(self, "@uri", uri);
|
641
|
-
rb_iv_set(self, "@connection", oci8_conn);
|
631
|
+
execute_sql(self, RUBY_STRING("alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'"));
|
632
|
+
execute_sql(self, RUBY_STRING("alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'"));
|
633
|
+
execute_sql(self, RUBY_STRING("alter session set nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'"));
|
642
634
|
|
643
635
|
return Qtrue;
|
644
636
|
}
|
@@ -808,6 +800,7 @@ void Init_do_oracle() {
|
|
808
800
|
ID_LOGGER = rb_intern("logger");
|
809
801
|
ID_DEBUG = rb_intern("debug");
|
810
802
|
ID_LEVEL = rb_intern("level");
|
803
|
+
ID_LOG = rb_intern("log");
|
811
804
|
ID_TO_S = rb_intern("to_s");
|
812
805
|
ID_RATIONAL = rb_intern("Rational");
|
813
806
|
|
@@ -871,6 +864,8 @@ void Init_do_oracle() {
|
|
871
864
|
cDO_Command = CONST_GET(mDO, "Command");
|
872
865
|
cDO_Result = CONST_GET(mDO, "Result");
|
873
866
|
cDO_Reader = CONST_GET(mDO, "Reader");
|
867
|
+
cDO_Logger = CONST_GET(mDO, "Logger");
|
868
|
+
cDO_Logger_Message = CONST_GET(cDO_Logger, "Message");
|
874
869
|
|
875
870
|
// Top Level Module that all the classes live under
|
876
871
|
mOracle = rb_define_module_under(mDO, "Oracle");
|
data/lib/do_oracle.rb
CHANGED
@@ -41,11 +41,8 @@ if RUBY_PLATFORM !~ /java/
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def execute(*args)
|
44
|
-
oci8_conn = @connection.instance_variable_get("@connection")
|
45
|
-
raise ConnectionError, "This connection has already been closed." unless oci8_conn
|
46
|
-
|
47
44
|
sql, bind_variables = replace_argument_placeholders(@text, args)
|
48
|
-
execute_internal(
|
45
|
+
execute_internal(@connection, sql, bind_variables)
|
49
46
|
rescue OCIError => e
|
50
47
|
raise SQLError.new(e.message, e.code, nil, e.sql, @connection.to_s)
|
51
48
|
end
|
Binary file
|
Binary file
|
data/lib/do_oracle/version.rb
CHANGED
data/tasks/compile.rake
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do_oracle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 10
|
8
|
+
- 2
|
9
|
+
version: 0.10.2
|
5
10
|
platform: x86-mswin32-60
|
6
11
|
authors:
|
7
12
|
- Raimonds Simanovskis
|
@@ -9,49 +14,62 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-05-19 00:00:00 +02:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: data_objects
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - "="
|
22
26
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 10
|
30
|
+
- 2
|
31
|
+
version: 0.10.2
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: ruby-oci8
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ~>
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 0
|
33
44
|
version: "2.0"
|
34
|
-
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
35
47
|
- !ruby/object:Gem::Dependency
|
36
48
|
name: bacon
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
42
53
|
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 1
|
56
|
+
- 1
|
43
57
|
version: "1.1"
|
44
|
-
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id003
|
45
60
|
- !ruby/object:Gem::Dependency
|
46
61
|
name: rake-compiler
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ~>
|
52
66
|
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
- 7
|
53
70
|
version: "0.7"
|
54
|
-
|
71
|
+
type: :development
|
72
|
+
version_requirements: *id004
|
55
73
|
description: Implements the DataObjects API for Oracle
|
56
74
|
email: raimonds.simanovskis@gmail.com
|
57
75
|
executables: []
|
@@ -113,18 +131,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
131
|
requirements:
|
114
132
|
- - ">="
|
115
133
|
- !ruby/object:Gem::Version
|
134
|
+
segments:
|
135
|
+
- 0
|
116
136
|
version: "0"
|
117
|
-
version:
|
118
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
138
|
requirements:
|
120
139
|
- - ">="
|
121
140
|
- !ruby/object:Gem::Version
|
141
|
+
segments:
|
142
|
+
- 0
|
122
143
|
version: "0"
|
123
|
-
version:
|
124
144
|
requirements: []
|
125
145
|
|
126
146
|
rubyforge_project: dorb
|
127
|
-
rubygems_version: 1.3.
|
147
|
+
rubygems_version: 1.3.6
|
128
148
|
signing_key:
|
129
149
|
specification_version: 3
|
130
150
|
summary: DataObjects Oracle Driver
|