ruby-oci8 2.1.8 → 2.2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +2 -0
- data/ChangeLog +186 -0
- data/Makefile +2 -2
- data/NEWS +64 -5
- data/README.md +10 -8
- data/dist-files +7 -2
- data/docs/install-instant-client.md +7 -5
- data/docs/install-on-osx.md +132 -0
- data/docs/osx-install-dev-tools.png +0 -0
- data/docs/report-installation-issue.md +1 -4
- data/ext/oci8/apiwrap.c.tmpl +0 -4
- data/ext/oci8/apiwrap.yml +2 -62
- data/ext/oci8/bind.c +1 -3
- data/ext/oci8/encoding.c +56 -168
- data/ext/oci8/env.c +0 -46
- data/ext/oci8/error.c +6 -32
- data/ext/oci8/extconf.rb +33 -39
- data/ext/oci8/lob.c +110 -118
- data/ext/oci8/oci8.c +19 -174
- data/ext/oci8/oci8.h +10 -121
- data/ext/oci8/oci8lib.c +26 -69
- data/ext/oci8/ocidatetime.c +4 -46
- data/ext/oci8/ocinumber.c +7 -30
- data/ext/oci8/oraconf.rb +64 -4
- data/ext/oci8/stmt.c +2 -9
- data/ext/oci8/thread_util.c +0 -4
- data/ext/oci8/thread_util.h +0 -12
- data/ext/oci8/util.c +71 -0
- data/ext/oci8/win32.c +1 -25
- data/lib/{oci8.rb.in → oci8.rb} +11 -3
- data/lib/oci8/bindtype.rb +3 -13
- data/lib/oci8/check_load_error.rb +99 -0
- data/lib/oci8/encoding-init.rb +27 -61
- data/lib/oci8/metadata.rb +27 -57
- data/lib/oci8/oci8.rb +17 -18
- data/lib/oci8/properties.rb +1 -9
- data/lib/oci8/version.rb +3 -0
- data/ruby-oci8.gemspec +15 -5
- data/test/test_oci8.rb +14 -2
- data/test/test_package_type.rb +967 -0
- metadata +28 -11
- data/VERSION +0 -1
data/ext/oci8/oci8.c
CHANGED
@@ -250,9 +250,7 @@ static VALUE oci8_svcctx_alloc(VALUE klass)
|
|
250
250
|
|
251
251
|
svcctx->pid = getpid();
|
252
252
|
svcctx->is_autocommit = 0;
|
253
|
-
#ifdef NATIVE_THREAD_WITH_GVL
|
254
253
|
svcctx->non_blocking = 1;
|
255
|
-
#endif
|
256
254
|
svcctx->long_read_len = INT2FIX(65535);
|
257
255
|
return self;
|
258
256
|
}
|
@@ -267,10 +265,10 @@ static VALUE oracle_client_vernum; /* Oracle client version number */
|
|
267
265
|
* It is devided into 5 parts: 8, 4, 8, 4 and 8 bits.
|
268
266
|
*
|
269
267
|
* @example
|
270
|
-
* # Oracle
|
271
|
-
* oracle_client_vernum # =>
|
272
|
-
* # =>
|
273
|
-
* # =>
|
268
|
+
* # Oracle 10.2.0.4
|
269
|
+
* oracle_client_vernum # => 0x0a200400
|
270
|
+
* # => 0x0a 2 00 4 00
|
271
|
+
* # => 10.2.0.4.0
|
274
272
|
*
|
275
273
|
* # Oracle 11.1.0.7.0
|
276
274
|
* oracle_client_vernum # => 0x0b100700
|
@@ -761,14 +759,7 @@ static VALUE oci8_rollback(VALUE self)
|
|
761
759
|
static VALUE oci8_non_blocking_p(VALUE self)
|
762
760
|
{
|
763
761
|
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
764
|
-
#ifdef NATIVE_THREAD_WITH_GVL
|
765
762
|
return svcctx->non_blocking ? Qtrue : Qfalse;
|
766
|
-
#else
|
767
|
-
sb1 non_blocking;
|
768
|
-
|
769
|
-
chker2(OCIAttrGet(svcctx->srvhp, OCI_HTYPE_SERVER, &non_blocking, 0, OCI_ATTR_NONBLOCKING_MODE, oci8_errhp), &svcctx->base);
|
770
|
-
return non_blocking ? Qtrue : Qfalse;
|
771
|
-
#endif
|
772
763
|
}
|
773
764
|
|
774
765
|
/*
|
@@ -791,20 +782,7 @@ static VALUE oci8_non_blocking_p(VALUE self)
|
|
791
782
|
static VALUE oci8_set_non_blocking(VALUE self, VALUE val)
|
792
783
|
{
|
793
784
|
oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
|
794
|
-
#ifdef NATIVE_THREAD_WITH_GVL
|
795
785
|
svcctx->non_blocking = RTEST(val);
|
796
|
-
#else
|
797
|
-
sb1 non_blocking;
|
798
|
-
|
799
|
-
if (svcctx->state & OCI8_STATE_CPOOL) {
|
800
|
-
rb_raise(rb_eRuntimeError, "Could not set non-blocking mode to a connection allocated from OCI8::ConnectionPool.");
|
801
|
-
}
|
802
|
-
chker2(OCIAttrGet(svcctx->srvhp, OCI_HTYPE_SERVER, &non_blocking, 0, OCI_ATTR_NONBLOCKING_MODE, oci8_errhp), &svcctx->base);
|
803
|
-
if ((RTEST(val) && !non_blocking) || (!RTEST(val) && non_blocking)) {
|
804
|
-
/* toggle blocking / non-blocking. */
|
805
|
-
chker2(OCIAttrSet(svcctx->srvhp, OCI_HTYPE_SERVER, 0, 0, OCI_ATTR_NONBLOCKING_MODE, oci8_errhp), &svcctx->base);
|
806
|
-
}
|
807
|
-
#endif
|
808
786
|
return val;
|
809
787
|
}
|
810
788
|
|
@@ -894,9 +872,6 @@ static VALUE oci8_break(VALUE self)
|
|
894
872
|
if (NIL_P(svcctx->executing_thread)) {
|
895
873
|
return Qfalse;
|
896
874
|
}
|
897
|
-
#ifndef NATIVE_THREAD_WITH_GVL
|
898
|
-
chker2(OCIBreak(svcctx->base.hp.ptr, oci8_errhp), &svcctx->base);
|
899
|
-
#endif
|
900
875
|
rb_thread_wakeup(svcctx->executing_thread);
|
901
876
|
return Qtrue;
|
902
877
|
}
|
@@ -960,21 +935,9 @@ static VALUE oci8_ping(VALUE self)
|
|
960
935
|
*
|
961
936
|
* Sets the specified value to {V$SESSION.CLIENT_IDENTIFIER}[http://docs.oracle.com/database/121/REFRN/refrn30223.htm#r62c1-t21].
|
962
937
|
*
|
963
|
-
* === Oracle 9i client or upper
|
964
|
-
*
|
965
938
|
* The specified value is sent to the server by piggybacking on the next network
|
966
939
|
* round trip issued by {OCI8#exec}, {OCI8#ping} and so on.
|
967
940
|
*
|
968
|
-
* === Oracle 8i client or lower
|
969
|
-
*
|
970
|
-
* This executes the following PL/SQL block internally.
|
971
|
-
*
|
972
|
-
* BEGIN
|
973
|
-
* DBMS_SESSION.SET_IDENTIFIER(:client_id);
|
974
|
-
* END;
|
975
|
-
*
|
976
|
-
* See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sessio.htm#i996935]
|
977
|
-
*
|
978
941
|
* @param [String] client_identifier
|
979
942
|
* @since 2.0.3
|
980
943
|
*/
|
@@ -993,29 +956,12 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
|
|
993
956
|
size = 0;
|
994
957
|
}
|
995
958
|
|
996
|
-
if (
|
997
|
-
|
998
|
-
rb_raise(rb_eArgError, "client identifier should not start with ':'.");
|
999
|
-
}
|
1000
|
-
chker2(OCIAttrSet(svcctx->usrhp, OCI_HTYPE_SESSION, (dvoid*)ptr,
|
1001
|
-
size, OCI_ATTR_CLIENT_IDENTIFIER, oci8_errhp),
|
1002
|
-
&svcctx->base);
|
1003
|
-
} else {
|
1004
|
-
/* Workaround for Bug 2449486 */
|
1005
|
-
oci8_exec_sql_var_t bind_vars[1];
|
1006
|
-
|
1007
|
-
/* :client_id */
|
1008
|
-
bind_vars[0].valuep = (dvoid*)ptr;
|
1009
|
-
bind_vars[0].value_sz = size;
|
1010
|
-
bind_vars[0].dty = SQLT_CHR;
|
1011
|
-
bind_vars[0].indp = NULL;
|
1012
|
-
bind_vars[0].alenp = NULL;
|
1013
|
-
|
1014
|
-
oci8_exec_sql(svcctx,
|
1015
|
-
"BEGIN\n"
|
1016
|
-
" DBMS_SESSION.SET_IDENTIFIER(:client_id);\n"
|
1017
|
-
"END;\n", 0, NULL, 1, bind_vars, 1);
|
959
|
+
if (size > 0 && ptr[0] == ':') {
|
960
|
+
rb_raise(rb_eArgError, "client identifier should not start with ':'.");
|
1018
961
|
}
|
962
|
+
chker2(OCIAttrSet(svcctx->usrhp, OCI_HTYPE_SESSION, (dvoid*)ptr,
|
963
|
+
size, OCI_ATTR_CLIENT_IDENTIFIER, oci8_errhp),
|
964
|
+
&svcctx->base);
|
1019
965
|
return val;
|
1020
966
|
}
|
1021
967
|
|
@@ -1027,26 +973,6 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
|
|
1027
973
|
* and {V$SQLAREA.MODULE}[http://docs.oracle.com/database/121/REFRN/refrn30259.htm#r46c1-t94]
|
1028
974
|
* when an SQL statement is first parsed in the Oracle server.
|
1029
975
|
*
|
1030
|
-
* === Oracle 10g client or upper
|
1031
|
-
*
|
1032
|
-
* The specified value is sent to the server by piggybacking on the next network
|
1033
|
-
* round trip issued by {OCI8#exec}, {OCI8#ping} and so on.
|
1034
|
-
*
|
1035
|
-
* === Oracle 9i client or lower
|
1036
|
-
*
|
1037
|
-
* This executes the following PL/SQL block internally.
|
1038
|
-
*
|
1039
|
-
* DECLARE
|
1040
|
-
* action VARCHAR2(32);
|
1041
|
-
* BEGIN
|
1042
|
-
* -- retrieve action name.
|
1043
|
-
* SELECT SYS_CONTEXT('USERENV','ACTION') INTO action FROM DUAL;
|
1044
|
-
* -- change module name without modifying the action name.
|
1045
|
-
* DBMS_APPLICATION_INFO.SET_MODULE(:module, action);
|
1046
|
-
* END;
|
1047
|
-
*
|
1048
|
-
* See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#i999254]
|
1049
|
-
*
|
1050
976
|
* @param [String] module
|
1051
977
|
* @since 2.0.3
|
1052
978
|
*/
|
@@ -1064,30 +990,9 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
|
|
1064
990
|
ptr = "";
|
1065
991
|
size = 0;
|
1066
992
|
}
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
size, OCI_ATTR_MODULE, oci8_errhp),
|
1071
|
-
&svcctx->base);
|
1072
|
-
} else {
|
1073
|
-
/* Oracle 9i or lower */
|
1074
|
-
oci8_exec_sql_var_t bind_vars[1];
|
1075
|
-
|
1076
|
-
/* :module */
|
1077
|
-
bind_vars[0].valuep = (dvoid*)ptr;
|
1078
|
-
bind_vars[0].value_sz = size;
|
1079
|
-
bind_vars[0].dty = SQLT_CHR;
|
1080
|
-
bind_vars[0].indp = NULL;
|
1081
|
-
bind_vars[0].alenp = NULL;
|
1082
|
-
|
1083
|
-
oci8_exec_sql(svcctx,
|
1084
|
-
"DECLARE\n"
|
1085
|
-
" action VARCHAR2(32);\n"
|
1086
|
-
"BEGIN\n"
|
1087
|
-
" SELECT SYS_CONTEXT('USERENV','ACTION') INTO action FROM DUAL;\n"
|
1088
|
-
" DBMS_APPLICATION_INFO.SET_MODULE(:module, action);\n"
|
1089
|
-
"END;\n", 0, NULL, 1, bind_vars, 1);
|
1090
|
-
}
|
993
|
+
chker2(OCIAttrSet(svcctx->usrhp, OCI_HTYPE_SESSION, (dvoid*)ptr,
|
994
|
+
size, OCI_ATTR_MODULE, oci8_errhp),
|
995
|
+
&svcctx->base);
|
1091
996
|
return self;
|
1092
997
|
}
|
1093
998
|
|
@@ -1099,21 +1004,9 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
|
|
1099
1004
|
* and {V$SQLAREA.ACTION}[http://docs.oracle.com/database/121/REFRN/refrn30259.htm#r48c1-t94]
|
1100
1005
|
* when an SQL statement is first parsed in the Oracle server.
|
1101
1006
|
*
|
1102
|
-
* === Oracle 10g client or upper
|
1103
|
-
*
|
1104
1007
|
* The specified value is sent to the server by piggybacking on the next network
|
1105
1008
|
* round trip issued by {OCI8#exec}, {OCI8#ping} and so on.
|
1106
1009
|
*
|
1107
|
-
* === Oracle 9i client or lower
|
1108
|
-
*
|
1109
|
-
* This executes the following PL/SQL block internally.
|
1110
|
-
*
|
1111
|
-
* BEGIN
|
1112
|
-
* DBMS_APPLICATION_INFO.SET_ACTION(:action);
|
1113
|
-
* END;
|
1114
|
-
*
|
1115
|
-
* See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#i999254]
|
1116
|
-
*
|
1117
1010
|
* @param [String] action
|
1118
1011
|
* @since 2.0.3
|
1119
1012
|
*/
|
@@ -1131,27 +1024,9 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
|
|
1131
1024
|
ptr = "";
|
1132
1025
|
size = 0;
|
1133
1026
|
}
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
size, OCI_ATTR_ACTION, oci8_errhp),
|
1138
|
-
&svcctx->base);
|
1139
|
-
} else {
|
1140
|
-
/* Oracle 9i or lower */
|
1141
|
-
oci8_exec_sql_var_t bind_vars[1];
|
1142
|
-
|
1143
|
-
/* :action */
|
1144
|
-
bind_vars[0].valuep = (dvoid*)ptr;
|
1145
|
-
bind_vars[0].value_sz = size;
|
1146
|
-
bind_vars[0].dty = SQLT_CHR;
|
1147
|
-
bind_vars[0].indp = NULL;
|
1148
|
-
bind_vars[0].alenp = NULL;
|
1149
|
-
|
1150
|
-
oci8_exec_sql(svcctx,
|
1151
|
-
"BEGIN\n"
|
1152
|
-
" DBMS_APPLICATION_INFO.SET_ACTION(:action);\n"
|
1153
|
-
"END;\n", 0, NULL, 1, bind_vars, 1);
|
1154
|
-
}
|
1027
|
+
chker2(OCIAttrSet(svcctx->usrhp, OCI_HTYPE_SESSION, (dvoid*)ptr,
|
1028
|
+
size, OCI_ATTR_ACTION, oci8_errhp),
|
1029
|
+
&svcctx->base);
|
1155
1030
|
return val;
|
1156
1031
|
}
|
1157
1032
|
|
@@ -1160,21 +1035,9 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
|
|
1160
1035
|
*
|
1161
1036
|
* Sets the specified value to {V$SESSION.CLIENT_INFO}[http://docs.oracle.com/database/121/REFRN/refrn30223.htm#r44c1-t21].
|
1162
1037
|
*
|
1163
|
-
* === Oracle 10g client or upper
|
1164
|
-
*
|
1165
1038
|
* The specified value is sent to the server by piggybacking on the next network
|
1166
1039
|
* round trip issued by {OCI8#exec}, {OCI8#ping} and so on.
|
1167
1040
|
*
|
1168
|
-
* === Oracle 9i client or lower
|
1169
|
-
*
|
1170
|
-
* This executes the following PL/SQL block internally.
|
1171
|
-
*
|
1172
|
-
* BEGIN
|
1173
|
-
* DBMS_APPLICATION_INFO.SET_CLIENT_INFO(:client_info);
|
1174
|
-
* END;
|
1175
|
-
*
|
1176
|
-
* See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#CHEJCFGG]
|
1177
|
-
*
|
1178
1041
|
* @param [String] client_info
|
1179
1042
|
* @since 2.0.3
|
1180
1043
|
*/
|
@@ -1192,27 +1055,9 @@ static VALUE oci8_set_client_info(VALUE self, VALUE val)
|
|
1192
1055
|
ptr = "";
|
1193
1056
|
size = 0;
|
1194
1057
|
}
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
size, OCI_ATTR_CLIENT_INFO, oci8_errhp),
|
1199
|
-
&svcctx->base);
|
1200
|
-
} else {
|
1201
|
-
/* Oracle 9i or lower */
|
1202
|
-
oci8_exec_sql_var_t bind_vars[1];
|
1203
|
-
|
1204
|
-
/* :client_info */
|
1205
|
-
bind_vars[0].valuep = (dvoid*)ptr;
|
1206
|
-
bind_vars[0].value_sz = size;
|
1207
|
-
bind_vars[0].dty = SQLT_CHR;
|
1208
|
-
bind_vars[0].indp = NULL;
|
1209
|
-
bind_vars[0].alenp = NULL;
|
1210
|
-
|
1211
|
-
oci8_exec_sql(svcctx,
|
1212
|
-
"BEGIN\n"
|
1213
|
-
" DBMS_APPLICATION_INFO.SET_CLIENT_INFO(:client_info);\n"
|
1214
|
-
"END;\n", 0, NULL, 1, bind_vars, 1);
|
1215
|
-
}
|
1058
|
+
chker2(OCIAttrSet(svcctx->usrhp, OCI_HTYPE_SESSION, (dvoid*)ptr,
|
1059
|
+
size, OCI_ATTR_CLIENT_INFO, oci8_errhp),
|
1060
|
+
&svcctx->base);
|
1216
1061
|
return val;
|
1217
1062
|
}
|
1218
1063
|
|
@@ -1251,7 +1096,7 @@ void Init_oci8(VALUE *out)
|
|
1251
1096
|
oracle_client_vernum = INT2FIX(ORAVERNUM(major, minor, update, patch, port_update));
|
1252
1097
|
}
|
1253
1098
|
|
1254
|
-
rb_define_const(cOCI8, "
|
1099
|
+
rb_define_const(cOCI8, "LIB_VERSION", rb_obj_freeze(rb_usascii_str_new_cstr(OCI8LIB_VERSION)));
|
1255
1100
|
rb_define_singleton_method_nodoc(cOCI8, "oracle_client_vernum", oci8_s_oracle_client_vernum, 0);
|
1256
1101
|
rb_define_singleton_method_nodoc(cOCI8, "__get_prop", oci8_s_get_prop, 1);
|
1257
1102
|
rb_define_singleton_method_nodoc(cOCI8, "__set_prop", oci8_s_set_prop, 2);
|
data/ext/oci8/oci8.h
CHANGED
@@ -2,21 +2,12 @@
|
|
2
2
|
/*
|
3
3
|
* oci8.h - part of ruby-oci8
|
4
4
|
*
|
5
|
-
* Copyright (C) 2002-
|
5
|
+
* Copyright (C) 2002-2015 Kubo Takehiro <kubo@jiubao.org>
|
6
6
|
*/
|
7
7
|
#ifndef _RUBY_OCI_H_
|
8
8
|
#define _RUBY_OCI_H_ 1
|
9
9
|
|
10
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
11
|
#include <stdio.h>
|
21
12
|
#include <stdlib.h>
|
22
13
|
#include <assert.h>
|
@@ -43,9 +34,7 @@ extern "C"
|
|
43
34
|
#define ORAVER_12_1 ORAVERNUM(12, 1, 0, 0, 0)
|
44
35
|
|
45
36
|
#include "extconf.h"
|
46
|
-
#ifdef HAVE_TYPE_RB_ENCODING
|
47
37
|
#include <ruby/encoding.h>
|
48
|
-
#endif
|
49
38
|
|
50
39
|
#ifndef OCI_TEMP_CLOB
|
51
40
|
#define OCI_TEMP_CLOB 1
|
@@ -101,75 +90,7 @@ typedef struct OCIMsg OCIMsg;
|
|
101
90
|
typedef struct OCICPool OCICPool;
|
102
91
|
#endif
|
103
92
|
|
104
|
-
|
105
|
-
* define compatible macros for ruby 1.8.5 or lower.
|
106
|
-
*/
|
107
|
-
#ifndef RSTRING_PTR
|
108
|
-
#define RSTRING_PTR(obj) RSTRING(obj)->ptr
|
109
|
-
#endif
|
110
|
-
#ifndef RSTRING_LEN
|
111
|
-
#define RSTRING_LEN(obj) RSTRING(obj)->len
|
112
|
-
#endif
|
113
|
-
#ifndef RARRAY_PTR
|
114
|
-
#define RARRAY_PTR(obj) RARRAY(obj)->ptr
|
115
|
-
#endif
|
116
|
-
#ifndef RARRAY_LEN
|
117
|
-
#define RARRAY_LEN(obj) RARRAY(obj)->len
|
118
|
-
#endif
|
119
|
-
|
120
|
-
#ifndef HAVE_RB_STR_SET_LEN
|
121
|
-
#define rb_str_set_len(s, l) do { \
|
122
|
-
RSTRING(s)->len = (l); \
|
123
|
-
RSTRING(s)->ptr[l] = '\0'; \
|
124
|
-
} while (0)
|
125
|
-
#endif
|
126
|
-
|
127
|
-
/* new macros in ruby 1.9.
|
128
|
-
* define compatible macros for ruby 1.8 or lower.
|
129
|
-
*/
|
130
|
-
#ifndef RFLOAT_VALUE
|
131
|
-
#define RFLOAT_VALUE(obj) RFLOAT(obj)->value
|
132
|
-
#endif
|
133
|
-
#ifndef STRINGIZE
|
134
|
-
#define STRINGIZE(name) #name
|
135
|
-
#endif
|
136
|
-
#ifndef RB_GC_GUARD
|
137
|
-
#ifdef __GNUC__
|
138
|
-
#define RB_GC_GUARD_PTR(ptr) \
|
139
|
-
__extension__ ({volatile VALUE *rb_gc_guarded_ptr = (ptr); rb_gc_guarded_ptr;})
|
140
|
-
#else
|
141
|
-
#ifdef _MSC_VER
|
142
|
-
#pragma optimize("", off)
|
143
|
-
#endif
|
144
|
-
static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;}
|
145
|
-
#ifdef _MSC_VER
|
146
|
-
#pragma optimize("", on)
|
147
|
-
#endif
|
148
|
-
#define RB_GC_GUARD_PTR(ptr) rb_gc_guarded_ptr(ptr)
|
149
|
-
#endif
|
150
|
-
#define RB_GC_GUARD(v) (*RB_GC_GUARD_PTR(&(v)))
|
151
|
-
#endif
|
152
|
-
|
153
|
-
/* new functions in ruby 1.9.
|
154
|
-
* define compatible macros for ruby 1.8 or lower.
|
155
|
-
*/
|
156
|
-
#if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO)
|
157
|
-
#define rb_errinfo() ruby_errinfo
|
158
|
-
#endif
|
159
|
-
|
160
|
-
#ifndef HAVE_TYPE_RB_ENCODING
|
161
|
-
/* ruby 1.8, rubinuis 1.2 */
|
162
|
-
#define rb_enc_associate(str, enc) do {} while(0)
|
163
|
-
#define rb_enc_str_new(str, len, enc) rb_str_new((str), (len))
|
164
|
-
#define rb_enc_str_buf_cat(str, ptr, len, enc) rb_str_buf_cat((str), (ptr), (len))
|
165
|
-
#define rb_external_str_new_with_enc(ptr, len, enc) rb_tainted_str_new((ptr), (len))
|
166
|
-
#define rb_locale_str_new_cstr(ptr) rb_str_new2(ptr)
|
167
|
-
#define rb_str_buf_cat_ascii(str, ptr) rb_str_buf_cat2((str), (ptr))
|
168
|
-
#define rb_str_conv_enc(str, from, to) (str)
|
169
|
-
#define rb_str_export_to_enc(str, enc) (str)
|
170
|
-
#define rb_usascii_str_new(ptr, len) rb_str_new((ptr), (len))
|
171
|
-
#define rb_usascii_str_new_cstr(ptr) rb_str_new2(ptr)
|
172
|
-
#elif defined RBX_CAPI_RUBY_H
|
93
|
+
#if defined RBX_CAPI_RUBY_H
|
173
94
|
/* rubinius 2.0 */
|
174
95
|
#ifndef HAVE_RB_ENC_STR_BUF_CAT
|
175
96
|
#define rb_enc_str_buf_cat(str, ptr, len, enc) \
|
@@ -179,6 +100,9 @@ static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr
|
|
179
100
|
#define rb_str_buf_cat_ascii(str, ptr) \
|
180
101
|
rb_str_concat((str), rb_usascii_str_new_cstr(ptr))
|
181
102
|
#endif
|
103
|
+
#ifndef STRINGIZE
|
104
|
+
#define STRINGIZE(name) #name
|
105
|
+
#endif
|
182
106
|
#endif
|
183
107
|
|
184
108
|
/*
|
@@ -247,18 +171,6 @@ struct oci8_data_type_struct {
|
|
247
171
|
#define RB_OBJ_WRITTEN(a, oldv, b) do {(void)oldv;} while (0)
|
248
172
|
#endif
|
249
173
|
|
250
|
-
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) || defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
251
|
-
#define NATIVE_THREAD_WITH_GVL 1
|
252
|
-
#endif
|
253
|
-
|
254
|
-
#if defined(HAVE_NATIVETHREAD) || NATIVE_THREAD_WITH_GVL
|
255
|
-
/*
|
256
|
-
* oci8_errhp is a thread local object in ruby 1.9, rubinius
|
257
|
-
* and ruby 1.8 configured with --enable-pthread.
|
258
|
-
*/
|
259
|
-
#define USE_THREAD_LOCAL_ERRHP 1
|
260
|
-
#endif
|
261
|
-
|
262
174
|
/* macros depends on the compiler.
|
263
175
|
* LIKELY(x) hint for the compiler that 'x' is 1(TRUE) in many cases.
|
264
176
|
* UNLIKELY(x) hint for the compiler that 'x' is 0(FALSE) in many cases.
|
@@ -291,8 +203,6 @@ struct oci8_data_type_struct {
|
|
291
203
|
* set a value to the key.
|
292
204
|
*
|
293
205
|
*/
|
294
|
-
#ifdef USE_THREAD_LOCAL_ERRHP
|
295
|
-
/* rubies with native-thread support. */
|
296
206
|
#if defined(_WIN32)
|
297
207
|
#include <windows.h>
|
298
208
|
#define oci8_tls_key_t DWORD
|
@@ -304,7 +214,6 @@ struct oci8_data_type_struct {
|
|
304
214
|
#define oci8_tls_get(key) pthread_getspecific(key)
|
305
215
|
#define oci8_tls_set(key, val) pthread_setspecific((key), (val))
|
306
216
|
#endif
|
307
|
-
#endif /* USE_THREAD_LOCAL_ERRHP */
|
308
217
|
|
309
218
|
/* utility macros
|
310
219
|
*/
|
@@ -439,9 +348,7 @@ typedef struct oci8_svcctx {
|
|
439
348
|
unsigned char state;
|
440
349
|
char is_autocommit;
|
441
350
|
char suppress_free_temp_lobs;
|
442
|
-
#ifdef NATIVE_THREAD_WITH_GVL
|
443
351
|
char non_blocking;
|
444
|
-
#endif
|
445
352
|
VALUE long_read_len;
|
446
353
|
oci8_temp_lob_t *temp_lobs;
|
447
354
|
} oci8_svcctx_t;
|
@@ -469,12 +376,6 @@ typedef struct {
|
|
469
376
|
#define chker2(status, base) oci8_check_error_((status), (base), NULL, __FILE__, __LINE__)
|
470
377
|
#define chker3(status, base, stmt) oci8_check_error_((status), (base), (stmt), __FILE__, __LINE__)
|
471
378
|
|
472
|
-
#if SIZEOF_LONG > 4
|
473
|
-
#define UB4_TO_NUM INT2FIX
|
474
|
-
#else
|
475
|
-
#define UB4_TO_NUM UINT2NUM
|
476
|
-
#endif
|
477
|
-
|
478
379
|
/* The folloiwng macros oci8_envhp and oci8_errhp are used
|
479
380
|
* as if they are defined as follows:
|
480
381
|
*
|
@@ -482,17 +383,12 @@ typedef struct {
|
|
482
383
|
* extern OCIError *oci8_errhp;
|
483
384
|
*/
|
484
385
|
#define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp())
|
485
|
-
#ifdef USE_THREAD_LOCAL_ERRHP
|
486
386
|
#define oci8_errhp oci8_get_errhp()
|
487
|
-
#else
|
488
|
-
#define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp())
|
489
|
-
#endif
|
490
387
|
|
491
388
|
/* env.c */
|
492
389
|
extern ub4 oci8_env_mode;
|
493
390
|
extern OCIEnv *oci8_global_envhp;
|
494
391
|
OCIEnv *oci8_make_envhp(void);
|
495
|
-
#ifdef USE_THREAD_LOCAL_ERRHP
|
496
392
|
extern oci8_tls_key_t oci8_tls_key; /* native thread key */
|
497
393
|
OCIError *oci8_make_errhp(void);
|
498
394
|
|
@@ -502,10 +398,6 @@ static inline OCIError *oci8_get_errhp()
|
|
502
398
|
return LIKELY(errhp != NULL) ? errhp : oci8_make_errhp();
|
503
399
|
}
|
504
400
|
|
505
|
-
#else
|
506
|
-
extern OCIError *oci8_global_errhp;
|
507
|
-
OCIError *oci8_make_errhp(void);
|
508
|
-
#endif
|
509
401
|
void Init_oci8_env(void);
|
510
402
|
|
511
403
|
/* oci8lib.c */
|
@@ -636,8 +528,12 @@ VALUE oci8_get_rowid_attr(oci8_base_t *base, ub4 attrtype, OCIStmt *stmtp);
|
|
636
528
|
|
637
529
|
/* encoding.c */
|
638
530
|
void Init_oci8_encoding(VALUE cOCI8);
|
639
|
-
VALUE oci8_charset_id2name(VALUE svc, VALUE charset_id);
|
640
531
|
extern int oci8_nls_ratio;
|
532
|
+
extern rb_encoding *oci8_encoding;
|
533
|
+
|
534
|
+
/* util.c */
|
535
|
+
void Init_oci8_util(VALUE cOCI8);
|
536
|
+
const char *oci8_dll_path(void);
|
641
537
|
|
642
538
|
/* win32.c */
|
643
539
|
void Init_oci8_win32(VALUE cOCI8);
|
@@ -646,9 +542,6 @@ void Init_oci8_win32(VALUE cOCI8);
|
|
646
542
|
void oci8_install_hook_functions(void);
|
647
543
|
void oci8_shutdown_sockets(void);
|
648
544
|
|
649
|
-
#ifdef HAVE_TYPE_RB_ENCODING
|
650
|
-
extern rb_encoding *oci8_encoding;
|
651
|
-
|
652
545
|
#define OCI8StringValue(v) do { \
|
653
546
|
StringValue(v); \
|
654
547
|
(v) = rb_str_export_to_enc(v, oci8_encoding); \
|
@@ -657,10 +550,6 @@ extern rb_encoding *oci8_encoding;
|
|
657
550
|
SafeStringValue(v); \
|
658
551
|
(v) = rb_str_export_to_enc(v, oci8_encoding); \
|
659
552
|
} while (0)
|
660
|
-
#else
|
661
|
-
#define OCI8StringValue(v) StringValue(v)
|
662
|
-
#define OCI8SafeStringValue(v) SafeStringValue(v)
|
663
|
-
#endif
|
664
553
|
|
665
554
|
#include "thread_util.h"
|
666
555
|
#include "apiwrap.h"
|