ruby-staci 2.2.9
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/.yardopts +14 -0
- data/COPYING +30 -0
- data/COPYING_old +64 -0
- data/ChangeLog +3826 -0
- data/Makefile +92 -0
- data/NEWS +1194 -0
- data/README.md +66 -0
- data/dist-files +113 -0
- data/docs/bind-array-to-in_cond.md +38 -0
- data/docs/conflicts-local-connections-and-processes.md +98 -0
- data/docs/hanging-after-inactivity.md +63 -0
- data/docs/install-binary-package.md +44 -0
- data/docs/install-full-client.md +111 -0
- data/docs/install-instant-client.md +194 -0
- data/docs/install-on-osx.md +133 -0
- data/docs/ldap-auth-and-function-interposition.md +123 -0
- data/docs/number-type-mapping.md +79 -0
- data/docs/osx-install-dev-tools.png +0 -0
- data/docs/platform-specific-issues.md +164 -0
- data/docs/report-installation-issue.md +50 -0
- data/docs/timeout-parameters.md +94 -0
- data/ext/oci8/.document +18 -0
- data/ext/oci8/MANIFEST +18 -0
- data/ext/oci8/apiwrap.c.tmpl +178 -0
- data/ext/oci8/apiwrap.h.tmpl +61 -0
- data/ext/oci8/apiwrap.rb +96 -0
- data/ext/oci8/apiwrap.yml +1322 -0
- data/ext/oci8/attr.c +57 -0
- data/ext/oci8/bind.c +838 -0
- data/ext/oci8/connection_pool.c +216 -0
- data/ext/oci8/encoding.c +196 -0
- data/ext/oci8/env.c +139 -0
- data/ext/oci8/error.c +385 -0
- data/ext/oci8/extconf.rb +219 -0
- data/ext/oci8/hook_funcs.c +407 -0
- data/ext/oci8/lob.c +1278 -0
- data/ext/oci8/metadata.c +279 -0
- data/ext/oci8/object.c +919 -0
- data/ext/oci8/oci8.c +1058 -0
- data/ext/oci8/oci8.h +556 -0
- data/ext/oci8/oci8lib.c +704 -0
- data/ext/oci8/ocidatetime.c +506 -0
- data/ext/oci8/ocihandle.c +852 -0
- data/ext/oci8/ocinumber.c +1922 -0
- data/ext/oci8/oraconf.rb +1145 -0
- data/ext/oci8/oradate.c +670 -0
- data/ext/oci8/oranumber_util.c +352 -0
- data/ext/oci8/oranumber_util.h +24 -0
- data/ext/oci8/plthook.h +66 -0
- data/ext/oci8/plthook_elf.c +702 -0
- data/ext/oci8/plthook_osx.c +505 -0
- data/ext/oci8/plthook_win32.c +391 -0
- data/ext/oci8/post-config.rb +5 -0
- data/ext/oci8/stmt.c +448 -0
- data/ext/oci8/thread_util.c +81 -0
- data/ext/oci8/thread_util.h +18 -0
- data/ext/oci8/util.c +71 -0
- data/ext/oci8/win32.c +117 -0
- data/lib/.document +1 -0
- data/lib/dbd/STACI.rb +591 -0
- data/lib/oci8/.document +8 -0
- data/lib/oci8/bindtype.rb +333 -0
- data/lib/oci8/check_load_error.rb +146 -0
- data/lib/oci8/compat.rb +117 -0
- data/lib/oci8/connection_pool.rb +179 -0
- data/lib/oci8/cursor.rb +605 -0
- data/lib/oci8/datetime.rb +605 -0
- data/lib/oci8/encoding-init.rb +45 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2148 -0
- data/lib/oci8/object.rb +641 -0
- data/lib/oci8/oci8.rb +756 -0
- data/lib/oci8/ocihandle.rb +591 -0
- data/lib/oci8/oracle_version.rb +153 -0
- data/lib/oci8/properties.rb +196 -0
- data/lib/oci8/version.rb +3 -0
- data/lib/ruby-staci.rb +1 -0
- data/lib/staci.rb +190 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-aci.gemspec +83 -0
- data/setup.rb +1342 -0
- data/test/README.md +37 -0
- data/test/config.rb +201 -0
- data/test/setup_test_object.sql +199 -0
- data/test/setup_test_package.sql +59 -0
- data/test/test_all.rb +56 -0
- data/test/test_appinfo.rb +62 -0
- data/test/test_array_dml.rb +333 -0
- data/test/test_bind_array.rb +70 -0
- data/test/test_bind_boolean.rb +99 -0
- data/test/test_bind_integer.rb +47 -0
- data/test/test_bind_raw.rb +45 -0
- data/test/test_bind_string.rb +105 -0
- data/test/test_bind_time.rb +177 -0
- data/test/test_break.rb +124 -0
- data/test/test_clob.rb +86 -0
- data/test/test_connection_pool.rb +124 -0
- data/test/test_connstr.rb +220 -0
- data/test/test_datetime.rb +585 -0
- data/test/test_dbi.rb +365 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +103 -0
- data/test/test_error.rb +87 -0
- data/test/test_metadata.rb +2674 -0
- data/test/test_object.rb +546 -0
- data/test/test_oci8.rb +624 -0
- data/test/test_oracle_version.rb +68 -0
- data/test/test_oradate.rb +255 -0
- data/test/test_oranumber.rb +786 -0
- data/test/test_package_type.rb +981 -0
- data/test/test_properties.rb +17 -0
- data/test/test_rowid.rb +32 -0
- metadata +158 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
# @title Report Installation Issues
|
2
|
+
|
3
|
+
Report Installation Issues
|
4
|
+
==========================
|
5
|
+
|
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.
|
7
|
+
|
8
|
+
If it is a new one, post the following information to [github][].
|
9
|
+
|
10
|
+
[github]: https://github.com/kubo/ruby-oci8/issues
|
11
|
+
|
12
|
+
* Messages printed out to the console
|
13
|
+
|
14
|
+
* `gem_make.out` if you install a gem
|
15
|
+
|
16
|
+
* Last 100 lines of 'ext/oci8/mkmf.log'
|
17
|
+
|
18
|
+
Get them as follows.
|
19
|
+
|
20
|
+
tail -100 ext/oci8/mkmf.log
|
21
|
+
|
22
|
+
* The results of the following commands:
|
23
|
+
|
24
|
+
file `which ruby`
|
25
|
+
ruby --version
|
26
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['host']"
|
27
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['CC']"
|
28
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['CFLAGS']"
|
29
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['LDSHARED']"
|
30
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['LDFLAGS']"
|
31
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['DLDLAGS']"
|
32
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['LIBS']"
|
33
|
+
ruby -r rbconfig -e "p RbConfig::CONFIG['GNU_LD']"
|
34
|
+
|
35
|
+
# if you use gcc,
|
36
|
+
gcc --print-prog-name=ld
|
37
|
+
gcc --print-prog-name=as
|
38
|
+
|
39
|
+
# Oracle full client
|
40
|
+
file $ORACLE_HOME/bin/oracle
|
41
|
+
|
42
|
+
# Oracle Instant client. You need to change INSTANT_CLIENT_DIRECTORY.
|
43
|
+
file INSTANT_CLIENT_DIRECTORY/libclntsh.*
|
44
|
+
|
45
|
+
echo $LD_LIBRARY_PATH
|
46
|
+
echo $LIBPATH # AIX
|
47
|
+
echo $SHLIB_PATH # HP-UX PA-RISC 32-bit ruby
|
48
|
+
echo $DYLD_LIBRARY_PATH # Mac OS X
|
49
|
+
echo $LD_LIBRARY_PATH_32 # Solaris 32-bit ruby
|
50
|
+
echo $LD_LIBRARY_PATH_64 # Solaris 64-bit ruby
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# @title Timeout Parameters
|
2
|
+
|
3
|
+
Timeout Parameters
|
4
|
+
==================
|
5
|
+
|
6
|
+
The following timeout parameters are available since ruby-oci8 2.2.2.
|
7
|
+
|
8
|
+
* tcp_connect_timeout
|
9
|
+
* connect_timeout
|
10
|
+
* send_timeout
|
11
|
+
* recv_timeout
|
12
|
+
|
13
|
+
For example:
|
14
|
+
|
15
|
+
OCI8.properties[:tcp_connect_timeout] = 10
|
16
|
+
OCI8.properties[:connect_timeout] = 15
|
17
|
+
OCI8.properties[:send_timeout] = 60
|
18
|
+
OCI8.properties[:recv_timeout] = 60
|
19
|
+
|
20
|
+
These parameters are applied only to TCP/IP connections.
|
21
|
+
|
22
|
+
The first two parameters `tcp_connect_timeout` and `connect_timeout`
|
23
|
+
are applied only to [connect descriptors][connect descriptor] using [Easy Connect Naming Method][EZCONNECT].
|
24
|
+
If you use a net service name, you should set [TRANSPORT_CONNECT_TIMEOUT][] and/or
|
25
|
+
[CONNECT_TIMEOUT][] in the address descriptor in `tnsnames.ora` instead of these parameters.
|
26
|
+
If you use easy connect naming method without any of `port`, `service_name`, `server` and `instance_name`,
|
27
|
+
you need to use `//host` to distinguish it from a net service name.
|
28
|
+
|
29
|
+
The next two parameters `send_timeout` and `recv_timeout` are available on Oracle 11g client
|
30
|
+
or upper. Use these parameters to prevent a ruby process from being blocked by poor quality network.
|
31
|
+
Otherwise, the ruby process may be blocked until TCP keepalive time (2 hours).
|
32
|
+
|
33
|
+
See {file:docs/hanging-after-inactivity.md Hanging After a Long Period of Inactivity}
|
34
|
+
for TCP keepalive time.
|
35
|
+
|
36
|
+
tcp_connect_timeout
|
37
|
+
-------------------
|
38
|
+
|
39
|
+
`tcp_connect_timeout` is equivalent to [TCP.CONNECT_TIMEOUT][] in the client-side `sqlnet.ora` and
|
40
|
+
[TRANSPORT_CONNECT_TIMEOUT][] in the address descriptor.
|
41
|
+
See description about [TCP.CONNECT_TIMEOUT][] and [TRANSPORT_CONNECT_TIMEOUT][].
|
42
|
+
|
43
|
+
connect_timeout
|
44
|
+
---------------
|
45
|
+
|
46
|
+
`connect_timeout` is equivalent to [SQLNET.OUTBOUND_CONNECT_TIMEOUT][] in the client-side `sqlnet.ora`
|
47
|
+
and [CONNECT_TIMEOUT][] in the address description.
|
48
|
+
See description about [SQLNET.OUTBOUND_CONNECT_TIMEOUT][] and [CONNECT_TIMEOUT][].
|
49
|
+
|
50
|
+
Note: this parameter isn't equivalent to login timeout. It needs the following three
|
51
|
+
steps to establish a database connection.
|
52
|
+
|
53
|
+
1. Establish a TCP/IP connection.
|
54
|
+
2. Establish an [Oracle Net][] connection on the TCP/IP connection.
|
55
|
+
3. Authenticate and authorize the database user.
|
56
|
+
|
57
|
+
`tcp_connect_timeout` sets the timeout of the first step.
|
58
|
+
`connect_timeout` sets the total timeout of the first and the second steps.
|
59
|
+
There is no timeout parameter to limit the maximum time of all three steps.
|
60
|
+
|
61
|
+
Use `send_timeout` and `recv_timeout` in case that a TCP/IP connection stalls
|
62
|
+
in the third step.
|
63
|
+
|
64
|
+
send_timeout
|
65
|
+
------------
|
66
|
+
|
67
|
+
`send_timeout` is equivalent to [SQLNET.SEND_TIMEOUT][] in the client-side `sqlnet.ora`.
|
68
|
+
See description about [SQLNET.SEND_TIMEOUT][].
|
69
|
+
|
70
|
+
Note that the connection becomes unusable on timeout.
|
71
|
+
|
72
|
+
See also {OCI8#send_timeout=}.
|
73
|
+
|
74
|
+
recv_timeout
|
75
|
+
------------
|
76
|
+
|
77
|
+
`recv_timeout` is equivalent to [SQLNET.RECV_TIMEOUT][] in the client-side `sqlnet.ora`.
|
78
|
+
See description about [SQLNET.RECV_TIMEOUT][].
|
79
|
+
|
80
|
+
Note that the connection becomes unusable on timeout.
|
81
|
+
|
82
|
+
See also {OCI8#recv_timeout=}.
|
83
|
+
|
84
|
+
Note: This parameter must be larger than the longest SQL execution time in your applications.
|
85
|
+
|
86
|
+
[TCP.CONNECT_TIMEOUT]: http://docs.oracle.com/database/121/NETRF/sqlnet.htm#BIIDDACA
|
87
|
+
[SQLNET.OUTBOUND_CONNECT_TIMEOUT]: https://docs.oracle.com/database/121/NETRF/sqlnet.htm#NETRF427
|
88
|
+
[SQLNET.SEND_TIMEOUT]: http://docs.oracle.com/database/121/NETRF/sqlnet.htm#NETRF228
|
89
|
+
[SQLNET.RECV_TIMEOUT]: http://docs.oracle.com/database/121/NETRF/sqlnet.htm#NETRF227
|
90
|
+
[connect descriptor]: https://docs.oracle.com/database/121/NETRF/glossary.htm#BGBEDFBF
|
91
|
+
[EZCONNECT]: https://docs.oracle.com/database/121/NETAG/naming.htm#NETAG255
|
92
|
+
[CONNECT_TIMEOUT]: https://docs.oracle.com/database/121/NETRF/tnsnames.htm#NETRF666
|
93
|
+
[TRANSPORT_CONNECT_TIMEOUT]: https://docs.oracle.com/database/121/NETRF/tnsnames.htm#NETRF1982
|
94
|
+
[Oracle Net]: https://en.wikipedia.org/wiki/Oracle_Net_Services#Oracle_Net
|
data/ext/oci8/.document
ADDED
data/ext/oci8/MANIFEST
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
<%= header_comment
|
3
|
+
# This file is processed by apiwrap.rb.
|
4
|
+
%>
|
5
|
+
#define API_WRAP_C 1
|
6
|
+
#include "apiwrap.h"
|
7
|
+
#define BLOCKING_FUNCTION_EPILOGUE(svcctx) do { (svcctx)->executing_thread = Qnil; } while (0)
|
8
|
+
|
9
|
+
<%
|
10
|
+
prev_name = ''
|
11
|
+
funcs.each do |f|
|
12
|
+
next if f.name == prev_name
|
13
|
+
prev_name = f.name
|
14
|
+
%>
|
15
|
+
/* <%=f.name%> */
|
16
|
+
#if defined RUNTIME_API_CHECK
|
17
|
+
typedef <%=f.ret%> (*oci8_<%=f.name%>_func_t)(<%=f.args.collect {|arg| arg.dcl}.join(', ')%>);
|
18
|
+
static oci8_<%=f.name%>_func_t oci8_<%=f.name%>_func;
|
19
|
+
#define <%=f.name%> oci8_<%=f.name%>_func
|
20
|
+
#elif ORACLE_CLIENT_VERSION < <%=f.version_num%>
|
21
|
+
#define <%=f.name%>(<%=f.args.collect {|a| a.name}.join(', ')%>) (0)
|
22
|
+
#endif
|
23
|
+
<%
|
24
|
+
end # funcs.each
|
25
|
+
|
26
|
+
funcs.each do |f|
|
27
|
+
if f.remote
|
28
|
+
######################################################################
|
29
|
+
##
|
30
|
+
## remote API with runtime-check - start
|
31
|
+
##
|
32
|
+
######################################################################
|
33
|
+
%>
|
34
|
+
/*
|
35
|
+
* <%=f.name%>_nb
|
36
|
+
*/
|
37
|
+
typedef struct {
|
38
|
+
oci8_svcctx_t *svcctx;
|
39
|
+
<%
|
40
|
+
f.ret != 'void'
|
41
|
+
%> <%= f.ret %> rv;
|
42
|
+
<%
|
43
|
+
f.args.each do |a|
|
44
|
+
%> <%= a.dcl %>;
|
45
|
+
<% end
|
46
|
+
%>} oci8_<%=f.name%>_data_t;
|
47
|
+
|
48
|
+
#if defined RUNTIME_API_CHECK
|
49
|
+
int oci8_have_<%=f.name%>_nb;
|
50
|
+
#endif
|
51
|
+
|
52
|
+
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= <%=f.version_num%>
|
53
|
+
static void *oci8_<%=f.name%>_cb(void *user_data)
|
54
|
+
{
|
55
|
+
oci8_<%=f.name%>_data_t *data = (oci8_<%=f.name%>_data_t *)user_data;
|
56
|
+
<% if f.ret == 'void'
|
57
|
+
%> <%=f.name%>(<%= f.args.collect do |a| 'data->' + a.name; end.join(', ') %>);
|
58
|
+
<% else
|
59
|
+
%> data->rv = <%=f.name%>(<%= f.args.collect do |a| 'data->' + a.name; end.join(', ') %>);
|
60
|
+
<% end %>
|
61
|
+
<% if f.ret == 'sword'
|
62
|
+
%> BLOCKING_FUNCTION_EPILOGUE(data->svcctx);
|
63
|
+
return (void*)(VALUE)data->rv;
|
64
|
+
<% else
|
65
|
+
%> BLOCKING_FUNCTION_EPILOGUE(data->svcctx);
|
66
|
+
return NULL;
|
67
|
+
<% end %>
|
68
|
+
}
|
69
|
+
#else
|
70
|
+
#define oci8_<%=f.name%>_cb NULL
|
71
|
+
#endif
|
72
|
+
|
73
|
+
<%=f.ret%> oci8_<%=f.name%>_nb(oci8_svcctx_t *svcctx, <%=f.args.collect {|arg| arg.dcl}.join(', ')%>, const char *file, int line)
|
74
|
+
{
|
75
|
+
if (have_<%=f.name%>_nb) {
|
76
|
+
oci8_<%=f.name%>_data_t data;
|
77
|
+
data.svcctx = svcctx;
|
78
|
+
<% f.args.each do |a|
|
79
|
+
%> data.<%=a.name%> = <%=a.name%>;
|
80
|
+
<% end
|
81
|
+
%> oci8_call_without_gvl(svcctx, oci8_<%=f.name%>_cb, &data);
|
82
|
+
<% if f.ret != 'void'
|
83
|
+
%> return data.rv;
|
84
|
+
<% end
|
85
|
+
%> } else {
|
86
|
+
rb_raise(rb_eRuntimeError, "undefined OCI function %s is called", "<%=f.name%>_nb");
|
87
|
+
}
|
88
|
+
}
|
89
|
+
<%
|
90
|
+
######################################################################
|
91
|
+
##
|
92
|
+
## remote API with runtime-check - end
|
93
|
+
##
|
94
|
+
######################################################################
|
95
|
+
else
|
96
|
+
######################################################################
|
97
|
+
##
|
98
|
+
## local API with runtime-check - start
|
99
|
+
##
|
100
|
+
######################################################################
|
101
|
+
%>
|
102
|
+
/*
|
103
|
+
* <%=f.name%>
|
104
|
+
*/
|
105
|
+
#if defined RUNTIME_API_CHECK
|
106
|
+
int oci8_have_<%=f.name%>;
|
107
|
+
#endif
|
108
|
+
|
109
|
+
<%=f.ret%> oci8_<%=f.name%>(<%=f.args.collect {|arg| arg.dcl}.join(', ')%>, const char *file, int line)
|
110
|
+
{
|
111
|
+
if (have_<%=f.name%>) {
|
112
|
+
<% if f.ret == 'void'
|
113
|
+
%> <%=f.name%>(<%=f.args.collect {|arg| arg.name}.join(', ')%>);
|
114
|
+
<% else
|
115
|
+
%> return <%=f.name%>(<%=f.args.collect {|arg| arg.name}.join(', ')%>);
|
116
|
+
<% end
|
117
|
+
%> } else {
|
118
|
+
<% if f.code_if_not_found %><%=f.code_if_not_found.split("\n").collect {|line| " " + line}.join("\n")%>
|
119
|
+
<% else
|
120
|
+
%> rb_raise(rb_eRuntimeError, "undefined OCI function %s is called", "<%=f.name%>");
|
121
|
+
<% end
|
122
|
+
%> }
|
123
|
+
}
|
124
|
+
<%
|
125
|
+
######################################################################
|
126
|
+
##
|
127
|
+
## local API with runtime-check - end
|
128
|
+
##
|
129
|
+
######################################################################
|
130
|
+
end
|
131
|
+
end # funcs.each
|
132
|
+
######################################################################
|
133
|
+
##
|
134
|
+
## RUNTIME_API_CHECK
|
135
|
+
##
|
136
|
+
######################################################################
|
137
|
+
current_version_num = funcs[0].version_num
|
138
|
+
current_version_str = funcs[0].version_str
|
139
|
+
have_vars = []
|
140
|
+
%>
|
141
|
+
#if defined RUNTIME_API_CHECK
|
142
|
+
int oracle_client_version;
|
143
|
+
|
144
|
+
void Init_oci8_apiwrap(void)
|
145
|
+
{
|
146
|
+
oracle_client_version = 0;
|
147
|
+
<%
|
148
|
+
funcs.each do |f|
|
149
|
+
if current_version_num != f.version_num
|
150
|
+
unless have_vars.empty?
|
151
|
+
%> /* pass Oracle <%=current_version_str%> API */
|
152
|
+
oracle_client_version = <%=current_version_num%>;
|
153
|
+
<% have_vars.each do |v|
|
154
|
+
%> <%=v%> = 1;
|
155
|
+
<% end
|
156
|
+
end
|
157
|
+
have_vars = []
|
158
|
+
current_version_num = f.version_num
|
159
|
+
current_version_str = f.version_str
|
160
|
+
%>
|
161
|
+
/*
|
162
|
+
* checking Oracle <%=f.version_str%> API
|
163
|
+
*/
|
164
|
+
<%
|
165
|
+
end
|
166
|
+
have_vars << 'have_' + f.name + (f.remote ? '_nb' : '')
|
167
|
+
%> oci8_<%=f.name%>_func = (oci8_<%=f.name%>_func_t)oci8_find_symbol("<%=f.name%>");
|
168
|
+
if (oci8_<%=f.name%>_func == NULL)
|
169
|
+
return;
|
170
|
+
<%
|
171
|
+
end
|
172
|
+
%> /* pass Oracle <%=current_version_str%> API */
|
173
|
+
oracle_client_version = <%=current_version_num%>;
|
174
|
+
<% have_vars.each do |v|
|
175
|
+
%> <%=v%> = 1;
|
176
|
+
<% end
|
177
|
+
%>}
|
178
|
+
#endif /* RUNTIME_API_CHECK */
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
<%= header_comment
|
3
|
+
# This file is processed by apiwrap.rb.
|
4
|
+
%>
|
5
|
+
#ifndef APIWRAP_H
|
6
|
+
#define APIWRAP_H 1
|
7
|
+
#include <oci8.h>
|
8
|
+
|
9
|
+
#if defined RUNTIME_API_CHECK
|
10
|
+
void Init_oci8_apiwrap(void);
|
11
|
+
extern int oracle_client_version;
|
12
|
+
#else
|
13
|
+
#define oracle_client_version ORACLE_CLIENT_VERSION
|
14
|
+
#endif
|
15
|
+
<%
|
16
|
+
funcs.each do |f|
|
17
|
+
if f.remote
|
18
|
+
%>
|
19
|
+
/*
|
20
|
+
* <%=f.name%>
|
21
|
+
* version: <%=f.version_str%>
|
22
|
+
* remote: true
|
23
|
+
*/
|
24
|
+
<%=f.ret%> oci8_<%=f.name%>_nb(oci8_svcctx_t *svcctx, <%=f.args.collect {|arg| arg.dcl}.join(', ')%>, const char *file, int line);
|
25
|
+
#define <%=f.name%>_nb(svcctx, <%=f.args.collect do |a| a.name; end.join(', ')%>) \
|
26
|
+
oci8_<%=f.name%>_nb(svcctx, <%=f.args.collect do |a| a.name; end.join(', ')%>, __FILE__, __LINE__)
|
27
|
+
#if defined RUNTIME_API_CHECK
|
28
|
+
extern int oci8_have_<%=f.name%>_nb;
|
29
|
+
#define have_<%=f.name%>_nb oci8_have_<%=f.name%>_nb
|
30
|
+
#elif ORACLE_CLIENT_VERSION >= <%=f.version_num%>
|
31
|
+
#define have_<%=f.name%>_nb (1)
|
32
|
+
#else
|
33
|
+
#define have_<%=f.name%>_nb (0)
|
34
|
+
#endif
|
35
|
+
<%
|
36
|
+
else
|
37
|
+
%>
|
38
|
+
/*
|
39
|
+
* <%=f.name%>
|
40
|
+
* version: <%=f.version_str%>
|
41
|
+
* remote: false
|
42
|
+
*/
|
43
|
+
<%=f.ret%> oci8_<%=f.name%>(<%=f.args.collect {|arg| arg.dcl}.join(', ')%>, const char *file, int line);
|
44
|
+
#ifndef API_WRAP_C
|
45
|
+
#undef <%=f.name%>
|
46
|
+
#define <%=f.name%>(<%=f.args.collect do |a| a.name; end.join(', ')%>) \
|
47
|
+
oci8_<%=f.name%>(<%=f.args.collect do |a| a.name; end.join(', ')%>, __FILE__, __LINE__)
|
48
|
+
#endif
|
49
|
+
#if defined RUNTIME_API_CHECK
|
50
|
+
extern int oci8_have_<%=f.name%>;
|
51
|
+
#define have_<%=f.name%> oci8_have_<%=f.name%>
|
52
|
+
#elif ORACLE_CLIENT_VERSION >= <%=f.version_num%>
|
53
|
+
#define have_<%=f.name%> (1)
|
54
|
+
#else
|
55
|
+
#define have_<%=f.name%> (0)
|
56
|
+
#endif
|
57
|
+
<%
|
58
|
+
end
|
59
|
+
end # funcs.each
|
60
|
+
%>
|
61
|
+
#endif /* APIWRAP_H */
|
data/ext/oci8/apiwrap.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
class ArgDef
|
5
|
+
attr_reader :dcl
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(arg)
|
9
|
+
/(\w+)\s*$/ =~ arg
|
10
|
+
/\(\*(\w+)\)/ =~ arg if $1.nil?
|
11
|
+
@dcl = arg
|
12
|
+
@name = $1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class FuncDef
|
17
|
+
attr_reader :name
|
18
|
+
attr_reader :version
|
19
|
+
attr_reader :version_num
|
20
|
+
attr_reader :version_str
|
21
|
+
attr_reader :remote
|
22
|
+
attr_reader :args
|
23
|
+
attr_reader :ret
|
24
|
+
attr_reader :code_if_not_found
|
25
|
+
|
26
|
+
def initialize(key, val)
|
27
|
+
if key[-3..-1] == '_nb'
|
28
|
+
@name = key[0..-4]
|
29
|
+
@remote = true
|
30
|
+
else
|
31
|
+
@name = key
|
32
|
+
@remote = false
|
33
|
+
end
|
34
|
+
ver = val[:version]
|
35
|
+
ver_major = (ver / 100)
|
36
|
+
ver_minor = (ver / 10) % 10
|
37
|
+
ver_update = ver % 10
|
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
|
43
|
+
case @version
|
44
|
+
when 0x08000000; @version_num = 'ORAVER_8_0'
|
45
|
+
when 0x08100000; @version_num = 'ORAVER_8_1'
|
46
|
+
when 0x09000000; @version_num = 'ORAVER_9_0'
|
47
|
+
when 0x09200000; @version_num = 'ORAVER_9_2'
|
48
|
+
when 0x0a100000; @version_num = 'ORAVER_10_1'
|
49
|
+
when 0x0a200000; @version_num = 'ORAVER_10_2'
|
50
|
+
when 0x0b100000; @version_num = 'ORAVER_11_1'
|
51
|
+
when 0x12000000; @version_num = 'ORAVER_18'
|
52
|
+
end
|
53
|
+
@version_str = "#{ver_major}.#{ver_minor}.#{ver_update}"
|
54
|
+
@ret = val[:ret] || 'sword'
|
55
|
+
@args = val[:args].collect do |arg|
|
56
|
+
ArgDef.new(arg)
|
57
|
+
end
|
58
|
+
@code_if_not_found = val[:code_if_not_found]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_apiwrap
|
63
|
+
funcs = []
|
64
|
+
YAML.load(open(File.dirname(__FILE__) + '/apiwrap.yml')).each do |key, val|
|
65
|
+
funcs << FuncDef.new(key, val)
|
66
|
+
end
|
67
|
+
funcs.sort! do |a, b|
|
68
|
+
if a.version == b.version
|
69
|
+
a.name <=> b.name
|
70
|
+
else
|
71
|
+
a.version <=> b.version
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
header_comment = <<EOS.chomp
|
76
|
+
/*
|
77
|
+
* This file was created by apiwrap.rb.
|
78
|
+
* Don't edit this file manually.
|
79
|
+
*/
|
80
|
+
EOS
|
81
|
+
#'
|
82
|
+
|
83
|
+
erb = ERB.new(open(File.dirname(__FILE__) + '/apiwrap.h.tmpl').read)
|
84
|
+
open('apiwrap.h', 'w') do |fd|
|
85
|
+
fd.write(erb.result(binding))
|
86
|
+
end
|
87
|
+
|
88
|
+
erb = ERB.new(open(File.dirname(__FILE__) + '/apiwrap.c.tmpl').read)
|
89
|
+
open('apiwrap.c', 'w') do |fd|
|
90
|
+
fd.write(erb.result(binding))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if $0 == __FILE__
|
95
|
+
create_apiwrap
|
96
|
+
end
|