cubrid 9.2.0 → 9.3.0
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/README.rdoc +4 -5
- data/ext/build_cci.sh +1 -1
- data/ext/cci-src.tar.bz2 +0 -0
- data/ext/conn.c +10 -6
- data/ext/cubrid.c +1 -1
- data/ext/cubrid.h +70 -0
- data/ext/error.c +0 -0
- data/ext/extconf.rb +6 -0
- data/ext/stmt.c +38 -6
- metadata +5 -4
- data/ext/cci.bz2 +0 -0
data/README.rdoc
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
This is a Ruby Driver and ActiveRecord Adapter for CUBRID Database.
|
6
6
|
|
7
|
+
== Installation
|
7
8
|
== Installation
|
8
9
|
|
9
10
|
1. cd ext/
|
@@ -22,11 +23,9 @@ This is a Ruby Driver and ActiveRecord Adapter for CUBRID Database.
|
|
22
23
|
|
23
24
|
* Cross-platform.
|
24
25
|
|
25
|
-
* Compatible with CUBRID
|
26
|
-
|
27
|
-
* Compatible with Ruby 1.8.7.
|
26
|
+
* Compatible with CUBRID 9.3.0
|
28
27
|
|
29
|
-
* Ruby 1.
|
28
|
+
* Compatible with Ruby 1.8.x and 1.9.x
|
30
29
|
|
31
30
|
== Synopsis
|
32
31
|
|
@@ -36,7 +35,7 @@ Use Case:
|
|
36
35
|
|
37
36
|
#1: @con = Cubrid.connect('dbname')
|
38
37
|
#2: @con = Cubrid.connect('dbname', 'host', 'port', 'username', 'password')
|
39
|
-
@con = Cubrid.connect('demodb', '
|
38
|
+
@con = Cubrid.connect('demodb', 'test-db-server', 30000, 'public', '')
|
40
39
|
|
41
40
|
puts @con.server_version
|
42
41
|
|
data/ext/build_cci.sh
CHANGED
data/ext/cci-src.tar.bz2
ADDED
Binary file
|
data/ext/conn.c
CHANGED
@@ -56,13 +56,12 @@ cubrid_conn_new(char *host, int port, char *db, char *user, char *passwd)
|
|
56
56
|
{
|
57
57
|
VALUE conn;
|
58
58
|
Connection *c;
|
59
|
-
int handle;
|
59
|
+
int handle,res;
|
60
60
|
T_CCI_ERROR error;
|
61
61
|
|
62
62
|
handle = cci_connect_ex(host, port, db, user, passwd,&error);
|
63
63
|
if (handle < 0) {
|
64
64
|
cubrid_handle_error(handle, &error);
|
65
|
-
return Qnil;
|
66
65
|
}
|
67
66
|
|
68
67
|
conn = Data_Make_Struct(cConnection, Connection, 0, cubrid_conn_free, c);
|
@@ -72,7 +71,13 @@ cubrid_conn_new(char *host, int port, char *db, char *user, char *passwd)
|
|
72
71
|
c->port = port;
|
73
72
|
strcpy(c->db, db);
|
74
73
|
strcpy(c->user, user);
|
75
|
-
c->auto_commit =
|
74
|
+
c->auto_commit = Qtrue;
|
75
|
+
|
76
|
+
res = cci_set_autocommit(handle,CCI_AUTOCOMMIT_TRUE);
|
77
|
+
if (res < 0)
|
78
|
+
{
|
79
|
+
cubrid_handle_error (res, NULL);
|
80
|
+
}
|
76
81
|
|
77
82
|
return conn;
|
78
83
|
}
|
@@ -280,9 +285,8 @@ cubrid_conn_get_last_insert_id(VALUE self)
|
|
280
285
|
{
|
281
286
|
strncpy (ret, name, sizeof (ret) - 1);
|
282
287
|
}
|
283
|
-
|
284
|
-
return
|
285
|
-
|
288
|
+
|
289
|
+
return rb_cstr2inum(ret, 10);
|
286
290
|
}
|
287
291
|
|
288
292
|
|
data/ext/cubrid.c
CHANGED
@@ -175,7 +175,7 @@ void Init_cubrid()
|
|
175
175
|
rb_define_method(cStatement, "close", cubrid_stmt_close, 0); /* in stmt.c */
|
176
176
|
|
177
177
|
//error
|
178
|
-
cCubrid = rb_define_class("CUBRID", rb_cObject);
|
178
|
+
//cCubrid = rb_define_class("CUBRID", rb_cObject);
|
179
179
|
eCubrid = rb_define_class_under(cCubrid, "Error", rb_eStandardError);
|
180
180
|
|
181
181
|
}
|
data/ext/cubrid.h
CHANGED
@@ -34,6 +34,7 @@
|
|
34
34
|
|
35
35
|
#include "ruby.h"
|
36
36
|
#include "cas_cci.h"
|
37
|
+
#include "stdlib.h"
|
37
38
|
|
38
39
|
#define MAX_STR_LEN 255
|
39
40
|
|
@@ -48,6 +49,28 @@
|
|
48
49
|
#define CUBRID_ER_CREATE_TEMP_FILE -2010
|
49
50
|
#define CUBRID_ER_TRANSFER_FAIL -2011
|
50
51
|
|
52
|
+
/* Maximum length for the Cubrid data types.
|
53
|
+
*
|
54
|
+
* The max len of LOB is the max file size creatable in an external storage,
|
55
|
+
* so we ca't give the max len of LOB type, just use 1G. Please ignore it.
|
56
|
+
*/
|
57
|
+
#define MAX_CUBRID_CHAR_LEN 1073741823
|
58
|
+
#define MAX_LEN_INTEGER (10 + 1)
|
59
|
+
#define MAX_LEN_SMALLINT (5 + 1)
|
60
|
+
#define MAX_LEN_BIGINT (19 + 1)
|
61
|
+
#define MAX_LEN_FLOAT (14 + 1)
|
62
|
+
#define MAX_LEN_DOUBLE (28 + 1)
|
63
|
+
#define MAX_LEN_MONETARY (28 + 2)
|
64
|
+
#define MAX_LEN_DATE 10
|
65
|
+
#define MAX_LEN_TIME 8
|
66
|
+
#define MAX_LEN_TIMESTAMP 23
|
67
|
+
#define MAX_LEN_DATETIME MAX_LEN_TIMESTAMP
|
68
|
+
#define MAX_LEN_OBJECT MAX_CUBRID_CHAR_LEN
|
69
|
+
#define MAX_LEN_SET MAX_CUBRID_CHAR_LEN
|
70
|
+
#define MAX_LEN_MULTISET MAX_CUBRID_CHAR_LEN
|
71
|
+
#define MAX_LEN_SEQUENCE MAX_CUBRID_CHAR_LEN
|
72
|
+
#define MAX_LEN_LOB MAX_CUBRID_CHAR_LEN
|
73
|
+
|
51
74
|
typedef struct {
|
52
75
|
int handle;
|
53
76
|
char host[MAX_STR_LEN];
|
@@ -119,4 +142,51 @@ extern void cubrid_handle_error(int e, T_CCI_ERROR *error);
|
|
119
142
|
return (rtn); \
|
120
143
|
} \
|
121
144
|
} while(0)
|
145
|
+
|
146
|
+
typedef struct
|
147
|
+
{
|
148
|
+
char *type_name;
|
149
|
+
T_CCI_U_TYPE cubrid_u_type;
|
150
|
+
int len;
|
151
|
+
} DB_TYPE_INFO;
|
152
|
+
|
153
|
+
/* Define Cubrid supported date types */
|
154
|
+
static const DB_TYPE_INFO db_type_info[] = {
|
155
|
+
{"NULL", CCI_U_TYPE_NULL, 0},
|
156
|
+
{"UNKNOWN", CCI_U_TYPE_UNKNOWN, MAX_LEN_OBJECT},
|
157
|
+
|
158
|
+
{"CHAR", CCI_U_TYPE_CHAR, -1},
|
159
|
+
{"STRING", CCI_U_TYPE_STRING, -1},
|
160
|
+
{"NCHAR", CCI_U_TYPE_NCHAR, -1},
|
161
|
+
{"VARNCHAR", CCI_U_TYPE_VARNCHAR, -1},
|
162
|
+
|
163
|
+
{"BIT", CCI_U_TYPE_BIT, -1},
|
164
|
+
{"VARBIT", CCI_U_TYPE_VARBIT, -1},
|
165
|
+
|
166
|
+
{"NUMERIC", CCI_U_TYPE_NUMERIC, -1},
|
167
|
+
{"NUMBER", CCI_U_TYPE_NUMERIC, -1},
|
168
|
+
{"INT", CCI_U_TYPE_INT, MAX_LEN_INTEGER},
|
169
|
+
{"SHORT", CCI_U_TYPE_SHORT, MAX_LEN_SMALLINT},
|
170
|
+
{"BIGINT", CCI_U_TYPE_BIGINT, MAX_LEN_BIGINT},
|
171
|
+
{"MONETARY", CCI_U_TYPE_MONETARY, MAX_LEN_MONETARY},
|
172
|
+
|
173
|
+
{"FLOAT", CCI_U_TYPE_FLOAT, MAX_LEN_FLOAT},
|
174
|
+
{"DOUBLE", CCI_U_TYPE_DOUBLE, MAX_LEN_DOUBLE},
|
175
|
+
|
176
|
+
{"DATE", CCI_U_TYPE_DATE, MAX_LEN_DATE},
|
177
|
+
{"TIME", CCI_U_TYPE_TIME, MAX_LEN_TIME},
|
178
|
+
{"DATETIME", CCI_U_TYPE_DATETIME, MAX_LEN_DATETIME},
|
179
|
+
{"TIMESTAMP", CCI_U_TYPE_TIMESTAMP, MAX_LEN_TIMESTAMP},
|
180
|
+
|
181
|
+
{"SET", CCI_U_TYPE_SET, MAX_LEN_SET},
|
182
|
+
{"MULTISET", CCI_U_TYPE_MULTISET, MAX_LEN_MULTISET},
|
183
|
+
{"SEQUENCE", CCI_U_TYPE_SEQUENCE, MAX_LEN_SEQUENCE},
|
184
|
+
{"RESULTSET", CCI_U_TYPE_RESULTSET, -1},
|
185
|
+
|
186
|
+
{"OBJECT", CCI_U_TYPE_OBJECT, MAX_LEN_OBJECT},
|
187
|
+
{"BLOB", CCI_U_TYPE_BLOB, MAX_LEN_LOB},
|
188
|
+
{"CLOB", CCI_U_TYPE_CLOB, MAX_LEN_LOB},
|
189
|
+
{"ENUM",CCI_U_TYPE_ENUM,-1}
|
190
|
+
};
|
191
|
+
|
122
192
|
|
data/ext/error.c
CHANGED
File without changes
|
data/ext/extconf.rb
CHANGED
@@ -50,6 +50,12 @@ if RUBY_PLATFORM.include?"linux"
|
|
50
50
|
|
51
51
|
$INCFLAGS = ($INCFLAGS ? $INCFLAGS : "") + " -I" + cci_base_inc_path \
|
52
52
|
+" -I" + cci_cci_inc_path +" -I" + cci_broker_inc_path
|
53
|
+
|
54
|
+
if(ARGV[0] == "daily")
|
55
|
+
print "daily test"
|
56
|
+
$CPPFLAGS =($CPPFLAGS ? $CPPFLAGS : "") + " -fprofile-arcs -ftest-coverage"
|
57
|
+
$LDFLAGS =($LDFLAGS ? $LDFLAGS : "") + " -lgcov"
|
58
|
+
end
|
53
59
|
|
54
60
|
if !$LIBPATH
|
55
61
|
$LIBPATH = []
|
data/ext/stmt.c
CHANGED
@@ -34,6 +34,33 @@ extern VALUE cubrid_conn_end_tran(Connection *con, int type);
|
|
34
34
|
|
35
35
|
extern VALUE cStatement, cOid;
|
36
36
|
|
37
|
+
char*
|
38
|
+
get_type_name_by_u_type(T_CCI_COL_INFO * column_info)
|
39
|
+
{
|
40
|
+
int i,u_type;
|
41
|
+
int size = sizeof(db_type_info) / sizeof(db_type_info[0]);
|
42
|
+
char buf[64] = {'\0'};
|
43
|
+
int type_buf_len=63;
|
44
|
+
|
45
|
+
u_type = CCI_GET_COLLECTION_DOMAIN(column_info->type);
|
46
|
+
for (i = 0; i < size; i++) {
|
47
|
+
if (db_type_info[i].cubrid_u_type== u_type) {
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
if (CCI_IS_SET_TYPE(column_info->type)) {
|
53
|
+
snprintf(buf, type_buf_len, "set(%s)", db_type_info[i].type_name);
|
54
|
+
} else if (CCI_IS_MULTISET_TYPE(column_info->type)) {
|
55
|
+
snprintf(buf, type_buf_len, "multiset(%s)", db_type_info[i].type_name);
|
56
|
+
} else if (CCI_IS_SEQUENCE_TYPE(column_info->type)) {
|
57
|
+
snprintf(buf, type_buf_len, "sequence(%s)", db_type_info[i].type_name);
|
58
|
+
} else {
|
59
|
+
return db_type_info[i].type_name;
|
60
|
+
}
|
61
|
+
return buf;
|
62
|
+
}
|
63
|
+
|
37
64
|
void
|
38
65
|
cubrid_stmt_free(void *p)
|
39
66
|
{
|
@@ -193,7 +220,7 @@ cubrid_stmt_make_set(VALUE data, int u_type) /* TODO: check if all item has same
|
|
193
220
|
ind[i] = 1;
|
194
221
|
}
|
195
222
|
else {
|
196
|
-
str_ary[i] =
|
223
|
+
str_ary[i] =RSTRING_PTR(rb_ary_entry(data, i));// RSTRING(rb_ary_entry(data, i))->ptr;
|
197
224
|
ind[i] = 0;
|
198
225
|
}
|
199
226
|
}
|
@@ -316,7 +343,7 @@ cubrid_stmt_bind_internal(Statement *stmt, int index, VALUE data, int u_type, in
|
|
316
343
|
break;
|
317
344
|
|
318
345
|
case T_STRING:
|
319
|
-
str_val =
|
346
|
+
str_val = StringValueCStr(data);
|
320
347
|
a_type = CCI_A_TYPE_STR;
|
321
348
|
val = str_val;
|
322
349
|
if (u_type == CCI_U_TYPE_UNKNOWN) {
|
@@ -509,7 +536,6 @@ cubrid_stmt_execute(int argc, VALUE* argv, VALUE self)
|
|
509
536
|
stmt->affected_rows = row_count;
|
510
537
|
|
511
538
|
if(stmt->con->auto_commit == Qtrue && cubrid_stmt_is_auto_commitable(stmt->sql_type)) {
|
512
|
-
cubrid_stmt_close(self);
|
513
539
|
cubrid_conn_end_tran(stmt->con, CCI_TRAN_COMMIT);
|
514
540
|
}
|
515
541
|
|
@@ -527,7 +553,7 @@ cubrid_stmt_affected_rows(VALUE self)
|
|
527
553
|
|
528
554
|
GET_STMT_STRUCT(self, stmt);
|
529
555
|
CHECK_HANDLE(stmt, self);
|
530
|
-
|
556
|
+
|
531
557
|
return INT2NUM(stmt->affected_rows);
|
532
558
|
}
|
533
559
|
|
@@ -981,7 +1007,7 @@ cubrid_stmt_column_info(VALUE self)
|
|
981
1007
|
char col_name[MAX_STR_LEN];
|
982
1008
|
int datatype, precision, scale, nullable;
|
983
1009
|
Statement *stmt;
|
984
|
-
|
1010
|
+
char type_name[MAX_STR_LEN]={0};
|
985
1011
|
GET_STMT_STRUCT(self, stmt);
|
986
1012
|
CHECK_HANDLE(stmt, self);
|
987
1013
|
|
@@ -989,6 +1015,7 @@ cubrid_stmt_column_info(VALUE self)
|
|
989
1015
|
|
990
1016
|
for (i = 0; i < stmt->col_count; i++) {
|
991
1017
|
VALUE item;
|
1018
|
+
char* temp;
|
992
1019
|
|
993
1020
|
item = rb_hash_new();
|
994
1021
|
|
@@ -999,7 +1026,12 @@ cubrid_stmt_column_info(VALUE self)
|
|
999
1026
|
datatype = CCI_GET_RESULT_INFO_TYPE(stmt->col_info, i+1);
|
1000
1027
|
|
1001
1028
|
rb_hash_aset(item, rb_str_new2("name"), rb_str_new2(col_name));
|
1002
|
-
|
1029
|
+
|
1030
|
+
temp = get_type_name_by_u_type(&stmt->col_info[i]);
|
1031
|
+
memcpy(type_name,temp,strlen(temp));
|
1032
|
+
rb_hash_aset(item, rb_str_new2("type_name"), rb_str_new2(type_name));
|
1033
|
+
memset(type_name,0,strlen(temp));
|
1034
|
+
|
1003
1035
|
rb_hash_aset(item, rb_str_new2("precision"), INT2NUM(precision));
|
1004
1036
|
rb_hash_aset(item, rb_str_new2("scale"), INT2NUM(scale));
|
1005
1037
|
rb_hash_aset(item, rb_str_new2("nullable"), INT2NUM(nullable));
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cubrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This extension is a Ruby connector for CUBRID Database.
|
15
15
|
email: cubrid_ruby@nhncorp.com
|
@@ -26,10 +26,11 @@ files:
|
|
26
26
|
- ext/conn.c
|
27
27
|
- ext/stmt.c
|
28
28
|
- ext/error.c
|
29
|
-
- ext/cci.bz2
|
29
|
+
- ext/cci-src.tar.bz2
|
30
30
|
- ext/build_cci.sh
|
31
31
|
homepage: http://www.cubrid.org/cubrid_ruby_programming
|
32
|
-
licenses:
|
32
|
+
licenses:
|
33
|
+
- BSD
|
33
34
|
post_install_message:
|
34
35
|
rdoc_options:
|
35
36
|
- --title
|
data/ext/cci.bz2
DELETED
Binary file
|