ruby-oci8 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1254 -390
- data/Makefile +10 -13
- data/README +56 -385
- data/VERSION +1 -1
- data/dist-files +26 -27
- data/ext/oci8/.document +1 -0
- data/ext/oci8/MANIFEST +0 -4
- data/ext/oci8/apiwrap.c.tmpl +172 -0
- data/ext/oci8/apiwrap.h.tmpl +61 -0
- data/ext/oci8/apiwrap.rb +91 -0
- data/ext/oci8/apiwrap.yml +1243 -0
- data/ext/oci8/attr.c +124 -384
- data/ext/oci8/bind.c +472 -164
- data/ext/oci8/encoding.c +196 -0
- data/ext/oci8/env.c +84 -253
- data/ext/oci8/error.c +196 -127
- data/ext/oci8/extconf.rb +82 -59
- data/ext/oci8/lob.c +710 -370
- data/ext/oci8/metadata.c +359 -0
- data/ext/oci8/object.c +622 -0
- data/ext/oci8/oci8.c +577 -161
- data/ext/oci8/oci8.h +354 -258
- data/ext/oci8/oci8lib.c +493 -0
- data/ext/oci8/ocidatetime.c +473 -0
- data/ext/oci8/ocinumber.c +1123 -24
- data/ext/oci8/oraconf.rb +72 -106
- data/ext/oci8/oradate.c +511 -321
- data/ext/oci8/stmt.c +752 -572
- data/ext/oci8/win32.c +131 -0
- data/ext/oci8/xmldb.c +383 -0
- data/lib/.document +2 -0
- data/lib/dbd/OCI8.rb +2 -17
- data/lib/oci8.rb.in +41 -1622
- data/lib/oci8/.document +5 -0
- data/lib/oci8/compat.rb +108 -0
- data/lib/oci8/datetime.rb +489 -0
- data/lib/oci8/encoding-init.rb +40 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2077 -0
- data/lib/oci8/object.rb +548 -0
- data/lib/oci8/oci8.rb +773 -0
- data/lib/oci8/oracle_version.rb +144 -0
- data/metaconfig +3 -3
- data/ruby-oci8.gemspec +5 -5
- data/setup.rb +4 -4
- data/test/config.rb +64 -84
- data/test/test_all.rb +14 -21
- data/test/test_array_dml.rb +317 -0
- data/test/test_bind_raw.rb +18 -25
- data/test/test_bind_time.rb +78 -91
- data/test/test_break.rb +37 -35
- data/test/test_clob.rb +33 -89
- data/test/test_connstr.rb +5 -4
- data/test/test_datetime.rb +469 -0
- data/test/test_dbi.rb +99 -60
- data/test/test_dbi_clob.rb +3 -8
- data/test/test_metadata.rb +65 -51
- data/test/test_oci8.rb +151 -55
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +76 -83
- data/test/test_oranumber.rb +405 -71
- data/test/test_rowid.rb +6 -11
- metadata +31 -32
- data/NEWS +0 -420
- data/ext/oci8/const.c +0 -165
- data/ext/oci8/define.c +0 -53
- data/ext/oci8/describe.c +0 -81
- data/ext/oci8/descriptor.c +0 -39
- data/ext/oci8/handle.c +0 -273
- data/ext/oci8/oranumber.c +0 -445
- data/ext/oci8/param.c +0 -37
- data/ext/oci8/server.c +0 -182
- data/ext/oci8/session.c +0 -99
- data/ext/oci8/svcctx.c +0 -238
- data/ruby-oci8.spec +0 -62
- data/support/README +0 -4
- data/support/runit/assert.rb +0 -281
- data/support/runit/cui/testrunner.rb +0 -101
- data/support/runit/error.rb +0 -4
- data/support/runit/method_mappable.rb +0 -20
- data/support/runit/robserver.rb +0 -25
- data/support/runit/setuppable.rb +0 -15
- data/support/runit/teardownable.rb +0 -16
- data/support/runit/testcase.rb +0 -113
- data/support/runit/testfailure.rb +0 -25
- data/support/runit/testresult.rb +0 -121
- data/support/runit/testsuite.rb +0 -43
- data/support/runit/version.rb +0 -3
- data/test/test_describe.rb +0 -137
data/ext/oci8/const.c
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
const.c - part of ruby-oci8
|
3
|
-
|
4
|
-
Copyright (C) 2002-2006 KUBO Takehiro <kubo@jiubao.org>
|
5
|
-
|
6
|
-
define constant values.
|
7
|
-
*/
|
8
|
-
#include "oci8.h"
|
9
|
-
|
10
|
-
ID oci8_id_code;
|
11
|
-
ID oci8_id_define_array;
|
12
|
-
ID oci8_id_bind_hash;
|
13
|
-
ID oci8_id_message;
|
14
|
-
ID oci8_id_new;
|
15
|
-
ID oci8_id_parse_error_offset;
|
16
|
-
ID oci8_id_server;
|
17
|
-
ID oci8_id_session;
|
18
|
-
ID oci8_id_sql;
|
19
|
-
|
20
|
-
struct oci8_names {
|
21
|
-
const char *name;
|
22
|
-
VALUE value;
|
23
|
-
};
|
24
|
-
typedef struct oci8_names oci8_names_t;
|
25
|
-
#define ENTRY(name) {#name, INT2FIX(name)}
|
26
|
-
|
27
|
-
static oci8_names_t oci8_typecode[] = {
|
28
|
-
ENTRY(OCI_TYPECODE_VARCHAR), /* 1(SQLT_CHR) */
|
29
|
-
ENTRY(OCI_TYPECODE_NUMBER), /* 2(SQLT_NUM) */
|
30
|
-
ENTRY(OCI_TYPECODE_DATE), /* 12(SQLT_DAT) */
|
31
|
-
ENTRY(OCI_TYPECODE_UNSIGNED8), /* 23(SQLT_BIN) */
|
32
|
-
ENTRY(OCI_TYPECODE_RAW), /* 95(SQLT_LVB) */
|
33
|
-
ENTRY(OCI_TYPECODE_CHAR), /* 96(SQLT_AFC) */
|
34
|
-
#ifdef OCI_TYPECODE_BDOUBLE
|
35
|
-
ENTRY(OCI_TYPECODE_BDOUBLE), /* 101(SQLT_IBDOUBLE) */
|
36
|
-
#endif
|
37
|
-
ENTRY(OCI_TYPECODE_OBJECT), /* 108(SQLT_NTY) */
|
38
|
-
ENTRY(OCI_TYPECODE_BLOB), /* 113(SQLT_BLOB) */
|
39
|
-
ENTRY(OCI_TYPECODE_CLOB), /* 112(SQLT_CLOB) */
|
40
|
-
ENTRY(OCI_TYPECODE_NAMEDCOLLECTION), /* 122(SQLT_NCO) */
|
41
|
-
ENTRY(SQLT_RDD) /* 104 */
|
42
|
-
};
|
43
|
-
#define NUM_OF_OCI8_TYPECODE (sizeof(oci8_typecode) / sizeof(oci8_typecode[0]))
|
44
|
-
|
45
|
-
static VALUE oci8_make_names(oci8_names_t *names, size_t size)
|
46
|
-
{
|
47
|
-
volatile VALUE ary;
|
48
|
-
unsigned int i;
|
49
|
-
|
50
|
-
ary = rb_ary_new();
|
51
|
-
for (i = 0;i < size;i++)
|
52
|
-
rb_ary_store(ary, FIX2INT(names[i].value), rb_str_new2(names[i].name));
|
53
|
-
return ary;
|
54
|
-
}
|
55
|
-
|
56
|
-
void Init_oci8_const(void)
|
57
|
-
{
|
58
|
-
unsigned int i;
|
59
|
-
|
60
|
-
oci8_id_code = rb_intern("code");
|
61
|
-
oci8_id_define_array = rb_intern("define_array");
|
62
|
-
oci8_id_bind_hash = rb_intern("bind_hash");
|
63
|
-
oci8_id_message = rb_intern("message");
|
64
|
-
oci8_id_new = rb_intern("new");
|
65
|
-
oci8_id_parse_error_offset = rb_intern("parse_error_offset");
|
66
|
-
oci8_id_server = rb_intern("server");
|
67
|
-
oci8_id_session = rb_intern("session");
|
68
|
-
oci8_id_sql = rb_intern("sql");
|
69
|
-
|
70
|
-
rb_define_global_const("OCI_DEFAULT", INT2FIX(OCI_DEFAULT));
|
71
|
-
rb_define_global_const("OCI_OBJECT", INT2FIX(OCI_OBJECT));
|
72
|
-
rb_define_global_const("OCI_CRED_RDBMS", INT2FIX(OCI_CRED_RDBMS));
|
73
|
-
rb_define_global_const("OCI_CRED_EXT", INT2FIX(OCI_CRED_EXT));
|
74
|
-
rb_define_global_const("OCI_MIGRATE", INT2FIX(OCI_MIGRATE));
|
75
|
-
rb_define_global_const("OCI_SYSDBA", INT2FIX(OCI_SYSDBA));
|
76
|
-
rb_define_global_const("OCI_SYSOPER", INT2FIX(OCI_SYSOPER));
|
77
|
-
rb_define_global_const("OCI_PRELIM_AUTH", INT2FIX(OCI_PRELIM_AUTH));
|
78
|
-
|
79
|
-
/* OCIStmt#prepare */
|
80
|
-
rb_define_global_const("OCI_NTV_SYNTAX", INT2FIX(OCI_NTV_SYNTAX));
|
81
|
-
rb_define_global_const("OCI_V7_SYNTAX", INT2FIX(OCI_V7_SYNTAX));
|
82
|
-
rb_define_global_const("OCI_V8_SYNTAX", INT2FIX(OCI_V8_SYNTAX));
|
83
|
-
|
84
|
-
/* OCIStmt#execute */
|
85
|
-
#ifdef OCI_BATCH_ERRORS
|
86
|
-
rb_define_global_const("OCI_BATCH_ERRORS", INT2FIX(OCI_BATCH_ERRORS));
|
87
|
-
#endif
|
88
|
-
rb_define_global_const("OCI_COMMIT_ON_SUCCESS", INT2FIX(OCI_COMMIT_ON_SUCCESS));
|
89
|
-
rb_define_global_const("OCI_DESCRIBE_ONLY", INT2FIX(OCI_DESCRIBE_ONLY));
|
90
|
-
rb_define_global_const("OCI_EXACT_FETCH", INT2FIX(OCI_EXACT_FETCH));
|
91
|
-
#ifdef OCI_PARSE_ONLY
|
92
|
-
rb_define_global_const("OCI_PARSE_ONLY", INT2FIX(OCI_PARSE_ONLY));
|
93
|
-
#endif
|
94
|
-
#ifdef OCI_STMT_SCROLLABLE_READONLY
|
95
|
-
rb_define_global_const("OCI_STMT_SCROLLABLE_READONLY", INT2FIX(OCI_STMT_SCROLLABLE_READONLY));
|
96
|
-
#endif
|
97
|
-
|
98
|
-
rb_define_global_const("OCI_AUTH", INT2FIX(OCI_AUTH));
|
99
|
-
#ifdef OCI_SHARED
|
100
|
-
rb_define_global_const("OCI_SHARED", INT2FIX(OCI_SHARED));
|
101
|
-
#endif
|
102
|
-
#ifdef OCI_CPOOL
|
103
|
-
rb_define_global_const("OCI_CPOOL", INT2FIX(OCI_CPOOL));
|
104
|
-
#endif
|
105
|
-
#ifdef OCI_NO_SHARING
|
106
|
-
rb_define_global_const("OCI_NO_SHARING", INT2FIX(OCI_NO_SHARING));
|
107
|
-
#endif
|
108
|
-
|
109
|
-
rb_define_global_const("OCI_FETCH_NEXT", INT2FIX(OCI_FETCH_NEXT));
|
110
|
-
|
111
|
-
for (i = 0;i < oci8_attr_size;i++) {
|
112
|
-
rb_define_global_const(oci8_attr_list[i].name, INT2FIX(i));
|
113
|
-
}
|
114
|
-
|
115
|
-
/* TYPE CODE */
|
116
|
-
for (i = 0;i < NUM_OF_OCI8_TYPECODE;i++)
|
117
|
-
rb_define_global_const(oci8_typecode[i].name, oci8_typecode[i].value);
|
118
|
-
rb_define_global_const("OCI_TYPECODE_NAMES", oci8_make_names(oci8_typecode, NUM_OF_OCI8_TYPECODE));
|
119
|
-
|
120
|
-
/* OCI Parameter Types */
|
121
|
-
rb_define_global_const("OCI_PTYPE_UNK", INT2FIX(OCI_PTYPE_UNK));
|
122
|
-
rb_define_global_const("OCI_PTYPE_TABLE", INT2FIX(OCI_PTYPE_TABLE));
|
123
|
-
rb_define_global_const("OCI_PTYPE_VIEW", INT2FIX(OCI_PTYPE_VIEW));
|
124
|
-
rb_define_global_const("OCI_PTYPE_PROC", INT2FIX(OCI_PTYPE_PROC));
|
125
|
-
rb_define_global_const("OCI_PTYPE_FUNC", INT2FIX(OCI_PTYPE_FUNC));
|
126
|
-
rb_define_global_const("OCI_PTYPE_PKG", INT2FIX(OCI_PTYPE_PKG));
|
127
|
-
rb_define_global_const("OCI_PTYPE_TYPE", INT2FIX(OCI_PTYPE_TYPE));
|
128
|
-
rb_define_global_const("OCI_PTYPE_SYN", INT2FIX(OCI_PTYPE_SYN));
|
129
|
-
rb_define_global_const("OCI_PTYPE_SEQ", INT2FIX(OCI_PTYPE_SEQ));
|
130
|
-
rb_define_global_const("OCI_PTYPE_COL", INT2FIX(OCI_PTYPE_COL));
|
131
|
-
rb_define_global_const("OCI_PTYPE_ARG", INT2FIX(OCI_PTYPE_ARG));
|
132
|
-
rb_define_global_const("OCI_PTYPE_LIST", INT2FIX(OCI_PTYPE_LIST));
|
133
|
-
rb_define_global_const("OCI_PTYPE_TYPE_ATTR", INT2FIX(OCI_PTYPE_TYPE_ATTR));
|
134
|
-
rb_define_global_const("OCI_PTYPE_TYPE_COLL", INT2FIX(OCI_PTYPE_TYPE_COLL));
|
135
|
-
rb_define_global_const("OCI_PTYPE_TYPE_METHOD", INT2FIX(OCI_PTYPE_TYPE_METHOD));
|
136
|
-
rb_define_global_const("OCI_PTYPE_TYPE_ARG", INT2FIX(OCI_PTYPE_TYPE_ARG));
|
137
|
-
rb_define_global_const("OCI_PTYPE_TYPE_RESULT", INT2FIX(OCI_PTYPE_TYPE_RESULT));
|
138
|
-
#ifdef OCI_PTYPE_SCHEMA
|
139
|
-
rb_define_global_const("OCI_PTYPE_SCHEMA", INT2FIX(OCI_PTYPE_SCHEMA));
|
140
|
-
#endif
|
141
|
-
#ifdef OCI_PTYPE_DATABASE
|
142
|
-
rb_define_global_const("OCI_PTYPE_DATABASE", INT2FIX(OCI_PTYPE_DATABASE));
|
143
|
-
#endif
|
144
|
-
|
145
|
-
/* Bind and Define Options */
|
146
|
-
rb_define_global_const("OCI_DATA_AT_EXEC", INT2FIX(OCI_DATA_AT_EXEC));
|
147
|
-
rb_define_global_const("OCI_DYNAMIC_FETCH", INT2FIX(OCI_DYNAMIC_FETCH));
|
148
|
-
|
149
|
-
/* OCI Statement Types */
|
150
|
-
rb_define_global_const("OCI_STMT_SELECT", INT2FIX(OCI_STMT_SELECT));
|
151
|
-
rb_define_global_const("OCI_STMT_UPDATE", INT2FIX(OCI_STMT_UPDATE));
|
152
|
-
rb_define_global_const("OCI_STMT_DELETE", INT2FIX(OCI_STMT_DELETE));
|
153
|
-
rb_define_global_const("OCI_STMT_INSERT", INT2FIX(OCI_STMT_INSERT));
|
154
|
-
rb_define_global_const("OCI_STMT_CREATE", INT2FIX(OCI_STMT_CREATE));
|
155
|
-
rb_define_global_const("OCI_STMT_DROP", INT2FIX(OCI_STMT_DROP));
|
156
|
-
rb_define_global_const("OCI_STMT_ALTER", INT2FIX(OCI_STMT_ALTER));
|
157
|
-
rb_define_global_const("OCI_STMT_BEGIN", INT2FIX(OCI_STMT_BEGIN));
|
158
|
-
rb_define_global_const("OCI_STMT_DECLARE", INT2FIX(OCI_STMT_DECLARE));
|
159
|
-
|
160
|
-
/* Piece Definitions */
|
161
|
-
rb_define_global_const("OCI_ONE_PIECE", INT2FIX(OCI_ONE_PIECE));
|
162
|
-
rb_define_global_const("OCI_FIRST_PIECE", INT2FIX(OCI_FIRST_PIECE));
|
163
|
-
rb_define_global_const("OCI_NEXT_PIECE", INT2FIX(OCI_NEXT_PIECE));
|
164
|
-
rb_define_global_const("OCI_LAST_PIECE", INT2FIX(OCI_LAST_PIECE));
|
165
|
-
}
|
data/ext/oci8/define.c
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
define.c - part of ruby-oci8
|
3
|
-
|
4
|
-
Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
|
5
|
-
|
6
|
-
=begin
|
7
|
-
== OCIDefine
|
8
|
-
The define handle, which is created by ((<OCIStmt#defineByPos>)).
|
9
|
-
|
10
|
-
The fetched data of select statements is got via this handle.
|
11
|
-
|
12
|
-
super class: ((<OCIHandle>))
|
13
|
-
|
14
|
-
correspond native OCI datatype: ((|OCIDefine|))
|
15
|
-
=end
|
16
|
-
*/
|
17
|
-
#include "oci8.h"
|
18
|
-
|
19
|
-
/*
|
20
|
-
=begin
|
21
|
-
--- OCIDefine#get()
|
22
|
-
get the selected date.
|
23
|
-
|
24
|
-
:return value
|
25
|
-
fetched data. Its datatype is correspond to the 2nd argument of ((<OCIStmt#defineByPos>)).
|
26
|
-
|
27
|
-
correspond native OCI function: nothing
|
28
|
-
=end
|
29
|
-
*/
|
30
|
-
static VALUE oci8_get_data(VALUE self)
|
31
|
-
{
|
32
|
-
oci8_bind_handle_t *defnhp;
|
33
|
-
VALUE obj;
|
34
|
-
|
35
|
-
Data_Get_Struct(self, oci8_bind_handle_t, defnhp);
|
36
|
-
obj = oci8_get_value(defnhp);
|
37
|
-
return obj;
|
38
|
-
}
|
39
|
-
|
40
|
-
static VALUE oci8_set_data(VALUE self, VALUE val)
|
41
|
-
{
|
42
|
-
oci8_bind_handle_t *hp;
|
43
|
-
|
44
|
-
Data_Get_Struct(self, oci8_bind_handle_t, hp);
|
45
|
-
oci8_set_value(hp, val);
|
46
|
-
return self;
|
47
|
-
}
|
48
|
-
|
49
|
-
void Init_oci8_define(void)
|
50
|
-
{
|
51
|
-
rb_define_method(cOCIDefine, "get", oci8_get_data, 0);
|
52
|
-
rb_define_method(cOCIDefine, "set", oci8_set_data, 1);
|
53
|
-
}
|
data/ext/oci8/describe.c
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
describe.c - part of ruby-oci8
|
3
|
-
|
4
|
-
Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
|
5
|
-
|
6
|
-
=begin
|
7
|
-
== OCIDescribe
|
8
|
-
The describe handle, which is used for the explicit describe.
|
9
|
-
|
10
|
-
super class: ((<OCIHandle>))
|
11
|
-
|
12
|
-
correspond native OCI datatype: ((|OCIDescribe|))
|
13
|
-
|
14
|
-
For example:
|
15
|
-
dsc = env.alloc(OCIDescribe)
|
16
|
-
dsc.describeAny(svc, "EMP", OCI_PTYPE_TABLE)
|
17
|
-
parm = dsc.attrGet(OCI_ATTR_PARAM)
|
18
|
-
...get various information from parm...
|
19
|
-
|
20
|
-
TODO: more explanation and examples.
|
21
|
-
|
22
|
-
=end
|
23
|
-
*/
|
24
|
-
#include "oci8.h"
|
25
|
-
|
26
|
-
/*
|
27
|
-
=begin
|
28
|
-
--- OCIDescribe#describeAny(svc, name, type)
|
29
|
-
get various information of Oracle's schema objects: tables, views, synonyms,
|
30
|
-
procedures, functions, packages, sequences, and types.
|
31
|
-
|
32
|
-
:svc
|
33
|
-
((<service context handle|OCISvcCtx>)) in which the object to describe exists.
|
34
|
-
:name
|
35
|
-
name of object to describe.
|
36
|
-
:type
|
37
|
-
type of object to describe.
|
38
|
-
|
39
|
-
* ((|OCI_PTYPE_TABLE|)), for tables
|
40
|
-
* ((|OCI_PTYPE_VIEW|)), for views
|
41
|
-
* ((|OCI_PTYPE_PROC|)), for procedures
|
42
|
-
* ((|OCI_PTYPE_FUNC|)), for functions
|
43
|
-
* ((|OCI_PTYPE_PKG|)), for packages
|
44
|
-
* ((|OCI_PTYPE_TYPE|)), for types
|
45
|
-
* ((|OCI_PTYPE_SYN|)), for synonyms
|
46
|
-
* ((|OCI_PTYPE_SEQ|)), for sequences
|
47
|
-
* ((|OCI_PTYPE_SCHEMA|)), for schemas
|
48
|
-
* ((|OCI_PTYPE_DATABASE|)), for databases
|
49
|
-
* ((|OCI_PTYPE_UNK|)), for unknown schema objects
|
50
|
-
|
51
|
-
correspond native OCI function: ((|OCIDescribeAny|))
|
52
|
-
|
53
|
-
((*note*)): To use this method in Oracle 8.0.5 for Linux,
|
54
|
-
call OCIEnv.create with OCI_OBJECT or segmentation fault occurs.
|
55
|
-
This bug was fixed 8.0.6 or later.
|
56
|
-
=end
|
57
|
-
*/
|
58
|
-
static VALUE oci8_describe_any(VALUE self, VALUE vdsc, VALUE vname, VALUE vtype)
|
59
|
-
{
|
60
|
-
oci8_handle_t *h;
|
61
|
-
oci8_handle_t *svch;
|
62
|
-
oci8_string_t name;
|
63
|
-
ub1 type;
|
64
|
-
sword rv;
|
65
|
-
|
66
|
-
Get_Handle(self, h); /* 0 */
|
67
|
-
Check_Handle(vdsc, OCISvcCtx, svch); /* 1 */
|
68
|
-
Get_String(vname, name); /* 2 */
|
69
|
-
type = FIX2INT(vtype); /* 3 */
|
70
|
-
|
71
|
-
rv = OCIDescribeAny(svch->hp, h->errhp, name.ptr, name.len, OCI_OTYPE_NAME, OCI_DEFAULT, type, h->hp);
|
72
|
-
if (rv != OCI_SUCCESS) {
|
73
|
-
oci8_raise(h->errhp, rv, NULL);
|
74
|
-
}
|
75
|
-
return self;
|
76
|
-
}
|
77
|
-
|
78
|
-
void Init_oci8_describe(void)
|
79
|
-
{
|
80
|
-
rb_define_method(cOCIDescribe, "describeAny", oci8_describe_any, 3);
|
81
|
-
}
|
data/ext/oci8/descriptor.c
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
descriptor.c - part of ruby-oci8
|
3
|
-
|
4
|
-
Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
|
5
|
-
|
6
|
-
=begin
|
7
|
-
== OCIDescriptor
|
8
|
-
The abstract class of OCI descriptors.
|
9
|
-
=end
|
10
|
-
*/
|
11
|
-
#include "oci8.h"
|
12
|
-
|
13
|
-
/*
|
14
|
-
=begin
|
15
|
-
--- OCIDescriptor#attrGet(type)
|
16
|
-
:type
|
17
|
-
the type of attribute.
|
18
|
-
:return value
|
19
|
-
depends on argument ((|type|)).
|
20
|
-
|
21
|
-
See also ((<Attributes of Handles and Descriptors>)).
|
22
|
-
=end
|
23
|
-
*/
|
24
|
-
|
25
|
-
/*
|
26
|
-
=begin
|
27
|
-
--- OCIDescriptor#free()
|
28
|
-
explicitly free the OCI's data structure associated with this object.
|
29
|
-
This call will not free ruby's object itself, which wrap the OCI's data structure.
|
30
|
-
=end
|
31
|
-
*/
|
32
|
-
|
33
|
-
void Init_oci8_descriptor(void)
|
34
|
-
{
|
35
|
-
rb_define_method(cOCIDescriptor, "attrGet", oci8_attr_get, 1);
|
36
|
-
rb_define_method(cOCIDescriptor, "attrSet", oci8_attr_set, 2);
|
37
|
-
rb_define_method(cOCIDescriptor, "free", oci8_handle_free, 0);
|
38
|
-
rb_define_singleton_method(cOCIDescriptor, "new", oci8_s_new, 0);
|
39
|
-
}
|
data/ext/oci8/handle.c
DELETED
@@ -1,273 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
handle.c - part of ruby-oci8
|
3
|
-
|
4
|
-
Copyright (C) 2002-2006 KUBO Takehiro <kubo@jiubao.org>
|
5
|
-
|
6
|
-
=begin
|
7
|
-
== OCIHandle
|
8
|
-
This is the abstract super class of OCI Handles.
|
9
|
-
See ((<Class Hierarchy>)).
|
10
|
-
=end
|
11
|
-
*/
|
12
|
-
#include "oci8.h"
|
13
|
-
#ifdef HAVE_UNISTD_H
|
14
|
-
#include <unistd.h> /* getpid() */
|
15
|
-
#endif
|
16
|
-
|
17
|
-
#ifdef WIN32
|
18
|
-
#ifndef getpid
|
19
|
-
extern rb_pid_t rb_w32_getpid(void);
|
20
|
-
#define getpid() rb_w32_getpid()
|
21
|
-
#endif
|
22
|
-
#endif
|
23
|
-
|
24
|
-
static void oci8_handle_do_free(oci8_handle_t *h)
|
25
|
-
{
|
26
|
-
unsigned int i;
|
27
|
-
if (h->type == 0) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
/* free its children recursively.*/
|
31
|
-
for (i = 0;i < h->size;i++) {
|
32
|
-
if (h->children[i] != NULL)
|
33
|
-
oci8_handle_do_free(h->children[i]);
|
34
|
-
}
|
35
|
-
xfree(h->children);
|
36
|
-
/* unlink from parent */
|
37
|
-
oci8_unlink(h);
|
38
|
-
/* do free */
|
39
|
-
if (h->hp != NULL) {
|
40
|
-
if (h->type >= OCI_DTYPE_FIRST)
|
41
|
-
OCIDescriptorFree(h->hp, h->type);
|
42
|
-
else
|
43
|
-
OCIHandleFree(h->hp, h->type);
|
44
|
-
}
|
45
|
-
h->type = 0;
|
46
|
-
return;
|
47
|
-
}
|
48
|
-
|
49
|
-
/*
|
50
|
-
=begin
|
51
|
-
--- OCIHandle#attrSet(type, value)
|
52
|
-
:type
|
53
|
-
the type of attribute to be set.
|
54
|
-
See ((<Attributes of Handles and Descriptors>)).
|
55
|
-
:value
|
56
|
-
depends on ((|type|)).
|
57
|
-
|
58
|
-
correspond native OCI function: ((|OCIAttrSet|))
|
59
|
-
=end
|
60
|
-
*/
|
61
|
-
|
62
|
-
|
63
|
-
/*
|
64
|
-
=begin
|
65
|
-
--- OCIHandle#attrGet(type)
|
66
|
-
:type
|
67
|
-
the type of attribute.
|
68
|
-
See also ((<Attributes of Handles and Descriptors>)).
|
69
|
-
:return value
|
70
|
-
depends on ((|type|)).
|
71
|
-
|
72
|
-
correspond native OCI function: ((|OCIAttrGet|))
|
73
|
-
=end
|
74
|
-
*/
|
75
|
-
|
76
|
-
|
77
|
-
/*
|
78
|
-
=begin
|
79
|
-
--- OCIHandle#free()
|
80
|
-
explicitly free the OCI's data structure.
|
81
|
-
|
82
|
-
correspond native OCI function: ((|OCIHandleFree|))
|
83
|
-
=end
|
84
|
-
*/
|
85
|
-
VALUE oci8_handle_free(VALUE self)
|
86
|
-
{
|
87
|
-
oci8_handle_t *h;
|
88
|
-
|
89
|
-
Get_Handle(self, h);
|
90
|
-
oci8_handle_do_free(h);
|
91
|
-
return self;
|
92
|
-
}
|
93
|
-
|
94
|
-
void Init_oci8_handle(void)
|
95
|
-
{
|
96
|
-
rb_define_method(cOCIHandle, "free", oci8_handle_free, 0);
|
97
|
-
rb_define_method(cOCIHandle, "attrSet", oci8_attr_set, 2);
|
98
|
-
rb_define_method(cOCIHandle, "attrGet", oci8_attr_get, 1);
|
99
|
-
rb_define_singleton_method(cOCIHandle, "new", oci8_s_new, 0);
|
100
|
-
}
|
101
|
-
|
102
|
-
void oci8_handle_cleanup(oci8_handle_t *h)
|
103
|
-
{
|
104
|
-
oci8_handle_do_free(h);
|
105
|
-
xfree(h);
|
106
|
-
}
|
107
|
-
|
108
|
-
VALUE oci8_s_new(VALUE self)
|
109
|
-
{
|
110
|
-
rb_raise(rb_eNameError, "private method `new' called for %s:Class", rb_class2name(self));
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
static void oci8_handle_mark(oci8_handle_t *h)
|
115
|
-
{
|
116
|
-
oci8_bind_handle_t *bh;
|
117
|
-
unsigned int i;
|
118
|
-
|
119
|
-
switch (h->type) {
|
120
|
-
case OCI_HTYPE_SVCCTX:
|
121
|
-
for (i = 0;i < h->size;i++) {
|
122
|
-
if (h->children[i] != NULL) {
|
123
|
-
if (h->children[i]->type == OCI_HTYPE_SERVER || h->children[i]->type == OCI_HTYPE_SESSION) {
|
124
|
-
rb_gc_mark(h->children[i]->self);
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
break;
|
129
|
-
case OCI_HTYPE_STMT:
|
130
|
-
for (i = 0;i < h->size;i++) {
|
131
|
-
if (h->children[i] != NULL) {
|
132
|
-
if (h->children[i]->type == OCI_HTYPE_BIND || h->children[i]->type == OCI_HTYPE_DEFINE) {
|
133
|
-
rb_gc_mark(h->children[i]->self);
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
break;
|
138
|
-
case OCI_HTYPE_DEFINE:
|
139
|
-
case OCI_HTYPE_BIND:
|
140
|
-
bh = (oci8_bind_handle_t *)h;
|
141
|
-
if (bh->bind_type == BIND_HANDLE)
|
142
|
-
rb_gc_mark(bh->value.handle.v);
|
143
|
-
break;
|
144
|
-
}
|
145
|
-
if (h->parent != NULL) {
|
146
|
-
rb_gc_mark(h->parent->self);
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
oci8_handle_t *oci8_make_handle(ub4 type, dvoid *hp, OCIError *errhp, oci8_handle_t *parenth, sb4 value_sz)
|
151
|
-
{
|
152
|
-
VALUE obj;
|
153
|
-
oci8_handle_t *h;
|
154
|
-
oci8_bind_handle_t *bh;
|
155
|
-
|
156
|
-
switch (type) {
|
157
|
-
case OCI_HTYPE_ENV:
|
158
|
-
obj = Data_Make_Struct(cOCIEnv, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
159
|
-
break;
|
160
|
-
case OCI_HTYPE_SVCCTX:
|
161
|
-
obj = Data_Make_Struct(cOCISvcCtx, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
162
|
-
h->u.svcctx.pid = getpid();
|
163
|
-
break;
|
164
|
-
case OCI_HTYPE_STMT:
|
165
|
-
obj = Data_Make_Struct(cOCIStmt, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
166
|
-
rb_ivar_set(obj, oci8_id_define_array, Qnil);
|
167
|
-
rb_ivar_set(obj, oci8_id_bind_hash, Qnil);
|
168
|
-
break;
|
169
|
-
case OCI_HTYPE_SERVER:
|
170
|
-
obj = Data_Make_Struct(cOCIServer, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
171
|
-
break;
|
172
|
-
case OCI_HTYPE_SESSION:
|
173
|
-
obj = Data_Make_Struct(cOCISession, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
174
|
-
break;
|
175
|
-
case OCI_HTYPE_DESCRIBE:
|
176
|
-
obj = Data_Make_Struct(cOCIDescribe, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
177
|
-
break;
|
178
|
-
case OCI_DTYPE_LOB:
|
179
|
-
obj = Data_Make_Struct(cOCILobLocator, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
180
|
-
#ifndef OCI8_USE_CALLBACK_LOB_READ
|
181
|
-
h->u.lob_locator.char_width = 1;
|
182
|
-
#endif
|
183
|
-
break;
|
184
|
-
case OCI_DTYPE_FILE:
|
185
|
-
obj = Data_Make_Struct(cOCIFileLocator, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
186
|
-
#ifndef OCI8_USE_CALLBACK_LOB_READ
|
187
|
-
h->u.lob_locator.char_width = 1;
|
188
|
-
#endif
|
189
|
-
break;
|
190
|
-
case OCI_DTYPE_ROWID:
|
191
|
-
obj = Data_Make_Struct(cOCIRowid, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
192
|
-
break;
|
193
|
-
case OCI_DTYPE_PARAM:
|
194
|
-
obj = Data_Make_Struct(cOCIParam, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h);
|
195
|
-
h->u.param.is_implicit = 0;
|
196
|
-
break;
|
197
|
-
case OCI_HTYPE_BIND:
|
198
|
-
bh = xmalloc(sizeof(oci8_bind_handle_t) - sizeof(bh->value) + value_sz);
|
199
|
-
memset(bh, 0, sizeof(oci8_bind_handle_t) - sizeof(bh->value) + value_sz);
|
200
|
-
obj = Data_Wrap_Struct(cOCIBind, oci8_handle_mark, oci8_handle_cleanup, bh);
|
201
|
-
bh->bind_type = 0;
|
202
|
-
bh->ind = -1;
|
203
|
-
bh->rlen = value_sz;
|
204
|
-
bh->value_sz = value_sz;
|
205
|
-
h = (oci8_handle_t *)bh;
|
206
|
-
break;
|
207
|
-
case OCI_HTYPE_DEFINE:
|
208
|
-
bh = xmalloc(sizeof(oci8_bind_handle_t) - sizeof(bh->value) + value_sz);
|
209
|
-
memset(bh, 0, sizeof(oci8_bind_handle_t) - sizeof(bh->value) + value_sz);
|
210
|
-
obj = Data_Wrap_Struct(cOCIDefine, oci8_handle_mark, oci8_handle_cleanup, bh);
|
211
|
-
bh->bind_type = 0;
|
212
|
-
bh->ind = -1;
|
213
|
-
bh->rlen = value_sz;
|
214
|
-
bh->value_sz = value_sz;
|
215
|
-
h = (oci8_handle_t *)bh;
|
216
|
-
break;
|
217
|
-
default:
|
218
|
-
rb_bug("unsupported type %d in oci8_make_handle()", type);
|
219
|
-
}
|
220
|
-
h->type = type;
|
221
|
-
h->hp = hp;
|
222
|
-
h->errhp = errhp;
|
223
|
-
h->self = obj;
|
224
|
-
h->parent = NULL;
|
225
|
-
h->size = 0;
|
226
|
-
h->children = NULL;
|
227
|
-
oci8_link(parenth, h);
|
228
|
-
return h;
|
229
|
-
}
|
230
|
-
|
231
|
-
#define CHILDREN_ARRAY_GROW_SIZE 16
|
232
|
-
|
233
|
-
void oci8_link(oci8_handle_t *parent, oci8_handle_t *child)
|
234
|
-
{
|
235
|
-
unsigned int i;
|
236
|
-
int new_size, n;
|
237
|
-
|
238
|
-
if (parent == NULL)
|
239
|
-
return;
|
240
|
-
oci8_unlink(child);
|
241
|
-
child->parent = parent;
|
242
|
-
|
243
|
-
for (i = 0;i < parent->size;i++) {
|
244
|
-
if (parent->children[i] == NULL) {
|
245
|
-
parent->children[i] = child;
|
246
|
-
return;
|
247
|
-
}
|
248
|
-
}
|
249
|
-
new_size = parent->size + CHILDREN_ARRAY_GROW_SIZE;
|
250
|
-
parent->children = xrealloc(parent->children, sizeof(oci8_handle_t *) * new_size);
|
251
|
-
parent->children[parent->size] = child;
|
252
|
-
for (n = parent->size + 1;n < new_size;n++) {
|
253
|
-
parent->children[n] = NULL;
|
254
|
-
}
|
255
|
-
parent->size = new_size;
|
256
|
-
return;
|
257
|
-
}
|
258
|
-
|
259
|
-
void oci8_unlink(oci8_handle_t *self)
|
260
|
-
{
|
261
|
-
oci8_handle_t *parent = self->parent;
|
262
|
-
unsigned int i;
|
263
|
-
|
264
|
-
if (self->parent == NULL)
|
265
|
-
return;
|
266
|
-
for (i = 0;i < parent->size;i++) {
|
267
|
-
if (parent->children[i] == self) {
|
268
|
-
parent->children[i] = NULL;
|
269
|
-
self->parent = NULL;
|
270
|
-
return;
|
271
|
-
}
|
272
|
-
}
|
273
|
-
}
|