ruby-oci8 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +100 -0
- data/NEWS +39 -0
- data/README.md +16 -8
- data/dist-files +2 -0
- data/docs/bind-array-to-in_cond.md +1 -1
- data/docs/conflicts-local-connections-and-processes.md +7 -4
- data/docs/hanging-after-inactivity.md +61 -0
- data/docs/install-binary-package.md +15 -11
- data/docs/install-full-client.md +18 -21
- data/docs/install-instant-client.md +44 -27
- data/docs/install-on-osx.md +13 -15
- 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/encoding.c +5 -5
- data/ext/oci8/env.c +8 -2
- data/ext/oci8/error.c +25 -2
- data/ext/oci8/hook_funcs.c +131 -6
- data/ext/oci8/oci8.c +18 -13
- data/ext/oci8/oci8.h +10 -2
- data/ext/oci8/oci8lib.c +129 -2
- data/ext/oci8/ocihandle.c +34 -34
- data/ext/oci8/oraconf.rb +26 -80
- data/ext/oci8/oradate.c +18 -18
- data/ext/oci8/plthook.h +10 -0
- data/ext/oci8/plthook_elf.c +83 -2
- data/ext/oci8/plthook_osx.c +31 -0
- data/ext/oci8/plthook_win32.c +9 -0
- data/ext/oci8/stmt.c +1 -1
- data/lib/oci8.rb +38 -1
- data/lib/oci8/cursor.rb +9 -8
- data/lib/oci8/oci8.rb +7 -3
- data/lib/oci8/properties.rb +22 -0
- data/lib/oci8/version.rb +1 -1
- data/ruby-oci8.gemspec +1 -5
- data/test/test_all.rb +1 -0
- data/test/test_bind_integer.rb +47 -0
- data/test/test_connstr.rb +29 -13
- data/test/test_oci8.rb +1 -1
- metadata +5 -3
@@ -1,7 +1,10 @@
|
|
1
1
|
# @title Install for Oracle Instant Client
|
2
2
|
|
3
|
+
Install for Oracle Instant Client
|
4
|
+
=================================
|
5
|
+
|
3
6
|
Introduction
|
4
|
-
|
7
|
+
------------
|
5
8
|
|
6
9
|
This page explains the way to install ruby-oci8 for Oracle Instant Client.
|
7
10
|
|
@@ -13,10 +16,10 @@ have a special need to compile ruby-oci8 by yourself.
|
|
13
16
|
Look at {file:docs/install-on-osx.md} for OS X.
|
14
17
|
|
15
18
|
Install Oracle Instant Client Packages
|
16
|
-
|
19
|
+
--------------------------------------
|
20
|
+
|
21
|
+
### Donwload Instant Client Packages
|
17
22
|
|
18
|
-
Donwload Instant Client Packages
|
19
|
-
--------------------------------
|
20
23
|
Download the following packages from [Oracle Technology Network](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html).
|
21
24
|
|
22
25
|
* Instant Client Package - Basic or Basic Lite
|
@@ -25,8 +28,7 @@ Download the following packages from [Oracle Technology Network](http://www.orac
|
|
25
28
|
|
26
29
|
Note: use 32-bit packages for 32-bit ruby even though the OS is 64-bit.
|
27
30
|
|
28
|
-
UNIX zip packages
|
29
|
-
-----------------
|
31
|
+
### UNIX zip packages
|
30
32
|
|
31
33
|
Unzip the packages as follows:
|
32
34
|
|
@@ -79,8 +81,7 @@ Though many instant client pages indicate that the environment varialbe
|
|
79
81
|
configuration files such as `tnsnames.ora` and `sqlnet.ora` are in
|
80
82
|
`$ORACLE_HOME/network/admin/`.
|
81
83
|
|
82
|
-
Linux rpm packages
|
83
|
-
------------------
|
84
|
+
### Linux rpm packages
|
84
85
|
|
85
86
|
Install the downloaded packages as follows:
|
86
87
|
|
@@ -95,24 +96,43 @@ For example:
|
|
95
96
|
$ LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client/lib
|
96
97
|
$ export LD_LIBRARY_PATH
|
97
98
|
|
98
|
-
Windows
|
99
|
-
|
99
|
+
### Windows
|
100
|
+
|
101
|
+
Unzip the packages and set `PATH` to point to the directory where `OCI.DLL` is installed.
|
102
|
+
|
103
|
+
If `require "ruby-oci8"` raises a load error such as "OCI.DLL: 126(The
|
104
|
+
specified module could not be found. )", either `OCI.DLL` or a DLL depended
|
105
|
+
by `OCI.DLL` could not be found in `PATH`.
|
106
|
+
|
107
|
+
If `OCI.DLL` is surely in `PATH`, the missing module is a Visual C++ runtime
|
108
|
+
library in most cases. You need to install "Microsoft Visual C++ Redistributable
|
109
|
+
Package" or copy a runtime library to the directory where `ruby.exe` resides.
|
110
|
+
|
111
|
+
| Oracle Version | Package | Runtime Library|
|
112
|
+
|---|---|---|
|
113
|
+
| 12.2.0.x | [Microsoft Visual C++ 2013 Redistributable Package][2013] | MSVCR120.DLL |
|
114
|
+
| 12.1.0.x | [Microsoft Visual C++ 2010 Redistributable Package][2010] | MSVCR100.DLL |
|
115
|
+
| 11.2.0.x | Microsoft Visual C++ 2005 SP1 Redistributable Package ([x86][2005SP1_x86], [x64][2005SP1_x64]) | MSVCR80.DLL(The file version must be 8.0.50727.762.) |
|
116
|
+
| 11.1.0.x | [No separate redistributable package][2003] | MSVCR71.DLL |
|
117
|
+
| 10.2.0.x | [No separate redistributable package][2003] | MSVCR71.DLL |
|
100
118
|
|
101
|
-
|
119
|
+
[2013]: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
|
120
|
+
[2010]: http://www.microsoft.com/en-us/download/details.aspx?id=26999
|
121
|
+
[2005SP1_x86]: https://www.microsoft.com/en-us/download/details.aspx?id=5638
|
122
|
+
[2005SP1_x64]: https://www.microsoft.com/en-us/download/details.aspx?id=18471
|
123
|
+
[2003]: http://stackoverflow.com/questions/1596167/where-to-download-microsoft-visual-c-2003-redistributable#6132093
|
102
124
|
|
103
125
|
Check the environment
|
104
|
-
|
126
|
+
---------------------
|
105
127
|
|
106
|
-
Oracle installation
|
107
|
-
-------------------
|
128
|
+
### Oracle installation
|
108
129
|
|
109
130
|
Run the following command and confirm it works fine. If it doesn't
|
110
131
|
work well, check `LD_LIBRARY_PATH` or PATH.
|
111
132
|
|
112
133
|
sqlplus USERNAME/PASSWORD
|
113
134
|
|
114
|
-
ruby installation
|
115
|
-
-----------------
|
135
|
+
### ruby installation
|
116
136
|
|
117
137
|
Run the following command. If it ends with "can't find header files
|
118
138
|
for ruby" or "ruby: no such file to load -- mkmf (LoadError)", you need
|
@@ -120,8 +140,7 @@ to install ruby-devel(redhat) or ruby-dev(debian/ubuntu).
|
|
120
140
|
|
121
141
|
ruby -r mkmf -e ""
|
122
142
|
|
123
|
-
development tools
|
124
|
-
-----------------
|
143
|
+
### development tools
|
125
144
|
|
126
145
|
You need a C compiler and development tools such as make or nmake.
|
127
146
|
Note that they must be same with ones used to compile the ruby.
|
@@ -129,13 +148,12 @@ For example, you need Oracle Solaris Studio, not gcc, for ruby
|
|
129
148
|
compiled by Oracle Solaris Studio.
|
130
149
|
|
131
150
|
Installation
|
132
|
-
|
151
|
+
------------
|
133
152
|
|
134
153
|
If you get a problem in the following steps, look at {file:docs/platform-specific-issues.md}
|
135
154
|
and {file:docs/report-installation-issue.md}.
|
136
155
|
|
137
|
-
gem package
|
138
|
-
-----------
|
156
|
+
### gem package
|
139
157
|
|
140
158
|
Run the following command.
|
141
159
|
|
@@ -144,19 +162,18 @@ Run the following command.
|
|
144
162
|
If you get a problem, look at {file:docs/platform-specific-issues.md}
|
145
163
|
and {file:docs/report-installation-issue.md}.
|
146
164
|
|
147
|
-
tar.gz package
|
148
|
-
--------------
|
165
|
+
### tar.gz package
|
149
166
|
|
150
|
-
|
167
|
+
#### Download the source code
|
151
168
|
|
152
169
|
Download the latest tar.gz package from [download page][].
|
153
170
|
|
154
171
|
Note: if you are using Windows and you have no special need to compile
|
155
172
|
it by yourself, look at {file:docs/install-binary-packge.md}.
|
156
173
|
|
157
|
-
|
174
|
+
#### Run make and install
|
158
175
|
|
159
|
-
|
176
|
+
##### UNIX or Windows(mingw32, cygwin)
|
160
177
|
|
161
178
|
gzip -dc ruby-oci8-VERSION.tar.gz | tar xvf -
|
162
179
|
cd ruby-oci8-VERSION
|
@@ -166,7 +183,7 @@ it by yourself, look at {file:docs/install-binary-packge.md}.
|
|
166
183
|
note: If you use '`sudo`', use it only when running '`make install`'.
|
167
184
|
'`sudo`' doesn't pass library search path to the executing command for security reasons.
|
168
185
|
|
169
|
-
|
186
|
+
##### Windows(mswin32)
|
170
187
|
|
171
188
|
gzip -dc ruby-oci8-VERSION.tar.gz | tar xvf -
|
172
189
|
cd ruby-oci8-VERSION
|
data/docs/install-on-osx.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# @title Install ruby-oci8 on OS X
|
2
2
|
|
3
|
+
Install ruby-oci8 on OS X
|
4
|
+
=========================
|
5
|
+
|
3
6
|
This page explains the way to install ruby-oci8 os OS X.
|
4
7
|
|
5
8
|
Look at {file:docs/install-full-client.md}, {file:docs/install-instant-client.md}
|
6
9
|
or {file:docs/install-binary-package.md} for other platforms.
|
7
10
|
|
8
11
|
Install C compiler
|
9
|
-
|
12
|
+
------------------
|
10
13
|
|
11
14
|
You need to install the command line developer tools or the Xcode.
|
12
15
|
(The latter includes the former.)
|
@@ -28,10 +31,9 @@ please re-run as root via sudo."` is printed, you need to run
|
|
28
31
|
and type `"agree"`.
|
29
32
|
|
30
33
|
Install Oracle Instant Client Packages
|
31
|
-
|
34
|
+
--------------------------------------
|
32
35
|
|
33
|
-
Download Oracle Instant Client Packages
|
34
|
-
--------------------------------
|
36
|
+
### Download Oracle Instant Client Packages
|
35
37
|
|
36
38
|
Download the following packages from [Oracle Technology Network][]
|
37
39
|
|
@@ -39,8 +41,7 @@ Download the following packages from [Oracle Technology Network][]
|
|
39
41
|
* Instant Client Package - SDK (`instantclient-sdk-macos.x64-12.1.0.2.0.zip`)
|
40
42
|
* Instant Client Package - SQL*Plus (`instantclient-sdk-macos.x64-12.1.0.2.0.zip`) (optionally)
|
41
43
|
|
42
|
-
Install Oracle Instant Client Packages via Homebrew
|
43
|
-
---------------------------------------------------
|
44
|
+
### Install Oracle Instant Client Packages via Homebrew
|
44
45
|
|
45
46
|
To install `Oracle Instant Client Basic` via [Homebrew][]
|
46
47
|
|
@@ -78,8 +79,7 @@ To install `Oracle Instant Client Basic Lite` via [Homebrew][]
|
|
78
79
|
|
79
80
|
export OCI_DIR=$(brew --prefix)/lib
|
80
81
|
|
81
|
-
Install Oracle Instant Client Manually
|
82
|
-
---------------------
|
82
|
+
### Install Oracle Instant Client Manually
|
83
83
|
|
84
84
|
If you don't use [Homebrew][], do the following:
|
85
85
|
|
@@ -104,25 +104,23 @@ Set the environment variable OCI_DIR while performing the following installation
|
|
104
104
|
export OCI_DIR=/opt/oracle/instantclient_12_1
|
105
105
|
|
106
106
|
Installation
|
107
|
-
|
107
|
+
------------
|
108
108
|
|
109
109
|
If you get a problem in the following steps, look at {file:docs/report-installation-issue.md}.
|
110
110
|
|
111
|
-
gem package
|
112
|
-
-----------
|
111
|
+
### gem package
|
113
112
|
|
114
113
|
Run the following command.
|
115
114
|
|
116
115
|
gem install ruby-oci8
|
117
116
|
|
118
|
-
tar.gz package
|
119
|
-
--------------
|
117
|
+
### tar.gz package
|
120
118
|
|
121
|
-
|
119
|
+
#### Download the source code
|
122
120
|
|
123
121
|
Download the latest tar.gz package from [download page][].
|
124
122
|
|
125
|
-
|
123
|
+
#### Run make and install
|
126
124
|
|
127
125
|
tar xvfz ruby-oci8-VERSION.tar.gz
|
128
126
|
cd ruby-oci8-VERSION
|
@@ -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/encoding.c
CHANGED
@@ -23,7 +23,7 @@ rb_encoding *oci8_encoding;
|
|
23
23
|
* Returns the Oracle character set name from the specified
|
24
24
|
* character set ID if it is valid. Otherwise, +nil+ is returned.
|
25
25
|
*
|
26
|
-
* @param [
|
26
|
+
* @param [Integer] charset_id Oracle character set id
|
27
27
|
* @return [String] Oracle character set name or nil
|
28
28
|
* @since 2.2.0
|
29
29
|
*/
|
@@ -48,7 +48,7 @@ VALUE oci8_s_charset_id2name(VALUE klass, VALUE csid)
|
|
48
48
|
* character set name if it is valid. Othewise, +nil+ is returned.
|
49
49
|
*
|
50
50
|
* @param [String] charset_name Oracle character set name
|
51
|
-
* @return [
|
51
|
+
* @return [Integer] Oracle character set id or nil
|
52
52
|
* @since 2.2.0
|
53
53
|
*/
|
54
54
|
static VALUE oci8_s_charset_name2id(VALUE klass, VALUE name)
|
@@ -71,7 +71,7 @@ static VALUE oci8_s_charset_name2id(VALUE klass, VALUE name)
|
|
71
71
|
* internal buffer size of a string bind variable whose nls length
|
72
72
|
* semantics is char.
|
73
73
|
*
|
74
|
-
* @return [
|
74
|
+
* @return [Integer] NLS ratio
|
75
75
|
* @since 2.1.0
|
76
76
|
* @private
|
77
77
|
*/
|
@@ -150,7 +150,7 @@ static VALUE oci8_set_encoding(VALUE klass, VALUE encoding)
|
|
150
150
|
* character set name if it is valid. Othewise, +nil+ is returned.
|
151
151
|
*
|
152
152
|
* @param [String] charset_name Oracle character set name
|
153
|
-
* @return [
|
153
|
+
* @return [Integer] Oracle character set id or nil
|
154
154
|
* @since 2.0.0
|
155
155
|
* @deprecated Use {OCI8.charset_name2id} instead.
|
156
156
|
*/
|
@@ -167,7 +167,7 @@ static VALUE oci8_charset_name2id(VALUE svc, VALUE name)
|
|
167
167
|
* Returns the Oracle character set name from the specified
|
168
168
|
* character set ID if it is valid. Otherwise, +nil+ is returned.
|
169
169
|
*
|
170
|
-
* @param [
|
170
|
+
* @param [Integer] charset_id Oracle character set id
|
171
171
|
* @return [String] Oracle character set name or nil
|
172
172
|
* @since 2.0.0
|
173
173
|
* @deprecated Use {OCI8.charset_id2name} instead.
|
data/ext/oci8/env.c
CHANGED
@@ -14,11 +14,17 @@ OCIEnv *oci8_global_envhp;
|
|
14
14
|
OCIEnv *oci8_make_envhp(void)
|
15
15
|
{
|
16
16
|
sword rv;
|
17
|
+
OCIEnv *envhp = NULL;
|
17
18
|
|
18
|
-
rv = OCIEnvCreate(&
|
19
|
+
rv = OCIEnvCreate(&envhp, oci8_env_mode, NULL, NULL, NULL, NULL, 0, NULL);
|
19
20
|
if (rv != OCI_SUCCESS) {
|
20
|
-
|
21
|
+
if (envhp != NULL) {
|
22
|
+
oci8_env_free_and_raise(envhp, rv);
|
23
|
+
} else {
|
24
|
+
oci8_raise_init_error();
|
25
|
+
}
|
21
26
|
}
|
27
|
+
oci8_global_envhp = envhp;
|
22
28
|
return oci8_global_envhp;
|
23
29
|
}
|
24
30
|
|
data/ext/oci8/error.c
CHANGED
@@ -172,6 +172,22 @@ sb4 oci8_get_error_code(OCIError *errhp)
|
|
172
172
|
return errcode;
|
173
173
|
}
|
174
174
|
|
175
|
+
/* This is overwritten by lib/oci8/oci8.rb. */
|
176
|
+
static VALUE oci8_error_initialize(int argc, VALUE *argv, VALUE self)
|
177
|
+
{
|
178
|
+
VALUE msg;
|
179
|
+
VALUE code;
|
180
|
+
VALUE sql;
|
181
|
+
VALUE parse_error_offset;
|
182
|
+
|
183
|
+
rb_scan_args(argc, argv, "04", &msg, &code, &sql, &parse_error_offset);
|
184
|
+
rb_call_super(argc ? 1 : 0, &msg);
|
185
|
+
rb_ivar_set(self, oci8_id_at_code, code);
|
186
|
+
rb_ivar_set(self, oci8_id_at_sql, sql);
|
187
|
+
rb_ivar_set(self, oci8_id_at_parse_error_offset, parse_error_offset);
|
188
|
+
return Qnil;
|
189
|
+
}
|
190
|
+
|
175
191
|
void Init_oci8_error(void)
|
176
192
|
{
|
177
193
|
errbufsiz = ERRBUF_EXPAND_LEN;
|
@@ -201,6 +217,9 @@ void Init_oci8_error(void)
|
|
201
217
|
rb_define_attr(eOCIError, "sql", 1, 0);
|
202
218
|
rb_define_attr(eOCIError, "parse_error_offset", 1, 0);
|
203
219
|
rb_define_alias(eOCIError, "parseErrorOffset", "parse_error_offset");
|
220
|
+
|
221
|
+
/* This is overwritten by lib/oci8/oci8.rb. */
|
222
|
+
rb_define_method_nodoc(eOCIError, "initialize", oci8_error_initialize, -1);
|
204
223
|
}
|
205
224
|
|
206
225
|
void oci8_do_raise(OCIError *errhp, sword status, OCIStmt *stmthp, const char *file, int line)
|
@@ -208,9 +227,13 @@ void oci8_do_raise(OCIError *errhp, sword status, OCIStmt *stmthp, const char *f
|
|
208
227
|
rb_exc_raise(oci8_make_exc(errhp, status, OCI_HTYPE_ERROR, stmthp, file, line));
|
209
228
|
}
|
210
229
|
|
211
|
-
void oci8_do_env_raise(OCIEnv *envhp, sword status, const char *file, int line)
|
230
|
+
void oci8_do_env_raise(OCIEnv *envhp, sword status, int free_envhp, const char *file, int line)
|
212
231
|
{
|
213
|
-
|
232
|
+
VALUE exc = oci8_make_exc(envhp, status, OCI_HTYPE_ENV, NULL, file, line);
|
233
|
+
if (free_envhp) {
|
234
|
+
OCIHandleFree(envhp, OCI_HTYPE_ENV);
|
235
|
+
}
|
236
|
+
rb_exc_raise(exc);
|
214
237
|
}
|
215
238
|
|
216
239
|
void oci8_do_raise_init_error(const char *file, int line)
|