ruby-oci8 2.2.3 → 2.2.12
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.
- checksums.yaml +7 -0
- data/ChangeLog +427 -0
- data/NEWS +335 -42
- data/README.md +20 -9
- data/dist-files +9 -3
- data/docs/bind-array-to-in_cond.md +2 -2
- data/docs/conflicts-local-connections-and-processes.md +7 -4
- data/docs/hanging-after-inactivity.md +63 -0
- data/docs/install-binary-package.md +15 -11
- data/docs/install-full-client.md +18 -21
- data/docs/install-instant-client.md +45 -27
- data/docs/install-on-osx.md +31 -120
- data/docs/ldap-auth-and-function-interposition.md +123 -0
- data/docs/number-type-mapping.md +79 -0
- data/docs/platform-specific-issues.md +17 -50
- data/docs/report-installation-issue.md +3 -0
- data/docs/timeout-parameters.md +3 -0
- data/ext/oci8/apiwrap.c.tmpl +2 -5
- data/ext/oci8/apiwrap.rb +6 -1
- data/ext/oci8/apiwrap.yml +34 -22
- data/ext/oci8/attr.c +4 -2
- data/ext/oci8/bind.c +366 -6
- data/ext/oci8/connection_pool.c +3 -3
- data/ext/oci8/encoding.c +5 -5
- data/ext/oci8/env.c +8 -2
- data/ext/oci8/error.c +24 -16
- data/ext/oci8/extconf.rb +8 -4
- data/ext/oci8/hook_funcs.c +274 -61
- data/ext/oci8/lob.c +31 -75
- data/ext/oci8/metadata.c +2 -2
- data/ext/oci8/object.c +72 -27
- data/ext/oci8/oci8.c +45 -132
- data/ext/oci8/oci8.h +32 -88
- data/ext/oci8/oci8lib.c +178 -38
- data/ext/oci8/ocihandle.c +37 -37
- data/ext/oci8/ocinumber.c +23 -18
- data/ext/oci8/oraconf.rb +158 -339
- data/ext/oci8/oradate.c +19 -19
- data/ext/oci8/plthook.h +10 -0
- data/ext/oci8/plthook_elf.c +433 -268
- data/ext/oci8/plthook_osx.c +40 -9
- data/ext/oci8/plthook_win32.c +9 -0
- data/ext/oci8/stmt.c +52 -17
- data/ext/oci8/win32.c +4 -22
- data/lib/oci8/bindtype.rb +1 -15
- data/lib/oci8/check_load_error.rb +57 -10
- data/lib/oci8/cursor.rb +57 -25
- data/lib/oci8/metadata.rb +9 -1
- data/lib/oci8/object.rb +10 -0
- data/lib/oci8/oci8.rb +33 -28
- data/lib/oci8/oracle_version.rb +11 -1
- data/lib/oci8/properties.rb +22 -0
- data/lib/oci8/version.rb +1 -1
- data/lib/oci8.rb +48 -4
- data/lib/ruby-oci8.rb +0 -3
- data/pre-distclean.rb +1 -3
- data/ruby-oci8.gemspec +3 -8
- data/setup.rb +11 -2
- data/test/README.md +37 -0
- data/test/config.rb +1 -1
- data/test/setup_test_object.sql +21 -13
- data/test/setup_test_package.sql +59 -0
- data/test/test_all.rb +2 -0
- data/test/test_bind_boolean.rb +99 -0
- data/test/test_bind_integer.rb +47 -0
- data/test/test_break.rb +11 -9
- data/test/test_clob.rb +4 -16
- data/test/test_connstr.rb +29 -13
- data/test/test_datetime.rb +8 -3
- data/test/test_object.rb +27 -9
- data/test/test_oci8.rb +170 -46
- data/test/test_oranumber.rb +12 -6
- data/test/test_package_type.rb +15 -3
- data/test/test_properties.rb +17 -0
- metadata +40 -54
- data/docs/osx-install-dev-tools.png +0 -0
- data/test/README +0 -42
@@ -0,0 +1,79 @@
|
|
1
|
+
# @title Number Type Mapping between Oracle and Ruby
|
2
|
+
|
3
|
+
Number Type Mapping between Oracle and Ruby
|
4
|
+
===========================================
|
5
|
+
|
6
|
+
Default mapping
|
7
|
+
---------------
|
8
|
+
|
9
|
+
Oracle numbers in select statements are fetched as followings by default:
|
10
|
+
|
11
|
+
| Oracle Data Type | Ruby Class |
|
12
|
+
|---|---|
|
13
|
+
| NUMBER(prec) or NUMBER(prec, 0) | Integer |
|
14
|
+
| NUMBER(prec, scale) where prec < 15 and scale != 0 | Float |
|
15
|
+
| NUMBER(prec, scale) where prec >= 15 and scale != 0 | BigDecimal |
|
16
|
+
| FLOAT or FLOAT(prec) | Float |
|
17
|
+
| NUMBER without precision and scale | BigDecimal |
|
18
|
+
| number type returned by functions or calculated number | BigDecimal |
|
19
|
+
| BINARY_FLOAT | Float |
|
20
|
+
| BINARY_DOUBLE | Float |
|
21
|
+
|
22
|
+
When the data type is within Integer or Float class, it is fetched
|
23
|
+
as Integer or Float. Otherwise, BigDecimal.
|
24
|
+
|
25
|
+
Note that the mapping is determined by the column definition in
|
26
|
+
select statements, not by the actual value fetched.
|
27
|
+
For example the column in `select count(*) from table_name` is
|
28
|
+
fetched as BigDecimal because it is returned from `count` function.
|
29
|
+
|
30
|
+
The mapping is customizable by `OCI8::BindType::Mapping`.
|
31
|
+
The default values of Oracle number data type mapping are:
|
32
|
+
|
33
|
+
# NUMBER or FLOAT data type, used for the first six rows in the above table
|
34
|
+
OCI8::BindType::Mapping[:number] = OCI8::BindType::Number
|
35
|
+
# BINARY_FLOAT data type, used for the seventh row in the above table
|
36
|
+
OCI8::BindType::Mapping[:binary_float] = OCI8::BindType::BinaryDouble
|
37
|
+
# BINARY_DOUBLE data type, used for the eighth row in the above table
|
38
|
+
OCI8::BindType::Mapping[:binary_double] = OCI8::BindType::BinaryDouble
|
39
|
+
|
40
|
+
`OCI8::BindType::Number` checks precision and scale to determine
|
41
|
+
ruby class. The first four rows in the above table are hard-coded.
|
42
|
+
The fifth and sixth rows are, however, customizable by
|
43
|
+
`OCI8::BindType::Mapping[:number_no_prec_setting]` and
|
44
|
+
`OCI8::BindType::Mapping[:number_unknown_prec]` respectively.
|
45
|
+
|
46
|
+
The default values are:
|
47
|
+
|
48
|
+
OCI8::BindType::Mapping[:number_no_prec_setting] = OCI8::BindType::BigDecimal
|
49
|
+
OCI8::BindType::Mapping[:number_unknown_prec] = OCI8::BindType::BigDecimal
|
50
|
+
|
51
|
+
The mapping may be changed as follows in future.
|
52
|
+
|
53
|
+
| Oracle Data Type | Ruby Class |
|
54
|
+
|---|---|
|
55
|
+
| NUMBER(prec) or NUMBER(prec, 0) | Integer |
|
56
|
+
| other NUMBER | OraNumber |
|
57
|
+
| BINARY_FLOAT | Float |
|
58
|
+
| BINARY_DOUBLE | Float |
|
59
|
+
|
60
|
+
Customize mapping
|
61
|
+
-----------------
|
62
|
+
|
63
|
+
Add the following code to fetch all number or float columns as {OraNumber}.
|
64
|
+
|
65
|
+
OCI8::BindType::Mapping[:number] = OCI8::BindType::OraNumber
|
66
|
+
|
67
|
+
Otherwise, add the following code to customize the fifth and sixth rows only
|
68
|
+
in the above table.
|
69
|
+
|
70
|
+
OCI8::BindType::Mapping[:number_no_prec_setting] = OCI8::BindType::OraNumber
|
71
|
+
OCI8::BindType::Mapping[:number_unknown_prec] = OCI8::BindType::OraNumber
|
72
|
+
|
73
|
+
If you want to fetch numbers as Integer or Float by its actual value, use
|
74
|
+
the following code:
|
75
|
+
|
76
|
+
# Fetch numbers as Integer when their fractional part is zero.
|
77
|
+
# Otherwise, Float. For example when a column contains 10 and
|
78
|
+
# 10.1, they are fetched as Integer and Float respectively.
|
79
|
+
OCI8::BindType::Mapping[:number] = OCI8::BindType::BasicNumberType
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# @title Platform Specific Issues
|
2
2
|
|
3
|
+
Platform Specific Issues
|
4
|
+
========================
|
5
|
+
|
3
6
|
Linux
|
4
|
-
|
7
|
+
-----
|
5
8
|
|
6
|
-
Ubuntu 11.10 (Oneiric Ocelot)
|
7
|
-
-----------------------------
|
9
|
+
### Ubuntu 11.10 (Oneiric Ocelot)
|
8
10
|
|
9
11
|
If the following error occurs even though libc6-dev is installed,
|
10
12
|
|
@@ -15,8 +17,7 @@ You need to use ruby-oci8 2.1.0 or upper. Otherwise, run the following command a
|
|
15
17
|
|
16
18
|
$ sudo ln -s /usr/include/linux/ /usr/include/sys
|
17
19
|
|
18
|
-
General Linux
|
19
|
-
-------------
|
20
|
+
### General Linux
|
20
21
|
|
21
22
|
Use the same bit-width of libraries with ruby. For example, x86\_64
|
22
23
|
instant client for x86\_64 ruby and 32-bit instant client for 32-bit
|
@@ -32,21 +33,18 @@ To check which type of ruby do you use:
|
|
32
33
|
Note: "`" is a back quote.
|
33
34
|
|
34
35
|
Mac OS X
|
35
|
-
|
36
|
+
--------
|
36
37
|
|
37
|
-
OS X 10.7+
|
38
|
-
----------
|
38
|
+
### OS X 10.7+
|
39
39
|
|
40
40
|
Use the latest 64-bit instant client. The older 64-bit (10.2.0.4) instant client [doesn't work](https://forums.oracle.com/forums/thread.jspa?threadID=2187558). The older 32-bit instant client will work but only with 32-bit ruby or jruby (using JDBC).
|
41
41
|
|
42
|
-
Intel Mac (64-bit)
|
43
|
-
------------------
|
42
|
+
### Intel Mac (64-bit)
|
44
43
|
|
45
44
|
See [How to setup Ruby and Oracle Instant Client on Snow Leopard](http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/).
|
46
45
|
Note that setting the environment variable RC\_ARCHS=x86\_64 instead of ARCHFLAGS="-arch x86\_64" will work fine also.
|
47
46
|
|
48
|
-
Intel Mac (32-bit)
|
49
|
-
------------------
|
47
|
+
### Intel Mac (32-bit)
|
50
48
|
|
51
49
|
See [How to setup Ruby and Oracle Instant Client on Snow Leopard](http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/). Note that you need to replace x86\_64 with i386 in the blog.
|
52
50
|
|
@@ -57,13 +55,12 @@ use one of the following workarounds.
|
|
57
55
|
* use [ruby-odbc](http://www.ch-werner.de/rubyodbc/) and a third party ODBC driver ([Actual Technologies](http://www.actualtechnologies.com) or [OpenLink Software](http://uda.openlinksw.com/)).
|
58
56
|
* use JRuby and Oracle JDBC driver.
|
59
57
|
|
60
|
-
PowerPC Mac
|
61
|
-
-----------
|
58
|
+
### PowerPC Mac
|
62
59
|
|
63
60
|
See [How to setup Ruby and Oracle Instant Client on Snow Leopard](http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/). Note that you need to replace x86\_64 with ppc in the blog.
|
64
61
|
|
65
62
|
Solaris
|
66
|
-
|
63
|
+
-------
|
67
64
|
|
68
65
|
You need a same compiler which is used to make ruby itself.
|
69
66
|
For example, if the ruby is compiled by gcc, you need gcc. If it is compiled by Oracle Solaris Studio
|
@@ -83,15 +80,10 @@ as follows:
|
|
83
80
|
to: CONFIG["LDFLAGS"] = "-L. "
|
84
81
|
|
85
82
|
FreeBSD
|
86
|
-
|
87
|
-
|
88
|
-
There are two ways.
|
83
|
+
-------
|
89
84
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
linux emulator
|
94
|
-
--------------
|
85
|
+
Oracle8-client port isn't available because it is too old.
|
86
|
+
You need to use linux emulator.
|
95
87
|
|
96
88
|
I have not run ruby-oci8 on linux emulator, but I guess it will
|
97
89
|
run as follows. If it works, please tell me.
|
@@ -129,33 +121,8 @@ On freebsd:
|
|
129
121
|
cd /compat/linux/usr/local
|
130
122
|
tar xvfz ruby-1.8.x-linux.tar.gz
|
131
123
|
|
132
|
-
oracle8-client port
|
133
|
-
-------------------
|
134
|
-
|
135
|
-
I don't recommend this because of the following two reasons.
|
136
|
-
|
137
|
-
* The oracle8-client port is made from Oracle 8.1.7.1 static library for Linux. Oracle have not supported the connectivity between 8.1.7.1 and Oracle 10g.
|
138
|
-
* It is very unstable. When it fails to connect to an Oracle server, it is down by segmentation fault on FreeBSD 7.0 not only when using ruby-oci8, but also by a very simple test code written by C.
|
139
|
-
|
140
|
-
If you try to use oracle8-client port, compile and install as follows.
|
141
|
-
|
142
|
-
* install oracle8-client
|
143
|
-
|
144
|
-
cd /usr/ports/databases/oracle8-client
|
145
|
-
make
|
146
|
-
make install
|
147
|
-
|
148
|
-
* set an environment variable ORACLE\_HOME
|
149
|
-
|
150
|
-
export ORACLE_HOME=/usr/local/oracle8-client
|
151
|
-
|
152
|
-
The rest steps are described at {file:docs/install-full-client.md}.
|
153
|
-
|
154
|
-
note: You have no need to set LD\_LIBRARY\_PATH because
|
155
|
-
Oracle libraries in oracle8-client port are static ones.
|
156
|
-
|
157
124
|
HP-UX
|
158
|
-
|
125
|
+
-----
|
159
126
|
|
160
127
|
You need a ruby which is linked with ''libpthread'' and ''libcl''.
|
161
128
|
|
@@ -174,7 +141,7 @@ and `make install`.
|
|
174
141
|
The rest steps are described at {file:docs/install-full-client.md}.
|
175
142
|
|
176
143
|
Windows
|
177
|
-
|
144
|
+
-------
|
178
145
|
|
179
146
|
On some machines using a slow disk, you may get the following error.
|
180
147
|
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# @title Report Installation Issues
|
2
2
|
|
3
|
+
Report Installation Issues
|
4
|
+
==========================
|
5
|
+
|
3
6
|
Look at {file:docs/platform-specific-issues.md} and [the issues page on github][github] to check whether your issue is fixed or not.
|
4
7
|
|
5
8
|
If it is a new one, post the following information to [github][].
|
data/docs/timeout-parameters.md
CHANGED
@@ -30,6 +30,9 @@ The next two parameters `send_timeout` and `recv_timeout` are available on Oracl
|
|
30
30
|
or upper. Use these parameters to prevent a ruby process from being blocked by poor quality network.
|
31
31
|
Otherwise, the ruby process may be blocked until TCP keepalive time (2 hours).
|
32
32
|
|
33
|
+
See {file:docs/hanging-after-inactivity.md Hanging After a Long Period of Inactivity}
|
34
|
+
for TCP keepalive time.
|
35
|
+
|
33
36
|
tcp_connect_timeout
|
34
37
|
-------------------
|
35
38
|
|
data/ext/oci8/apiwrap.c.tmpl
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
%>
|
5
5
|
#define API_WRAP_C 1
|
6
6
|
#include "apiwrap.h"
|
7
|
-
#define BLOCKING_FUNCTION_EPILOGUE(svcctx) do { (svcctx)->executing_thread = Qnil; } while (0)
|
8
7
|
|
9
8
|
<%
|
10
9
|
prev_name = ''
|
@@ -59,11 +58,9 @@ static void *oci8_<%=f.name%>_cb(void *user_data)
|
|
59
58
|
%> data->rv = <%=f.name%>(<%= f.args.collect do |a| 'data->' + a.name; end.join(', ') %>);
|
60
59
|
<% end %>
|
61
60
|
<% if f.ret == 'sword'
|
62
|
-
%>
|
63
|
-
return (void*)(VALUE)data->rv;
|
61
|
+
%> return (void*)(VALUE)data->rv;
|
64
62
|
<% else
|
65
|
-
%>
|
66
|
-
return NULL;
|
63
|
+
%> return NULL;
|
67
64
|
<% end %>
|
68
65
|
}
|
69
66
|
#else
|
data/ext/oci8/apiwrap.rb
CHANGED
@@ -35,7 +35,11 @@ class FuncDef
|
|
35
35
|
ver_major = (ver / 100)
|
36
36
|
ver_minor = (ver / 10) % 10
|
37
37
|
ver_update = ver % 10
|
38
|
-
@version =
|
38
|
+
@version = if ver_major >= 18
|
39
|
+
((ver_major << 24) | (ver_minor << 16) | (ver_update << 12))
|
40
|
+
else
|
41
|
+
((ver_major << 24) | (ver_minor << 20) | (ver_update << 12))
|
42
|
+
end
|
39
43
|
case @version
|
40
44
|
when 0x08000000; @version_num = 'ORAVER_8_0'
|
41
45
|
when 0x08100000; @version_num = 'ORAVER_8_1'
|
@@ -44,6 +48,7 @@ class FuncDef
|
|
44
48
|
when 0x0a100000; @version_num = 'ORAVER_10_1'
|
45
49
|
when 0x0a200000; @version_num = 'ORAVER_10_2'
|
46
50
|
when 0x0b100000; @version_num = 'ORAVER_11_1'
|
51
|
+
when 0x12000000; @version_num = 'ORAVER_18'
|
47
52
|
end
|
48
53
|
@version_str = "#{ver_major}.#{ver_minor}.#{ver_update}"
|
49
54
|
@ret = val[:ret] || 'sword'
|
data/ext/oci8/apiwrap.yml
CHANGED
@@ -83,6 +83,17 @@ OCIBindByPos:
|
|
83
83
|
- ub4 *curelep
|
84
84
|
- ub4 mode
|
85
85
|
|
86
|
+
# round trip: 0
|
87
|
+
OCIBindDynamic:
|
88
|
+
:version: 800
|
89
|
+
:args:
|
90
|
+
- OCIBind *bindp
|
91
|
+
- OCIError *errhp
|
92
|
+
- void *ictxp
|
93
|
+
- OCICallbackInBind icbfp
|
94
|
+
- void *octxp
|
95
|
+
- OCICallbackOutBind ocbfp
|
96
|
+
|
86
97
|
# round trip: 0
|
87
98
|
OCIBindObject:
|
88
99
|
:version: 800
|
@@ -180,6 +191,15 @@ OCIDefineByPos:
|
|
180
191
|
- ub2 *rcodep
|
181
192
|
- ub4 mode
|
182
193
|
|
194
|
+
# round trip: 0
|
195
|
+
OCIDefineDynamic:
|
196
|
+
:version: 800
|
197
|
+
:args:
|
198
|
+
- OCIDefine *defnp
|
199
|
+
- OCIError *errhp
|
200
|
+
- dvoid *octxp
|
201
|
+
- OCICallbackDefine ocbfp
|
202
|
+
|
183
203
|
# round trip: 0
|
184
204
|
OCIDefineObject:
|
185
205
|
:version: 800
|
@@ -321,13 +341,6 @@ OCILobLocatorIsInit:
|
|
321
341
|
- CONST OCILobLocator *locp
|
322
342
|
- boolean *is_initialized
|
323
343
|
|
324
|
-
# round trip: 1
|
325
|
-
OCILogoff:
|
326
|
-
:version: 800
|
327
|
-
:args:
|
328
|
-
- OCISvcCtx *svchp
|
329
|
-
- OCIError *errhp
|
330
|
-
|
331
344
|
# round trip: 0
|
332
345
|
OCINumberAbs:
|
333
346
|
:version: 800
|
@@ -1149,21 +1162,6 @@ OCIIntervalSetYearMonth:
|
|
1149
1162
|
- sb4 mnth
|
1150
1163
|
- OCIInterval *result
|
1151
1164
|
|
1152
|
-
# round trip: 1
|
1153
|
-
OCILogon2_nb:
|
1154
|
-
:version: 900
|
1155
|
-
:args:
|
1156
|
-
- OCIEnv *envhp
|
1157
|
-
- OCIError *errhp
|
1158
|
-
- OCISvcCtx **svchp
|
1159
|
-
- CONST text *username
|
1160
|
-
- ub4 uname_len
|
1161
|
-
- CONST text *password
|
1162
|
-
- ub4 passwd_len
|
1163
|
-
- CONST text *dbname
|
1164
|
-
- ub4 dbname_len
|
1165
|
-
- ub4 mode
|
1166
|
-
|
1167
1165
|
# round trip: 0 (not docmented. I guess.)
|
1168
1166
|
OCIRowidToChar:
|
1169
1167
|
:version: 900
|
@@ -1308,3 +1306,17 @@ OCIPing_nb:
|
|
1308
1306
|
- OCISvcCtx *svchp
|
1309
1307
|
- OCIError *errhp
|
1310
1308
|
- ub4 mode
|
1309
|
+
|
1310
|
+
#
|
1311
|
+
# Oracle 18.1
|
1312
|
+
#
|
1313
|
+
OCIServerRelease2:
|
1314
|
+
:version: 1800
|
1315
|
+
:args:
|
1316
|
+
- dvoid *hndlp
|
1317
|
+
- OCIError *errhp
|
1318
|
+
- OraText *bufp
|
1319
|
+
- ub4 bufsz
|
1320
|
+
- ub1 hndltype
|
1321
|
+
- ub4 *version
|
1322
|
+
- ub4 mode
|
data/ext/oci8/attr.c
CHANGED
@@ -15,8 +15,9 @@ typedef struct {
|
|
15
15
|
OCIRowid *ridp;
|
16
16
|
} rowid_arg_t;
|
17
17
|
|
18
|
-
static VALUE get_rowid_attr(
|
18
|
+
static VALUE get_rowid_attr(VALUE varg)
|
19
19
|
{
|
20
|
+
rowid_arg_t *arg = (rowid_arg_t *)varg;
|
20
21
|
oci8_base_t *base = arg->base;
|
21
22
|
ub4 attrtype = arg->attrtype;
|
22
23
|
char buf[MAX_ROWID_LEN];
|
@@ -36,8 +37,9 @@ static VALUE get_rowid_attr(rowid_arg_t *arg)
|
|
36
37
|
return rb_external_str_new_with_enc(buf, buflen, rb_usascii_encoding());
|
37
38
|
}
|
38
39
|
|
39
|
-
static VALUE rowid_ensure(
|
40
|
+
static VALUE rowid_ensure(VALUE varg)
|
40
41
|
{
|
42
|
+
rowid_arg_t *arg = (rowid_arg_t *)varg;
|
41
43
|
if (arg->ridp != NULL) {
|
42
44
|
OCIDescriptorFree(arg->ridp, OCI_DTYPE_ROWID);
|
43
45
|
}
|