ruby-oci8 2.1.8 → 2.2.0.1
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/.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
@@ -0,0 +1,132 @@
|
|
1
|
+
# @title Install ruby-oci8 on OS X
|
2
|
+
|
3
|
+
This page explains the way to install ruby-oci8 os OS X.
|
4
|
+
|
5
|
+
Look at {file:docs/install-full-client.md}, {file:docs/install-instant-client.md}
|
6
|
+
or {file:docs/install-binary-package.md} for other platforms.
|
7
|
+
|
8
|
+
Install C compiler
|
9
|
+
==================
|
10
|
+
|
11
|
+
You need to install the command line developer tools or the Xcode.
|
12
|
+
(The latter includes the former.)
|
13
|
+
|
14
|
+
Run `"cc --version"` in a terminal to check whether they are installed.
|
15
|
+
|
16
|
+
If the cc version is printed, the tools are installed.
|
17
|
+
|
18
|
+
If the follwoing dialog is displayed, click its Install button to
|
19
|
+
install the tools.
|
20
|
+
You have no need to install the Xcode to compile ruby-oci8.
|
21
|
+
It requires command line tools, not an IDE such as the Xcode.
|
22
|
+
|
23
|
+

|
24
|
+
|
25
|
+
If `"Agreeing to the Xcode/iOS license requires admin privileges,
|
26
|
+
please re-run as root via sudo."` is printed, you need to run
|
27
|
+
`"sudo cc --version"`, enter your password, look at the license
|
28
|
+
and type `"agree"`.
|
29
|
+
|
30
|
+
Install Oracle Instant Client Packages
|
31
|
+
======================================
|
32
|
+
|
33
|
+
Download Oracle Instant Client Packages
|
34
|
+
--------------------------------
|
35
|
+
|
36
|
+
Download the following packages from [Oracle Technology Network][]
|
37
|
+
|
38
|
+
* Instant Client Package - Basic or Basic Lite
|
39
|
+
* Instant Client Package - SDK
|
40
|
+
* Instant Client Package - SQL*Plus (optionally)
|
41
|
+
|
42
|
+
Install Oracle Instant Client Packages via Homebrew
|
43
|
+
---------------------------------------------------
|
44
|
+
|
45
|
+
To install `Oracle Instant Client Basic Lite` via [Homebrew][]
|
46
|
+
|
47
|
+
* Download two instant client packages: `Basic Lite` and `SDK` and put them
|
48
|
+
in `/Library/Caches/Homebrew` (if the environment variable `HOMEBREW_CACHE`
|
49
|
+
is not set and `$HOME/Library/Caches/Homebrew` doesn't exist.)
|
50
|
+
* Run the followining commands:
|
51
|
+
|
52
|
+
brew install InstantClientTap/instantclient/instantclient-basiclite
|
53
|
+
brew install InstantClientTap/instantclient/instantclient-sdk
|
54
|
+
|
55
|
+
To install `Oracle Instant Client Basic` via [Homebrew][]
|
56
|
+
|
57
|
+
* Download *three* instant client packages: `Basic`, `Basic Lite` and `SDK`
|
58
|
+
and put them in `/Library/Caches/Homebrew` (if the environment variable
|
59
|
+
`HOMEBREW_CACHE` is not set and `$HOME/Library/Caches/Homebrew` doesn't exist.)
|
60
|
+
* Run the followining commands:
|
61
|
+
|
62
|
+
brew install InstantClientTap/instantclient/instantclient-basic
|
63
|
+
brew install InstantClientTap/instantclient/instantclient-sdk
|
64
|
+
|
65
|
+
* Set the environment variable OCI_DIR while performing the following installation steps
|
66
|
+
if Homebrew is installed outside `/usr/local`.
|
67
|
+
|
68
|
+
export OCI_DIR=$(brew --prefix)/lib
|
69
|
+
|
70
|
+
Install Oracle Instant Client Manually
|
71
|
+
---------------------
|
72
|
+
|
73
|
+
If you don't use [Homebrew][], do the following:
|
74
|
+
|
75
|
+
Unzip the packages as follows:
|
76
|
+
|
77
|
+
mkdir /opt
|
78
|
+
mkdir /opt/oracle
|
79
|
+
cd /opt/oracle
|
80
|
+
|
81
|
+
Copy downloaded files to /opt/oracle before running the following commands.
|
82
|
+
|
83
|
+
unzip instantclient-basic-macos.x64-11.2.0.4.0.zip
|
84
|
+
unzip instantclient-sdk-macos.x64-11.2.0.4.0.zip
|
85
|
+
unzip instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
|
86
|
+
|
87
|
+
Make a symbolic link to link the library.
|
88
|
+
|
89
|
+
cd /opt/oracle/instantclient11_2
|
90
|
+
ln -s libclntsh.dylib.11.1 libclntsh.dylib
|
91
|
+
|
92
|
+
Fix the library install and identification names using [fix_oralib][] to make them work
|
93
|
+
without `DYLD_LIBRARY_PATH`.
|
94
|
+
|
95
|
+
cd /opt/oracle/instantclient11_2
|
96
|
+
curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
|
97
|
+
ruby fix_oralib.rb
|
98
|
+
|
99
|
+
Set the environment variable OCI_DIR while performing the following installation steps.
|
100
|
+
|
101
|
+
export OCI_DIR=/opt/oracle/instantclient11_2
|
102
|
+
|
103
|
+
Installation
|
104
|
+
============
|
105
|
+
|
106
|
+
If you get a problem in the following steps, look at {file:docs/report-installation-issue.md}.
|
107
|
+
|
108
|
+
gem package
|
109
|
+
-----------
|
110
|
+
|
111
|
+
Run the following command.
|
112
|
+
|
113
|
+
gem install ruby-oci8
|
114
|
+
|
115
|
+
tar.gz package
|
116
|
+
--------------
|
117
|
+
|
118
|
+
### Download the source code
|
119
|
+
|
120
|
+
Download the latest tar.gz package from [download page][].
|
121
|
+
|
122
|
+
### Run make and install
|
123
|
+
|
124
|
+
tar xvfz ruby-oci8-VERSION.tar.gz
|
125
|
+
cd ruby-oci8-VERSION
|
126
|
+
make
|
127
|
+
make install
|
128
|
+
|
129
|
+
[download page]: https://bintray.com/kubo/generic/ruby-oci8
|
130
|
+
[Homebrew]: http://brew.sh/
|
131
|
+
[fix_oralib]: https://github.com/kubo/fix_oralib_osx
|
132
|
+
[Oracle Technology Network]: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
|
Binary file
|
@@ -1,13 +1,10 @@
|
|
1
1
|
# @title Report Installation Issues
|
2
2
|
|
3
|
-
Look at {file:docs/platform-specific-issues.md}
|
4
|
-
[the issues page on github][github] and [the ruby-oci8 help forum on rubyforge][rubyforge]
|
5
|
-
to check whether your issue is fixed or not.
|
3
|
+
Look at {file:docs/platform-specific-issues.md} and [the issues page on github][github] to check whether your issue is fixed or not.
|
6
4
|
|
7
5
|
If it is a new one, post the following information to [github][].
|
8
6
|
|
9
7
|
[github]: https://github.com/kubo/ruby-oci8/issues
|
10
|
-
[rubyforge]: http://rubyforge.org/forum/forum.php?forum_id=1078
|
11
8
|
|
12
9
|
* Messages printed out to the console
|
13
10
|
|
data/ext/oci8/apiwrap.c.tmpl
CHANGED
@@ -4,11 +4,7 @@
|
|
4
4
|
%>
|
5
5
|
#define API_WRAP_C 1
|
6
6
|
#include "apiwrap.h"
|
7
|
-
#ifdef NATIVE_THREAD_WITH_GVL
|
8
7
|
#define BLOCKING_FUNCTION_EPILOGUE(svcctx) do { (svcctx)->executing_thread = Qnil; } while (0)
|
9
|
-
#else
|
10
|
-
#define BLOCKING_FUNCTION_EPILOGUE(svcctx) do { } while (0)
|
11
|
-
#endif
|
12
8
|
|
13
9
|
<%
|
14
10
|
prev_name = ''
|
data/ext/oci8/apiwrap.yml
CHANGED
@@ -312,15 +312,6 @@ OCILobFileSetName:
|
|
312
312
|
- CONST text *filename
|
313
313
|
- ub2 f_length
|
314
314
|
|
315
|
-
# round trip: 1
|
316
|
-
OCILobGetLength_nb:
|
317
|
-
:version: 800
|
318
|
-
:args:
|
319
|
-
- OCISvcCtx *svchp
|
320
|
-
- OCIError *errhp
|
321
|
-
- OCILobLocator *locp
|
322
|
-
- ub4 *lenp
|
323
|
-
|
324
315
|
# round trip: 0
|
325
316
|
OCILobLocatorIsInit:
|
326
317
|
:version: 800
|
@@ -330,48 +321,6 @@ OCILobLocatorIsInit:
|
|
330
321
|
- CONST OCILobLocator *locp
|
331
322
|
- boolean *is_initialized
|
332
323
|
|
333
|
-
# round trip: 0 or 1
|
334
|
-
OCILobRead_nb:
|
335
|
-
:version: 800
|
336
|
-
:args:
|
337
|
-
- OCISvcCtx *svchp
|
338
|
-
- OCIError *errhp
|
339
|
-
- OCILobLocator *locp
|
340
|
-
- ub4 *amtp
|
341
|
-
- ub4 offset
|
342
|
-
- dvoid *bufp
|
343
|
-
- ub4 bufl
|
344
|
-
- dvoid *ctxp
|
345
|
-
- OCICallbackLobRead cbfp
|
346
|
-
- ub2 csid
|
347
|
-
- ub1 csfrm
|
348
|
-
|
349
|
-
# round trip: 1
|
350
|
-
OCILobTrim_nb:
|
351
|
-
:version: 800
|
352
|
-
:args:
|
353
|
-
- OCISvcCtx *svchp
|
354
|
-
- OCIError *errhp
|
355
|
-
- OCILobLocator *locp
|
356
|
-
- ub4 newlen
|
357
|
-
|
358
|
-
# round trip: 0 or 1
|
359
|
-
OCILobWrite_nb:
|
360
|
-
:version: 800
|
361
|
-
:args:
|
362
|
-
- OCISvcCtx *svchp
|
363
|
-
- OCIError *errhp
|
364
|
-
- OCILobLocator *locp
|
365
|
-
- ub4 *amtp
|
366
|
-
- ub4 offset
|
367
|
-
- dvoid *bufp
|
368
|
-
- ub4 buflen
|
369
|
-
- ub1 piece
|
370
|
-
- dvoid *ctxp
|
371
|
-
- OCICallbackLobWrite cbfp
|
372
|
-
- ub2 csid
|
373
|
-
- ub1 csfrm
|
374
|
-
|
375
324
|
# round trip: 1
|
376
325
|
OCILogoff:
|
377
326
|
:version: 800
|
@@ -874,16 +823,6 @@ OCIStmtGetPieceInfo:
|
|
874
823
|
- ub4 *idxp
|
875
824
|
- ub1 *piecep
|
876
825
|
|
877
|
-
OCIStmtPrepare:
|
878
|
-
:version: 800
|
879
|
-
:args:
|
880
|
-
- OCIStmt *stmtp
|
881
|
-
- OCIError *errhp
|
882
|
-
- CONST text *stmt
|
883
|
-
- ub4 stmt_len
|
884
|
-
- ub4 language
|
885
|
-
- ub4 mode
|
886
|
-
|
887
826
|
OCIStmtSetPieceInfo:
|
888
827
|
:version: 800
|
889
828
|
:args:
|
@@ -1343,7 +1282,8 @@ OCINlsCharSetNameToId:
|
|
1343
1282
|
- dvoid *envhp
|
1344
1283
|
- const oratext *name
|
1345
1284
|
|
1346
|
-
|
1285
|
+
# round trip: 0
|
1286
|
+
OCIStmtPrepare2:
|
1347
1287
|
:version: 920
|
1348
1288
|
:args:
|
1349
1289
|
- OCISvcCtx *svchp
|
data/ext/oci8/bind.c
CHANGED
@@ -421,7 +421,5 @@ void Init_oci8_bind(VALUE klass)
|
|
421
421
|
/* register primitive data types. */
|
422
422
|
oci8_define_bind_class("String", &bind_string_data_type, bind_string_alloc);
|
423
423
|
oci8_define_bind_class("RAW", &bind_raw_data_type, bind_raw_alloc);
|
424
|
-
|
425
|
-
oci8_define_bind_class("BinaryDouble", &bind_binary_double_data_type, bind_binary_double_alloc);
|
426
|
-
}
|
424
|
+
oci8_define_bind_class("BinaryDouble", &bind_binary_double_data_type, bind_binary_double_alloc);
|
427
425
|
}
|
data/ext/oci8/encoding.c
CHANGED
@@ -14,17 +14,7 @@
|
|
14
14
|
/* NLS ratio, maximum number of bytes per one chracter */
|
15
15
|
int oci8_nls_ratio = 1;
|
16
16
|
|
17
|
-
/* Oracle charset id -> Oracle charset name */
|
18
|
-
static VALUE csid2name;
|
19
|
-
|
20
|
-
/* Oracle charset name -> Oracle charset id */
|
21
|
-
static ID id_upcase;
|
22
|
-
static VALUE csname2id;
|
23
|
-
static VALUE oci8_charset_name2id(VALUE svc, VALUE name);
|
24
|
-
#ifdef HAVE_TYPE_RB_ENCODING
|
25
17
|
rb_encoding *oci8_encoding;
|
26
|
-
#endif
|
27
|
-
|
28
18
|
|
29
19
|
/*
|
30
20
|
* call-seq:
|
@@ -33,72 +23,21 @@ rb_encoding *oci8_encoding;
|
|
33
23
|
* Returns the Oracle character set name from the specified
|
34
24
|
* character set ID if it is valid. Otherwise, +nil+ is returned.
|
35
25
|
*
|
36
|
-
* === Oracle 9iR2 client or upper
|
37
|
-
*
|
38
|
-
* It is done by using the mapping table stored in the client side.
|
39
|
-
*
|
40
|
-
* === Oracle 9iR1 client or lower
|
41
|
-
*
|
42
|
-
* It executes the following PL/SQL block internally to use
|
43
|
-
* the mapping table stored in the server side.
|
44
|
-
*
|
45
|
-
* BEGIN
|
46
|
-
* :name := nls_charset_name(:csid);
|
47
|
-
* END;
|
48
|
-
*
|
49
26
|
* @param [Fixnum] charset_id Oracle character set id
|
50
27
|
* @return [String] Oracle character set name or nil
|
51
|
-
* @since 2.
|
28
|
+
* @since 2.2.0
|
52
29
|
*/
|
53
|
-
VALUE
|
30
|
+
VALUE oci8_s_charset_id2name(VALUE klass, VALUE csid)
|
54
31
|
{
|
55
|
-
|
32
|
+
char buf[OCI_NLS_MAXBUFSZ];
|
33
|
+
sword rv;
|
56
34
|
|
57
|
-
if (!NIL_P(name)) {
|
58
|
-
return name;
|
59
|
-
}
|
60
35
|
Check_Type(csid, T_FIXNUM);
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
sword rv;
|
65
|
-
|
66
|
-
rv = OCINlsCharSetIdToName(oci8_envhp, TO_ORATEXT(buf), sizeof(buf), (ub2)FIX2INT(csid));
|
67
|
-
if (rv != OCI_SUCCESS) {
|
68
|
-
return Qnil;
|
69
|
-
}
|
70
|
-
name = rb_usascii_str_new_cstr(buf);
|
71
|
-
} else {
|
72
|
-
/* Oracle 9iR1 or lower */
|
73
|
-
oci8_exec_sql_var_t bind_vars[2];
|
74
|
-
char buf[OCI_NLS_MAXBUFSZ];
|
75
|
-
ub2 buflen = 0;
|
76
|
-
int ival = FIX2INT(csid);
|
77
|
-
|
78
|
-
/* :name */
|
79
|
-
bind_vars[0].valuep = buf;
|
80
|
-
bind_vars[0].value_sz = OCI_NLS_MAXBUFSZ;
|
81
|
-
bind_vars[0].dty = SQLT_CHR;
|
82
|
-
bind_vars[0].indp = NULL;
|
83
|
-
bind_vars[0].alenp = &buflen;
|
84
|
-
/* :csid */
|
85
|
-
bind_vars[1].valuep = &ival;
|
86
|
-
bind_vars[1].value_sz = sizeof(int);
|
87
|
-
bind_vars[1].dty = SQLT_INT;
|
88
|
-
bind_vars[1].indp = NULL;
|
89
|
-
bind_vars[1].alenp = NULL;
|
90
|
-
|
91
|
-
/* convert chaset id to charset name by querying Oracle server. */
|
92
|
-
oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :name := nls_charset_name(:csid); END;", 0, NULL, 2, bind_vars, 1);
|
93
|
-
if (buflen == 0) {
|
94
|
-
return Qnil;
|
95
|
-
}
|
96
|
-
name = rb_usascii_str_new(buf, buflen);
|
36
|
+
rv = OCINlsCharSetIdToName(oci8_envhp, TO_ORATEXT(buf), sizeof(buf), (ub2)FIX2INT(csid));
|
37
|
+
if (rv != OCI_SUCCESS) {
|
38
|
+
return Qnil;
|
97
39
|
}
|
98
|
-
|
99
|
-
rb_hash_aset(csid2name, csid, name);
|
100
|
-
rb_hash_aset(csname2id, name, csid);
|
101
|
-
return name;
|
40
|
+
return rb_usascii_str_new_cstr(buf);
|
102
41
|
}
|
103
42
|
|
104
43
|
/*
|
@@ -108,70 +47,19 @@ VALUE oci8_charset_id2name(VALUE svc, VALUE csid)
|
|
108
47
|
* Returns the Oracle character set ID for the specified Oracle
|
109
48
|
* character set name if it is valid. Othewise, +nil+ is returned.
|
110
49
|
*
|
111
|
-
* === Oracle 9iR2 client or upper
|
112
|
-
*
|
113
|
-
* It is done by using the mapping table stored in the client side.
|
114
|
-
*
|
115
|
-
* === Oracle 9iR1 client or lower
|
116
|
-
*
|
117
|
-
* It executes the following PL/SQL block internally to use
|
118
|
-
* the mapping table stored in the server side.
|
119
|
-
*
|
120
|
-
* BEGIN
|
121
|
-
* :csid := nls_charset_id(:name);
|
122
|
-
* END;
|
123
|
-
*
|
124
50
|
* @param [String] charset_name Oracle character set name
|
125
51
|
* @return [Fixnum] Oracle character set id or nil
|
126
|
-
* @since 2.
|
52
|
+
* @since 2.2.0
|
127
53
|
*/
|
128
|
-
static VALUE
|
54
|
+
static VALUE oci8_s_charset_name2id(VALUE klass, VALUE name)
|
129
55
|
{
|
130
|
-
|
131
|
-
|
132
|
-
name = rb_funcall(name, id_upcase, 0);
|
133
|
-
csid = rb_hash_aref(csname2id, StringValue(name));
|
134
|
-
if (!NIL_P(csid)) {
|
135
|
-
return csid;
|
136
|
-
}
|
137
|
-
if (have_OCINlsCharSetNameToId) {
|
138
|
-
/* Oracle 9iR2 or upper */
|
139
|
-
ub2 rv;
|
140
|
-
|
141
|
-
rv = OCINlsCharSetNameToId(oci8_envhp, RSTRING_ORATEXT(name));
|
142
|
-
if (rv == 0) {
|
143
|
-
return Qnil;
|
144
|
-
}
|
145
|
-
csid = INT2FIX(rv);
|
146
|
-
} else {
|
147
|
-
/* Oracle 9iR1 or lower */
|
148
|
-
oci8_exec_sql_var_t bind_vars[2];
|
149
|
-
int ival;
|
150
|
-
sb2 ind = 0; /* null indicator */
|
56
|
+
ub2 rv;
|
151
57
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
bind_vars[0].dty = SQLT_INT;
|
156
|
-
bind_vars[0].indp = &ind;
|
157
|
-
bind_vars[0].alenp = NULL;
|
158
|
-
/* :name */
|
159
|
-
bind_vars[1].valuep = RSTRING_PTR(name);
|
160
|
-
bind_vars[1].value_sz = RSTRING_LEN(name);
|
161
|
-
bind_vars[1].dty = SQLT_CHR;
|
162
|
-
bind_vars[1].indp = NULL;
|
163
|
-
bind_vars[1].alenp = NULL;
|
164
|
-
|
165
|
-
/* convert chaset name to charset id by querying Oracle server. */
|
166
|
-
oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :csid := nls_charset_id(:name); END;", 0, NULL, 2, bind_vars, 1);
|
167
|
-
if (ind) {
|
168
|
-
return Qnil;
|
169
|
-
}
|
170
|
-
csid = INT2FIX(ival);
|
58
|
+
rv = OCINlsCharSetNameToId(oci8_envhp, TO_ORATEXT(StringValueCStr(name)));
|
59
|
+
if (rv == 0) {
|
60
|
+
return Qnil;
|
171
61
|
}
|
172
|
-
|
173
|
-
rb_hash_aset(csname2id, name, csid);
|
174
|
-
return csid;
|
62
|
+
return INT2FIX(rv);
|
175
63
|
}
|
176
64
|
|
177
65
|
/*
|
@@ -192,33 +80,6 @@ static VALUE oci8_get_nls_ratio(VALUE klass)
|
|
192
80
|
return INT2NUM(oci8_nls_ratio);
|
193
81
|
}
|
194
82
|
|
195
|
-
#ifndef HAVE_TYPE_RB_ENCODING
|
196
|
-
/*
|
197
|
-
* call-seq:
|
198
|
-
* OCI8.nls_ratio = integer
|
199
|
-
*
|
200
|
-
* Sets NLS ratio, maximum number of bytes per one character of the
|
201
|
-
* current NLS chracter set. It is initialized in 'oci8/encoding-init.rb'
|
202
|
-
* when oci8 is required. You have no need to set it explicitly.
|
203
|
-
*
|
204
|
-
* @param [Fixnum] integer NLS ratio
|
205
|
-
* @since 2.1.0
|
206
|
-
* @private
|
207
|
-
* @note ruby 1.8 only
|
208
|
-
*/
|
209
|
-
static VALUE oci8_set_nls_ratio(VALUE klass, VALUE val)
|
210
|
-
{
|
211
|
-
int v = NUM2INT(val);
|
212
|
-
if (v <= 0) {
|
213
|
-
rb_raise(rb_eRangeError, "expected a positive integer but %d", v);
|
214
|
-
}
|
215
|
-
oci8_nls_ratio = v;
|
216
|
-
return val;
|
217
|
-
}
|
218
|
-
#endif
|
219
|
-
|
220
|
-
#ifdef HAVE_TYPE_RB_ENCODING
|
221
|
-
|
222
83
|
/*
|
223
84
|
* call-seq:
|
224
85
|
* OCI8.encoding -> enc
|
@@ -280,7 +141,43 @@ static VALUE oci8_set_encoding(VALUE klass, VALUE encoding)
|
|
280
141
|
}
|
281
142
|
return encoding;
|
282
143
|
}
|
283
|
-
|
144
|
+
|
145
|
+
/*
|
146
|
+
* call-seq:
|
147
|
+
* charset_name2id(charset_name) -> charset_id
|
148
|
+
*
|
149
|
+
* Returns the Oracle character set ID for the specified Oracle
|
150
|
+
* character set name if it is valid. Othewise, +nil+ is returned.
|
151
|
+
*
|
152
|
+
* @param [String] charset_name Oracle character set name
|
153
|
+
* @return [Fixnum] Oracle character set id or nil
|
154
|
+
* @since 2.0.0
|
155
|
+
* @deprecated Use {OCI8.charset_name2id} instead.
|
156
|
+
*/
|
157
|
+
static VALUE oci8_charset_name2id(VALUE svc, VALUE name)
|
158
|
+
{
|
159
|
+
rb_warning("Use OCI8.charset_name2id instead of OCI8#charset_name2id.");
|
160
|
+
return oci8_s_charset_name2id(Qnil, name);
|
161
|
+
}
|
162
|
+
|
163
|
+
/*
|
164
|
+
* call-seq:
|
165
|
+
* charset_id2name(charset_id) -> charset_name
|
166
|
+
*
|
167
|
+
* Returns the Oracle character set name from the specified
|
168
|
+
* character set ID if it is valid. Otherwise, +nil+ is returned.
|
169
|
+
*
|
170
|
+
* @param [Fixnum] charset_id Oracle character set id
|
171
|
+
* @return [String] Oracle character set name or nil
|
172
|
+
* @since 2.0.0
|
173
|
+
* @deprecated Use {OCI8.charset_id2name} instead.
|
174
|
+
*/
|
175
|
+
static VALUE oci8_charset_id2name(VALUE svc, VALUE name)
|
176
|
+
{
|
177
|
+
rb_warning("Use OCI8.charset_id2name instead of OCI8#charset_id2name.");
|
178
|
+
return oci8_s_charset_id2name(Qnil, name);
|
179
|
+
}
|
180
|
+
|
284
181
|
|
285
182
|
void Init_oci8_encoding(VALUE cOCI8)
|
286
183
|
{
|
@@ -288,21 +185,12 @@ void Init_oci8_encoding(VALUE cOCI8)
|
|
288
185
|
oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
|
289
186
|
cOCI8 = rb_define_class("OCI8", oci8_cOCIHandle);
|
290
187
|
#endif
|
291
|
-
csid2name = rb_hash_new();
|
292
|
-
rb_global_variable(&csid2name);
|
293
|
-
|
294
|
-
id_upcase = rb_intern("upcase");
|
295
|
-
csname2id = rb_hash_new();
|
296
|
-
rb_global_variable(&csname2id);
|
297
188
|
|
298
|
-
|
299
|
-
|
189
|
+
rb_define_singleton_method(cOCI8, "charset_name2id", oci8_s_charset_name2id, 1);
|
190
|
+
rb_define_singleton_method(cOCI8, "charset_id2name", oci8_s_charset_id2name, 1);
|
300
191
|
rb_define_singleton_method(cOCI8, "nls_ratio", oci8_get_nls_ratio, 0);
|
301
|
-
#ifndef HAVE_TYPE_RB_ENCODING
|
302
|
-
rb_define_singleton_method(cOCI8, "nls_ratio=", oci8_set_nls_ratio, 1);
|
303
|
-
#endif
|
304
|
-
#ifdef HAVE_TYPE_RB_ENCODING
|
305
192
|
rb_define_singleton_method(cOCI8, "encoding", oci8_get_encoding, 0);
|
306
193
|
rb_define_singleton_method(cOCI8, "encoding=", oci8_set_encoding, 1);
|
307
|
-
|
194
|
+
rb_define_method(cOCI8, "charset_name2id", oci8_charset_name2id, 1);
|
195
|
+
rb_define_method(cOCI8, "charset_id2name", oci8_charset_id2name, 1);
|
308
196
|
}
|