cubrid 9.3.0 → 10.1.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.
- checksums.yaml +7 -0
- data/README.rdoc +6 -5
- data/ext/conn.c +42 -64
- data/ext/cubrid.c +197 -194
- data/ext/cubrid.h +98 -192
- data/ext/error.c +144 -151
- data/ext/extconf.rb +19 -58
- data/ext/stmt.c +1019 -1044
- metadata +32 -30
- data/ext/build_cci.sh +0 -19
- data/ext/cci-src.tar.bz2 +0 -0
data/ext/cubrid.h
CHANGED
@@ -1,192 +1,98 @@
|
|
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
|
-
#ifdef _WINDOWS
|
32
|
-
#pragma warning(disable:4312) /* type corecing */
|
33
|
-
#endif
|
34
|
-
|
35
|
-
#include "ruby.h"
|
36
|
-
#include "cas_cci.h"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#define
|
42
|
-
#define
|
43
|
-
#define
|
44
|
-
#define
|
45
|
-
#define
|
46
|
-
#define
|
47
|
-
#define
|
48
|
-
#define
|
49
|
-
#define
|
50
|
-
|
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
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
VALUE hash;
|
100
|
-
} Oid;
|
101
|
-
|
102
|
-
#ifdef MS_WINDOWS
|
103
|
-
#define CUBRID_LONG_LONG _int64
|
104
|
-
#else
|
105
|
-
#define CUBRID_LONG_LONG long long
|
106
|
-
#endif
|
107
|
-
|
108
|
-
//ifndef CCI_ER_END
|
109
|
-
//#define CCI_ER_END (-20100)
|
110
|
-
//#endif
|
111
|
-
|
112
|
-
|
113
|
-
#ifndef RSTRING_PTR
|
114
|
-
#define RSTRING_PTR(str) RSTRING(str)->ptr
|
115
|
-
#endif
|
116
|
-
|
117
|
-
#ifndef RSTRING_LEN
|
118
|
-
#define RSTRING_LEN(str) RSTRING(str)->len
|
119
|
-
#endif
|
120
|
-
|
121
|
-
#ifndef HAVE_RB_STR_SET_LEN
|
122
|
-
#define rb_str_set_len(str, length) (RSTRING_LEN(str) = (length))
|
123
|
-
#endif
|
124
|
-
|
125
|
-
VALUE GeteCubrid();
|
126
|
-
extern void cubrid_handle_error(int e, T_CCI_ERROR *error);
|
127
|
-
|
128
|
-
#define GET_CONN_STRUCT(self, con) Data_Get_Struct((self), Connection, (con))
|
129
|
-
#define CHECK_CONNECTION(con, rtn) \
|
130
|
-
do { \
|
131
|
-
if (!((con)->handle)) { \
|
132
|
-
cubrid_handle_error(CCI_ER_CON_HANDLE, NULL); \
|
133
|
-
return (rtn); \
|
134
|
-
} \
|
135
|
-
} while(0)
|
136
|
-
|
137
|
-
#define GET_STMT_STRUCT(self, stmt) Data_Get_Struct((self), Statement, (stmt))
|
138
|
-
#define CHECK_HANDLE(stmt, rtn) \
|
139
|
-
do { \
|
140
|
-
if (!((stmt)->handle)) { \
|
141
|
-
cubrid_handle_error(CCI_ER_REQ_HANDLE, NULL); \
|
142
|
-
return (rtn); \
|
143
|
-
} \
|
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
|
-
|
192
|
-
|
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
|
+
#ifdef _WINDOWS
|
32
|
+
#pragma warning(disable:4312) /* type corecing */
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#include "ruby.h"
|
36
|
+
#include "cas_cci.h"
|
37
|
+
|
38
|
+
#define MAX_STR_LEN 255
|
39
|
+
|
40
|
+
#define CUBRID_ER_INVALID_SQL_TYPE -2002
|
41
|
+
#define CUBRID_ER_CANNOT_GET_COLUMN_INFO -2003
|
42
|
+
#define CUBRID_ER_INIT_ARRAY_FAIL -2004
|
43
|
+
#define CUBRID_ER_UNKNOWN_TYPE -2005
|
44
|
+
#define CUBRID_ER_INVALID_PARAM -2006
|
45
|
+
#define CUBRID_ER_INVALID_ARRAY_TYPE -2007
|
46
|
+
#define CUBRID_ER_NOT_SUPPORTED_TYPE -2008
|
47
|
+
#define CUBRID_ER_OPEN_FILE -2009
|
48
|
+
#define CUBRID_ER_CREATE_TEMP_FILE -2010
|
49
|
+
#define CUBRID_ER_TRANSFER_FAIL -2011
|
50
|
+
|
51
|
+
typedef struct {
|
52
|
+
int handle;
|
53
|
+
char host[MAX_STR_LEN];
|
54
|
+
int port;
|
55
|
+
char db[MAX_STR_LEN];
|
56
|
+
char user[MAX_STR_LEN];
|
57
|
+
VALUE auto_commit;
|
58
|
+
} Connection;
|
59
|
+
|
60
|
+
typedef struct {
|
61
|
+
Connection *con;
|
62
|
+
int handle;
|
63
|
+
int affected_rows;
|
64
|
+
int col_count;
|
65
|
+
int param_cnt;
|
66
|
+
T_CCI_SQLX_CMD sql_type;
|
67
|
+
T_CCI_COL_INFO *col_info;
|
68
|
+
int bound;
|
69
|
+
} Statement;
|
70
|
+
|
71
|
+
typedef struct {
|
72
|
+
Connection *con;
|
73
|
+
char oid_str[MAX_STR_LEN];
|
74
|
+
int col_count;
|
75
|
+
VALUE col_type;
|
76
|
+
VALUE hash;
|
77
|
+
} Oid;
|
78
|
+
|
79
|
+
extern void cubrid_handle_error(int e, T_CCI_ERROR *error);
|
80
|
+
|
81
|
+
#define GET_CONN_STRUCT(self, con) Data_Get_Struct((self), Connection, (con))
|
82
|
+
#define CHECK_CONNECTION(con, rtn) \
|
83
|
+
do { \
|
84
|
+
if (!((con)->handle)) { \
|
85
|
+
cubrid_handle_error(CCI_ER_CON_HANDLE, NULL); \
|
86
|
+
return (rtn); \
|
87
|
+
} \
|
88
|
+
} while(0)
|
89
|
+
|
90
|
+
#define GET_STMT_STRUCT(self, stmt) Data_Get_Struct((self), Statement, (stmt))
|
91
|
+
#define CHECK_HANDLE(stmt, rtn) \
|
92
|
+
do { \
|
93
|
+
if (!((stmt)->handle)) { \
|
94
|
+
cubrid_handle_error(CCI_ER_REQ_HANDLE, NULL); \
|
95
|
+
return (rtn); \
|
96
|
+
} \
|
97
|
+
} while(0)
|
98
|
+
|
data/ext/error.c
CHANGED
@@ -1,151 +1,144 @@
|
|
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
|
-
static struct _error_message {
|
34
|
-
int err;
|
35
|
-
char* msg;
|
36
|
-
} cubrid_err_msgs[] = {
|
37
|
-
{-1, "CUBRID database error"},
|
38
|
-
{-2, "Invalid connection handle"},
|
39
|
-
{-3, "Memory allocation error"},
|
40
|
-
{-4, "Communication error"},
|
41
|
-
{-5, "No more data"},
|
42
|
-
{-6, "Unknown transaction type"},
|
43
|
-
{-7, "Invalid string parameter"},
|
44
|
-
{-8, "Type conversion error"},
|
45
|
-
{-9, "Parameter binding error"},
|
46
|
-
{-10, "Invalid type"},
|
47
|
-
{-11, "Parameter binding error"},
|
48
|
-
{-12, "Invalid database parameter name"},
|
49
|
-
{-13, "Invalid column index"},
|
50
|
-
{-14, "Invalid schema type"},
|
51
|
-
{-15, "File open error"},
|
52
|
-
{-16, "Connection error"},
|
53
|
-
{-17, "Connection handle creation error"},
|
54
|
-
{-18, "Invalid request handle"},
|
55
|
-
{-19, "Invalid cursor position"},
|
56
|
-
{-20, "Object is not valid"},
|
57
|
-
{-21, "CAS error"},
|
58
|
-
{-22, "Unknown host name"},
|
59
|
-
{-99, "Not implemented"},
|
60
|
-
{-1000, "Database connection error"},
|
61
|
-
{-1002, "Memory allocation error"},
|
62
|
-
{-1003, "Communication error"},
|
63
|
-
{-1004, "Invalid argument"},
|
64
|
-
{-1005, "Unknown transaction type"},
|
65
|
-
{-1007, "Parameter binding error"},
|
66
|
-
{-1008, "Parameter binding error"},
|
67
|
-
{-1009, "Cannot make DB_VALUE"},
|
68
|
-
{-1010, "Type conversion error"},
|
69
|
-
{-1011, "Invalid database parameter name"},
|
70
|
-
{-1012, "No more data"},
|
71
|
-
{-1013, "Object is not valid"},
|
72
|
-
{-1014, "File open error"},
|
73
|
-
{-1015, "Invalid schema type"},
|
74
|
-
{-1016, "Version mismatch"},
|
75
|
-
{-1017, "Cannot process the request. Try again later."},
|
76
|
-
{-1018, "Authorization error"},
|
77
|
-
{-1020, "The attribute domain must be the set type."},
|
78
|
-
{-1021, "The domain of a set must be the same data type."},
|
79
|
-
{-2001, "Memory allocation error"},
|
80
|
-
{-2002, "Invalid API call"},
|
81
|
-
{-2003, "Cannot get column info"},
|
82
|
-
{-2004, "Array initializing error"},
|
83
|
-
{-2005, "Unknown column type"},
|
84
|
-
{-2006, "Invalid parameter"},
|
85
|
-
{-2007, "Invalid array type"},
|
86
|
-
{-2008, "Invalid type"},
|
87
|
-
{-2009, "File open error"},
|
88
|
-
{-2010, "Temporary file open error"},
|
89
|
-
{-2011, "Glo transfering error"},
|
90
|
-
{0, "Unknown Error"}
|
91
|
-
};
|
92
|
-
|
93
|
-
static char *
|
94
|
-
get_error_msg(int err_code)
|
95
|
-
{
|
96
|
-
int i
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
char
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
if (e >
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
err_msg = buf;
|
146
|
-
}
|
147
|
-
|
148
|
-
sprintf(msg, "ERROR: %s, %d, %s", facility_msg, err_code, err_msg);
|
149
|
-
rb_raise(GeteCubrid(), msg);
|
150
|
-
}
|
151
|
-
|
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
|
+
static struct _error_message {
|
34
|
+
int err;
|
35
|
+
char* msg;
|
36
|
+
} cubrid_err_msgs[] = {
|
37
|
+
{-1, "CUBRID database error"},
|
38
|
+
{-2, "Invalid connection handle"},
|
39
|
+
{-3, "Memory allocation error"},
|
40
|
+
{-4, "Communication error"},
|
41
|
+
{-5, "No more data"},
|
42
|
+
{-6, "Unknown transaction type"},
|
43
|
+
{-7, "Invalid string parameter"},
|
44
|
+
{-8, "Type conversion error"},
|
45
|
+
{-9, "Parameter binding error"},
|
46
|
+
{-10, "Invalid type"},
|
47
|
+
{-11, "Parameter binding error"},
|
48
|
+
{-12, "Invalid database parameter name"},
|
49
|
+
{-13, "Invalid column index"},
|
50
|
+
{-14, "Invalid schema type"},
|
51
|
+
{-15, "File open error"},
|
52
|
+
{-16, "Connection error"},
|
53
|
+
{-17, "Connection handle creation error"},
|
54
|
+
{-18, "Invalid request handle"},
|
55
|
+
{-19, "Invalid cursor position"},
|
56
|
+
{-20, "Object is not valid"},
|
57
|
+
{-21, "CAS error"},
|
58
|
+
{-22, "Unknown host name"},
|
59
|
+
{-99, "Not implemented"},
|
60
|
+
{-1000, "Database connection error"},
|
61
|
+
{-1002, "Memory allocation error"},
|
62
|
+
{-1003, "Communication error"},
|
63
|
+
{-1004, "Invalid argument"},
|
64
|
+
{-1005, "Unknown transaction type"},
|
65
|
+
{-1007, "Parameter binding error"},
|
66
|
+
{-1008, "Parameter binding error"},
|
67
|
+
{-1009, "Cannot make DB_VALUE"},
|
68
|
+
{-1010, "Type conversion error"},
|
69
|
+
{-1011, "Invalid database parameter name"},
|
70
|
+
{-1012, "No more data"},
|
71
|
+
{-1013, "Object is not valid"},
|
72
|
+
{-1014, "File open error"},
|
73
|
+
{-1015, "Invalid schema type"},
|
74
|
+
{-1016, "Version mismatch"},
|
75
|
+
{-1017, "Cannot process the request. Try again later."},
|
76
|
+
{-1018, "Authorization error"},
|
77
|
+
{-1020, "The attribute domain must be the set type."},
|
78
|
+
{-1021, "The domain of a set must be the same data type."},
|
79
|
+
{-2001, "Memory allocation error"},
|
80
|
+
{-2002, "Invalid API call"},
|
81
|
+
{-2003, "Cannot get column info"},
|
82
|
+
{-2004, "Array initializing error"},
|
83
|
+
{-2005, "Unknown column type"},
|
84
|
+
{-2006, "Invalid parameter"},
|
85
|
+
{-2007, "Invalid array type"},
|
86
|
+
{-2008, "Invalid type"},
|
87
|
+
{-2009, "File open error"},
|
88
|
+
{-2010, "Temporary file open error"},
|
89
|
+
{-2011, "Glo transfering error"},
|
90
|
+
{0, "Unknown Error"}
|
91
|
+
};
|
92
|
+
|
93
|
+
static char *
|
94
|
+
get_error_msg(int err_code)
|
95
|
+
{
|
96
|
+
int i;
|
97
|
+
|
98
|
+
for(i = 0; ; i++) {
|
99
|
+
if (!cubrid_err_msgs[i].err || cubrid_err_msgs[i].err == err_code) {
|
100
|
+
return cubrid_err_msgs[i].msg;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
return NULL;
|
104
|
+
}
|
105
|
+
|
106
|
+
void
|
107
|
+
cubrid_handle_error(int e, T_CCI_ERROR *error)
|
108
|
+
{
|
109
|
+
int err_code;
|
110
|
+
char msg[1024];
|
111
|
+
char *err_msg = NULL, *facility_msg;
|
112
|
+
|
113
|
+
if (e == CCI_ER_DBMS) {
|
114
|
+
facility_msg = "DBMS";
|
115
|
+
if (error) {
|
116
|
+
err_code = error->err_code;
|
117
|
+
err_msg = error->err_msg;
|
118
|
+
} else {
|
119
|
+
err_code = 0;
|
120
|
+
err_msg = "Unknown DBMS Error";
|
121
|
+
}
|
122
|
+
} else {
|
123
|
+
err_msg = get_error_msg(e);
|
124
|
+
err_code = e;
|
125
|
+
|
126
|
+
if (e > -1000) {
|
127
|
+
facility_msg = "CCI";
|
128
|
+
} else if (e > -2000) {
|
129
|
+
facility_msg = "CAS";
|
130
|
+
} else if (e > -3000) {
|
131
|
+
facility_msg = "CLIENT";
|
132
|
+
} else {
|
133
|
+
facility_msg = "UNKNOWN";
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
if (!err_msg) {
|
138
|
+
err_msg = "Unknown Error";
|
139
|
+
}
|
140
|
+
|
141
|
+
sprintf(msg, "ERROR: %s, %d, %s", facility_msg, err_code, err_msg);
|
142
|
+
rb_raise(rb_eStandardError, msg);
|
143
|
+
}
|
144
|
+
|