cubrid 0.65 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/ext/build_cci.sh +19 -0
- data/ext/cci.bz2 +0 -0
- data/ext/conn.c +57 -39
- data/ext/cubrid.c +194 -197
- data/ext/cubrid.h +122 -98
- data/ext/error.c +151 -144
- data/ext/extconf.rb +52 -19
- data/ext/stmt.c +1012 -1019
- metadata +28 -31
- checksums.yaml +0 -7
data/README.rdoc
CHANGED
@@ -36,7 +36,7 @@ Use Case:
|
|
36
36
|
|
37
37
|
#1: @con = Cubrid.connect('dbname')
|
38
38
|
#2: @con = Cubrid.connect('dbname', 'host', 'port', 'username', 'password')
|
39
|
-
@con = Cubrid.connect('demodb', 'localhost',
|
39
|
+
@con = Cubrid.connect('demodb', 'localhost', 30000, 'public', '')
|
40
40
|
|
41
41
|
puts @con.server_version
|
42
42
|
|
data/ext/build_cci.sh
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
#echo "build_cci sh."
|
4
|
+
if [ -f cci-src/cci/.libs/libcascci.a ];then
|
5
|
+
# echo "libcascci.a exist."
|
6
|
+
exit 0
|
7
|
+
fi
|
8
|
+
|
9
|
+
tar xvjf cci.bz2
|
10
|
+
cd cci-src
|
11
|
+
chmod +x configure
|
12
|
+
chmod +x external/libregex38a/configure
|
13
|
+
if [ "$1" = 'x86' ];then
|
14
|
+
./configure
|
15
|
+
else
|
16
|
+
./configure --enable-64bit
|
17
|
+
fi
|
18
|
+
|
19
|
+
make
|
data/ext/cci.bz2
ADDED
Binary file
|
data/ext/conn.c
CHANGED
@@ -57,10 +57,11 @@ cubrid_conn_new(char *host, int port, char *db, char *user, char *passwd)
|
|
57
57
|
VALUE conn;
|
58
58
|
Connection *c;
|
59
59
|
int handle;
|
60
|
+
T_CCI_ERROR error;
|
60
61
|
|
61
|
-
handle =
|
62
|
+
handle = cci_connect_ex(host, port, db, user, passwd,&error);
|
62
63
|
if (handle < 0) {
|
63
|
-
cubrid_handle_error(handle,
|
64
|
+
cubrid_handle_error(handle, &error);
|
64
65
|
return Qnil;
|
65
66
|
}
|
66
67
|
|
@@ -79,7 +80,6 @@ cubrid_conn_new(char *host, int port, char *db, char *user, char *passwd)
|
|
79
80
|
/* call-seq:
|
80
81
|
* close() -> nil
|
81
82
|
*
|
82
|
-
* 데이터베이스와의 연결을 헤제합니다. 이 연결로부터 생성된 Statement도 모두 close됩니다.
|
83
83
|
*/
|
84
84
|
VALUE
|
85
85
|
cubrid_conn_close(VALUE self)
|
@@ -123,15 +123,6 @@ cubrid_conn_prepare_internal(int argc, VALUE* argv, VALUE self)
|
|
123
123
|
* prepare(sql <, option>) -> Statement
|
124
124
|
* prepare(sql <, option>) { |stmt| block } -> nil
|
125
125
|
*
|
126
|
-
* 주어진 SQL을 실행할 준비를 하고 Statement 객체를 반환합니다.
|
127
|
-
* SQL은 데이터베이스 서버로 보내져 파싱되어 실행할 수 있도록 준비됩니다.
|
128
|
-
*
|
129
|
-
* option으로 Cubrid::INCLUDE_OID를 줄 수 있는데, 이것은 SQL 실행 결과에 OID를 포함하도록 합니다.
|
130
|
-
* 실행 결과에 포함된 OID는 Statement.get_oid 메쏘드로 얻을 수 있습니다.
|
131
|
-
*
|
132
|
-
* block 주어지면 생성된 Statement 객체를 인수로 전달하여 block을 실행시킵니다.
|
133
|
-
* block의 수행이 끝나면 Statement 객체는 더이상 유효하지 않습니다.
|
134
|
-
*
|
135
126
|
* con = Cubrid.connect('demodb')
|
136
127
|
* stmt = con.prepare('SELECT * FROM db_user')
|
137
128
|
* stmt.execute
|
@@ -169,15 +160,6 @@ cubrid_conn_prepare(int argc, VALUE* argv, VALUE self)
|
|
169
160
|
* query(sql <, option>) -> Statement
|
170
161
|
* query(sql <, option>) { |row| block } -> nil
|
171
162
|
*
|
172
|
-
* 주어진 SQL을 실행할 준비를 하고 실행까지 시킨 후 Statement 객체를 반환합니다.
|
173
|
-
* 따라서 Statement.execute를 수행할 필요없이 바로 결과를 받아올 수 있습니다.
|
174
|
-
*
|
175
|
-
* option으로 Cubrid::INCLUDE_OID를 줄 수 있는데, 이것은 prepare 메쏘드의 그것과 동일합니다.
|
176
|
-
*
|
177
|
-
* block 주어지면 Statement.fetch를 호출하여 얻어온 결과를 인수로 전달하여 block을 실행시킵니다.
|
178
|
-
* block은 SQL 실행 결과로 넘어온 모든 row 대해서 한번씩 호출됩니다.
|
179
|
-
* block이 끝나면 Statement 객체는 더 이상 유효하지 않습니다.
|
180
|
-
*
|
181
163
|
* con = Cubrid.connect('demodb')
|
182
164
|
* stmt = con.query('SELECT * FROM db_user')
|
183
165
|
* while row = stmt.fetch
|
@@ -238,10 +220,6 @@ cubrid_conn_end_tran(Connection *con, int type)
|
|
238
220
|
|
239
221
|
/* call-seq:
|
240
222
|
* commit() -> nil
|
241
|
-
*
|
242
|
-
* 트랜잭션을 commit으로 종료합니다.
|
243
|
-
* 트랜잭션이 종료되면 이 연결로 부터 생성된 모든 Statement 객체도 모두 close 됩니다.
|
244
|
-
*
|
245
223
|
*/
|
246
224
|
VALUE
|
247
225
|
cubrid_conn_commit(VALUE self)
|
@@ -256,9 +234,6 @@ cubrid_conn_commit(VALUE self)
|
|
256
234
|
|
257
235
|
/* call-seq:
|
258
236
|
* rollback() -> nil
|
259
|
-
*
|
260
|
-
* 트랜잭션을 rollback으로 종료합니다.
|
261
|
-
* 트랜잭션이 종료되면 이 연결로 부터 생성된 모든 Statement 객체도 모두 close 됩니다.
|
262
237
|
*
|
263
238
|
*/
|
264
239
|
VALUE
|
@@ -271,13 +246,48 @@ cubrid_conn_rollback(VALUE self)
|
|
271
246
|
|
272
247
|
return Qnil;
|
273
248
|
}
|
249
|
+
/* call-seq:
|
250
|
+
* last_insert_id? -> last_insert_id
|
251
|
+
*
|
252
|
+
*/
|
253
|
+
|
254
|
+
VALUE
|
255
|
+
cubrid_conn_get_last_insert_id(VALUE self)
|
256
|
+
{
|
257
|
+
Connection *con;
|
258
|
+
char *name = NULL;
|
259
|
+
char ret[1024] = { '\0' };
|
260
|
+
int res;
|
261
|
+
T_CCI_ERROR error;
|
262
|
+
|
263
|
+
GET_CONN_STRUCT(self, con);
|
264
|
+
CHECK_CONNECTION(con, Qnil);
|
265
|
+
|
266
|
+
/* cci_last_id set last_id as allocated string */
|
267
|
+
res = cci_get_last_insert_id (con->handle, &name, &error);
|
268
|
+
|
269
|
+
if (res < 0)
|
270
|
+
{
|
271
|
+
cubrid_handle_error (res, &error);
|
272
|
+
return Qnil;
|
273
|
+
}
|
274
|
+
|
275
|
+
if (!name)
|
276
|
+
{
|
277
|
+
return Qnil;
|
278
|
+
}
|
279
|
+
else
|
280
|
+
{
|
281
|
+
strncpy (ret, name, sizeof (ret) - 1);
|
282
|
+
}
|
283
|
+
|
284
|
+
return rb_str_new2(ret);
|
285
|
+
|
286
|
+
}
|
287
|
+
|
274
288
|
|
275
289
|
/* call-seq:
|
276
290
|
* auto_commit? -> true or false
|
277
|
-
*
|
278
|
-
* Connection이 auto commit 모드인지 아닌지를 반환합니다.
|
279
|
-
* Connection은 기본적으로 auto commit 모드가 아니며, auto_commit= 메쏘드로 auto commit 여부를 설정할 수 있습니다.
|
280
|
-
*
|
281
291
|
*/
|
282
292
|
VALUE
|
283
293
|
cubrid_conn_get_auto_commit(VALUE self)
|
@@ -292,19 +302,30 @@ cubrid_conn_get_auto_commit(VALUE self)
|
|
292
302
|
|
293
303
|
/* call-seq:
|
294
304
|
* auto_commit= true or false -> nil
|
295
|
-
*
|
296
|
-
* Connection의 auto commit 모드를 설정합니다.
|
297
|
-
* auto commit이 true로 설정되면 Statement.execute의 실행이 끝난 후 바로 commit이 실행됩니다.
|
298
|
-
*
|
299
305
|
*/
|
300
306
|
VALUE
|
301
307
|
cubrid_conn_set_auto_commit(VALUE self, VALUE auto_commit)
|
302
308
|
{
|
303
309
|
Connection *con;
|
310
|
+
int res=0;
|
304
311
|
|
305
312
|
GET_CONN_STRUCT(self, con);
|
306
313
|
CHECK_CONNECTION(con, self);
|
307
314
|
|
315
|
+
if(auto_commit == Qtrue)
|
316
|
+
{
|
317
|
+
res = cci_set_autocommit(con->handle,CCI_AUTOCOMMIT_TRUE);
|
318
|
+
}
|
319
|
+
else
|
320
|
+
{
|
321
|
+
res = cci_set_autocommit(con->handle,CCI_AUTOCOMMIT_FALSE);
|
322
|
+
}
|
323
|
+
|
324
|
+
if (res < 0)
|
325
|
+
{
|
326
|
+
cubrid_handle_error (res, NULL);
|
327
|
+
return Qnil;
|
328
|
+
}
|
308
329
|
con->auto_commit = auto_commit;
|
309
330
|
return Qnil;
|
310
331
|
}
|
@@ -312,7 +333,6 @@ cubrid_conn_set_auto_commit(VALUE self, VALUE auto_commit)
|
|
312
333
|
/* call-seq:
|
313
334
|
* to_s() -> string
|
314
335
|
*
|
315
|
-
* Connection의 현재 연결 정보를 문자열로 반환합니다.
|
316
336
|
*/
|
317
337
|
VALUE
|
318
338
|
cubrid_conn_to_s(VALUE self)
|
@@ -328,8 +348,6 @@ cubrid_conn_to_s(VALUE self)
|
|
328
348
|
|
329
349
|
/* call-seq:
|
330
350
|
* server_version() -> string
|
331
|
-
*
|
332
|
-
* 연결된 서버의 버전을 문자열로 반환합니다.
|
333
351
|
*/
|
334
352
|
VALUE
|
335
353
|
cubrid_conn_server_version(VALUE self)
|
data/ext/cubrid.c
CHANGED
@@ -1,197 +1,194 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
|
3
|
-
*
|
4
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
5
|
-
* are permitted provided that the following conditions are met:
|
6
|
-
*
|
7
|
-
* - Redistributions of source code must retain the above copyright notice,
|
8
|
-
* this list of conditions and the following disclaimer.
|
9
|
-
*
|
10
|
-
* - Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
* this list of conditions and the following disclaimer in the documentation
|
12
|
-
* and/or other materials provided with the distribution.
|
13
|
-
*
|
14
|
-
* - Neither the name of the <ORGANIZATION> nor the names of its contributors
|
15
|
-
* may be used to endorse or promote products derived from this software without
|
16
|
-
* specific prior written permission.
|
17
|
-
*
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
19
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
21
|
-
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
22
|
-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
23
|
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
24
|
-
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
25
|
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
27
|
-
* OF SUCH DAMAGE.
|
28
|
-
*
|
29
|
-
*/
|
30
|
-
|
31
|
-
#include "cubrid.h"
|
32
|
-
|
33
|
-
char *cci_client_name = "CCI"; /* for lower than 7.0 */
|
34
|
-
VALUE cCubrid, cConnection, cStatement, cOid;
|
35
|
-
extern VALUE cubrid_conn_new(char *host, int port, char *db, char *user, char *passwd);
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
*
|
44
|
-
*
|
45
|
-
*
|
46
|
-
*
|
47
|
-
* con
|
48
|
-
*
|
49
|
-
*
|
50
|
-
* con
|
51
|
-
*
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
extern VALUE
|
82
|
-
extern VALUE
|
83
|
-
extern VALUE
|
84
|
-
extern VALUE
|
85
|
-
extern VALUE
|
86
|
-
extern VALUE
|
87
|
-
extern VALUE
|
88
|
-
|
89
|
-
|
90
|
-
extern VALUE
|
91
|
-
|
92
|
-
|
93
|
-
extern VALUE
|
94
|
-
extern VALUE
|
95
|
-
extern VALUE
|
96
|
-
extern VALUE
|
97
|
-
extern VALUE
|
98
|
-
extern VALUE
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
*
|
106
|
-
*
|
107
|
-
* *
|
108
|
-
*
|
109
|
-
*
|
110
|
-
*
|
111
|
-
*
|
112
|
-
* stmt.
|
113
|
-
*
|
114
|
-
*
|
115
|
-
*
|
116
|
-
*
|
117
|
-
*
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
rb_define_const(cCubrid, "
|
127
|
-
rb_define_const(cCubrid, "
|
128
|
-
rb_define_const(cCubrid, "
|
129
|
-
rb_define_const(cCubrid, "
|
130
|
-
rb_define_const(cCubrid, "
|
131
|
-
rb_define_const(cCubrid, "
|
132
|
-
rb_define_const(cCubrid, "
|
133
|
-
rb_define_const(cCubrid, "
|
134
|
-
rb_define_const(cCubrid, "
|
135
|
-
rb_define_const(cCubrid, "
|
136
|
-
rb_define_const(cCubrid, "
|
137
|
-
rb_define_const(cCubrid, "
|
138
|
-
rb_define_const(cCubrid, "
|
139
|
-
rb_define_const(cCubrid, "
|
140
|
-
rb_define_const(cCubrid, "
|
141
|
-
rb_define_const(cCubrid, "
|
142
|
-
rb_define_const(cCubrid, "
|
143
|
-
rb_define_const(cCubrid, "
|
144
|
-
|
145
|
-
rb_define_const(cCubrid, "
|
146
|
-
rb_define_const(cCubrid, "
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
rb_define_method(cConnection, "
|
155
|
-
rb_define_method(cConnection, "
|
156
|
-
rb_define_method(cConnection, "
|
157
|
-
rb_define_method(cConnection, "
|
158
|
-
rb_define_method(cConnection, "
|
159
|
-
rb_define_method(cConnection, "
|
160
|
-
|
161
|
-
/*
|
162
|
-
|
163
|
-
rb_define_method(
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
rb_define_method(cStatement, "
|
168
|
-
rb_define_method(cStatement, "
|
169
|
-
rb_define_method(cStatement, "
|
170
|
-
rb_define_method(cStatement, "
|
171
|
-
rb_define_method(cStatement, "
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
/*
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
/* Document-class: Cubrid::Oid
|
184
|
-
*
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
schema infomation
|
196
|
-
*/
|
197
|
-
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
|
3
|
+
*
|
4
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
* are permitted provided that the following conditions are met:
|
6
|
+
*
|
7
|
+
* - Redistributions of source code must retain the above copyright notice,
|
8
|
+
* this list of conditions and the following disclaimer.
|
9
|
+
*
|
10
|
+
* - Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer in the documentation
|
12
|
+
* and/or other materials provided with the distribution.
|
13
|
+
*
|
14
|
+
* - Neither the name of the <ORGANIZATION> nor the names of its contributors
|
15
|
+
* may be used to endorse or promote products derived from this software without
|
16
|
+
* specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
19
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
21
|
+
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
22
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
23
|
+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
24
|
+
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
25
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
27
|
+
* OF SUCH DAMAGE.
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
|
31
|
+
#include "cubrid.h"
|
32
|
+
|
33
|
+
char *cci_client_name = "CCI"; /* for lower than 7.0 */
|
34
|
+
VALUE cCubrid, cConnection, cStatement, cOid,eCubrid,cCubrid;
|
35
|
+
extern VALUE cubrid_conn_new(char *host, int port, char *db, char *user, char *passwd);
|
36
|
+
|
37
|
+
VALUE GeteCubrid()
|
38
|
+
{
|
39
|
+
return eCubrid;
|
40
|
+
}
|
41
|
+
|
42
|
+
/* call-seq:
|
43
|
+
* connect(db, host, port, user, password) -> Connection
|
44
|
+
*
|
45
|
+
*
|
46
|
+
* con = Cubrid.connect('demodb', '192.168.1.1', '33000', 'foo','bar')
|
47
|
+
* con.to_s #=> host: 192.168.1.1, port: 33000, db: demodb, user: foo
|
48
|
+
*
|
49
|
+
* con = Cubrid.connect('subway')
|
50
|
+
* con.to_s #=> host: localhost, port: 30000, db: subway, user: PUBLIC
|
51
|
+
*
|
52
|
+
* con = Cubrid.connect('subway', '192.168.1.2')
|
53
|
+
* con.to_s #=> host: 192.168.1.2, port: 33000, db: subway, user: PUBLIC
|
54
|
+
*/
|
55
|
+
VALUE cubrid_connect(int argc, VALUE* argv, VALUE self)
|
56
|
+
{
|
57
|
+
VALUE host, port, db, user, passwd;
|
58
|
+
|
59
|
+
rb_scan_args(argc, argv, "14", &db, &host, &port, &user, &passwd);
|
60
|
+
|
61
|
+
if (NIL_P(db))
|
62
|
+
rb_raise(rb_eStandardError, "DB name is required.");
|
63
|
+
|
64
|
+
if (NIL_P(host))
|
65
|
+
host = rb_str_new2("localhost");
|
66
|
+
|
67
|
+
if (NIL_P(port))
|
68
|
+
port = INT2NUM(30000);
|
69
|
+
|
70
|
+
if (NIL_P(user))
|
71
|
+
user = rb_str_new2("PUBLIC");
|
72
|
+
|
73
|
+
if (NIL_P(passwd))
|
74
|
+
passwd = rb_str_new2("");
|
75
|
+
|
76
|
+
return cubrid_conn_new(StringValueCStr(host), NUM2INT(port),
|
77
|
+
StringValueCStr(db), StringValueCStr(user), StringValueCStr(passwd));
|
78
|
+
}
|
79
|
+
|
80
|
+
/* from conn.c */
|
81
|
+
extern VALUE cubrid_conn_close(VALUE self);
|
82
|
+
extern VALUE cubrid_conn_prepare(int argc, VALUE* argv, VALUE self);
|
83
|
+
extern VALUE cubrid_conn_query(int argc, VALUE* argv, VALUE self);
|
84
|
+
extern VALUE cubrid_conn_commit(VALUE self);
|
85
|
+
extern VALUE cubrid_conn_rollback(VALUE self);
|
86
|
+
extern VALUE cubrid_conn_get_auto_commit(VALUE self);
|
87
|
+
extern VALUE cubrid_conn_get_last_insert_id(VALUE self);
|
88
|
+
extern VALUE cubrid_conn_set_auto_commit(VALUE self, VALUE auto_commit);
|
89
|
+
extern VALUE cubrid_conn_to_s(VALUE self);
|
90
|
+
extern VALUE cubrid_conn_server_version(VALUE self);
|
91
|
+
|
92
|
+
/* from stmt.c */
|
93
|
+
extern VALUE cubrid_stmt_close(VALUE self);
|
94
|
+
extern VALUE cubrid_stmt_bind(int argc, VALUE* argv, VALUE self);
|
95
|
+
extern VALUE cubrid_stmt_execute(int argc, VALUE* argv, VALUE self);
|
96
|
+
extern VALUE cubrid_stmt_affected_rows(VALUE self);
|
97
|
+
extern VALUE cubrid_stmt_fetch(VALUE self);
|
98
|
+
extern VALUE cubrid_stmt_fetch_hash(VALUE self);
|
99
|
+
extern VALUE cubrid_stmt_each(VALUE self);
|
100
|
+
extern VALUE cubrid_stmt_each_hash(VALUE self);
|
101
|
+
extern VALUE cubrid_stmt_column_info(VALUE self);
|
102
|
+
|
103
|
+
|
104
|
+
/* CUBRID[http://www.cubrid.com] ruby driver
|
105
|
+
*
|
106
|
+
*
|
107
|
+
* * Connection
|
108
|
+
* * Statement
|
109
|
+
* * Oid
|
110
|
+
*
|
111
|
+
* con = Cubrid.connect('demodb', '192.168.1.1', '33000', 'foo','bar')
|
112
|
+
* stmt = con.prepare('SELECT * FROM db_user')
|
113
|
+
* stmt.execute
|
114
|
+
* stmt.each { |row|
|
115
|
+
* print row
|
116
|
+
* }
|
117
|
+
* stmt.close
|
118
|
+
* con.close
|
119
|
+
*
|
120
|
+
*/
|
121
|
+
void Init_cubrid()
|
122
|
+
{
|
123
|
+
cCubrid = rb_define_module("Cubrid");
|
124
|
+
rb_define_module_function(cCubrid, "connect", cubrid_connect, -1);
|
125
|
+
|
126
|
+
rb_define_const(cCubrid, "CHAR", INT2NUM(CCI_U_TYPE_CHAR));
|
127
|
+
rb_define_const(cCubrid, "VARCHAR", INT2NUM(CCI_U_TYPE_STRING));
|
128
|
+
rb_define_const(cCubrid, "STRING", INT2NUM(CCI_U_TYPE_STRING));
|
129
|
+
rb_define_const(cCubrid, "NCHAR", INT2NUM(CCI_U_TYPE_NCHAR));
|
130
|
+
rb_define_const(cCubrid, "VARNCHAR", INT2NUM(CCI_U_TYPE_VARNCHAR));
|
131
|
+
rb_define_const(cCubrid, "BIT", INT2NUM(CCI_U_TYPE_BIT));
|
132
|
+
rb_define_const(cCubrid, "VARBIT", INT2NUM(CCI_U_TYPE_VARBIT));
|
133
|
+
rb_define_const(cCubrid, "NUMERIC", INT2NUM(CCI_U_TYPE_NUMERIC));
|
134
|
+
rb_define_const(cCubrid, "INT", INT2NUM(CCI_U_TYPE_INT));
|
135
|
+
rb_define_const(cCubrid, "BIGINT", INT2NUM(CCI_U_TYPE_BIGINT));
|
136
|
+
rb_define_const(cCubrid, "SHORT", INT2NUM(CCI_U_TYPE_SHORT));
|
137
|
+
rb_define_const(cCubrid, "MONETARY", INT2NUM(CCI_U_TYPE_MONETARY));
|
138
|
+
rb_define_const(cCubrid, "FLOAT", INT2NUM(CCI_U_TYPE_FLOAT));
|
139
|
+
rb_define_const(cCubrid, "DOUBLE", INT2NUM(CCI_U_TYPE_DOUBLE));
|
140
|
+
rb_define_const(cCubrid, "DATE", INT2NUM(CCI_U_TYPE_DATE));
|
141
|
+
rb_define_const(cCubrid, "TIME", INT2NUM(CCI_U_TYPE_TIME));
|
142
|
+
rb_define_const(cCubrid, "TIMESTAMP", INT2NUM(CCI_U_TYPE_TIMESTAMP));
|
143
|
+
rb_define_const(cCubrid, "SET", INT2NUM(CCI_U_TYPE_SET));
|
144
|
+
rb_define_const(cCubrid, "MULTISET", INT2NUM(CCI_U_TYPE_MULTISET));
|
145
|
+
rb_define_const(cCubrid, "SEQUENCE", INT2NUM(CCI_U_TYPE_SEQUENCE));
|
146
|
+
rb_define_const(cCubrid, "OBJECT", INT2NUM(CCI_U_TYPE_OBJECT));
|
147
|
+
|
148
|
+
rb_define_const(cCubrid, "INCLUDE_OID", INT2NUM(CCI_PREPARE_INCLUDE_OID));
|
149
|
+
rb_define_const(cCubrid, "READ_LOCK", INT2NUM(CCI_OID_LOCK_READ));
|
150
|
+
rb_define_const(cCubrid, "WRITE_LOCK", INT2NUM(CCI_OID_LOCK_WRITE));
|
151
|
+
|
152
|
+
/* connection */
|
153
|
+
cConnection = rb_define_class_under(cCubrid, "Connection", rb_cObject);
|
154
|
+
rb_define_method(cConnection, "close", cubrid_conn_close, 0); /* in conn.c */
|
155
|
+
rb_define_method(cConnection, "commit", cubrid_conn_commit, 0); /* in conn.c */
|
156
|
+
rb_define_method(cConnection, "rollback", cubrid_conn_rollback, 0); /* in conn.c */
|
157
|
+
rb_define_method(cConnection, "prepare", cubrid_conn_prepare, -1); /* in conn.c */
|
158
|
+
rb_define_method(cConnection, "query", cubrid_conn_query, -1); /* in conn.c */
|
159
|
+
rb_define_method(cConnection, "auto_commit?", cubrid_conn_get_auto_commit, 0); /* in conn.c */
|
160
|
+
rb_define_method(cConnection, "last_insert_id", cubrid_conn_get_last_insert_id, 0); /* in conn.c */
|
161
|
+
rb_define_method(cConnection, "auto_commit=", cubrid_conn_set_auto_commit, 1); /* in conn.c */
|
162
|
+
rb_define_method(cConnection, "to_s", cubrid_conn_to_s, 0); /* in conn.c */
|
163
|
+
rb_define_method(cConnection, "server_version", cubrid_conn_server_version, 0); /* in conn.c */
|
164
|
+
|
165
|
+
/* statement */
|
166
|
+
cStatement = rb_define_class_under(cCubrid, "Statement", rb_cObject);
|
167
|
+
rb_define_method(cStatement, "bind", cubrid_stmt_bind, -1); /* in stmt.c */
|
168
|
+
rb_define_method(cStatement, "execute", cubrid_stmt_execute, -1); /* in stmt.c */
|
169
|
+
rb_define_method(cStatement, "affected_rows", cubrid_stmt_affected_rows, 0); /* in stmt.c */
|
170
|
+
rb_define_method(cStatement, "column_info", cubrid_stmt_column_info, 0); /* in stmt.c */
|
171
|
+
rb_define_method(cStatement, "fetch", cubrid_stmt_fetch, 0); /* in stmt.c */
|
172
|
+
rb_define_method(cStatement, "fetch_hash", cubrid_stmt_fetch_hash, 0); /* in stmt.c */
|
173
|
+
rb_define_method(cStatement, "each", cubrid_stmt_each, 0); /* in stmt.c */
|
174
|
+
rb_define_method(cStatement, "each_hash", cubrid_stmt_each_hash, 0); /* in stmt.c */
|
175
|
+
rb_define_method(cStatement, "close", cubrid_stmt_close, 0); /* in stmt.c */
|
176
|
+
|
177
|
+
//error
|
178
|
+
cCubrid = rb_define_class("CUBRID", rb_cObject);
|
179
|
+
eCubrid = rb_define_class_under(cCubrid, "Error", rb_eStandardError);
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
/* Document-class: Cubrid::Oid
|
184
|
+
*
|
185
|
+
*/
|
186
|
+
|
187
|
+
/* TODO:
|
188
|
+
bind method & stored procedure
|
189
|
+
save point
|
190
|
+
db parameter : isolation level, max result count, lock time out, ..
|
191
|
+
glo : load to buffer, save from buffer, performance task
|
192
|
+
schema infomation
|
193
|
+
*/
|
194
|
+
|