CUBRID Engine  latest
db_stub.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * db_stub.h - cubrid api header file.
22  */
23 
24 #ifndef _DB_STUB_H_
25 #define _DB_STUB_H_
26 
27 #include "config.h"
28 
29 #include <stddef.h>
30 #include <stdlib.h>
31 #include "api_common.h"
32 #include "parser.h"
33 #include "dbdef.h"
34 #include "error_manager.h"
35 #include "transaction_cl.h"
36 #include "parse_tree.h" /* TODO: remove */
37 #include "system_parameter.h"
38 #include "api_compat.h"
39 
40 #define api_er_set(a,b,c,d) er_set(a,b,c,d)
41 #define api_get_errmsg() er_msg()
42 #define api_get_errid er_errid
43 
44 #define HAS_RESULT(stmt_type) (stmt_type == CUBRID_STMT_SELECT || \
45  stmt_type == CUBRID_STMT_CALL || \
46  stmt_type == CUBRID_STMT_GET_ISO_LVL || \
47  stmt_type == CUBRID_STMT_GET_TIMEOUT || \
48  stmt_type == CUBRID_STMT_GET_OPT_LVL || \
49  stmt_type == CUBRID_STMT_GET_STATS || \
50  stmt_type == CUBRID_STMT_EVALUATE)
51 
52 
53 
54 #define VERSION_LENGTH 32
55 
58 
61 
65 
70 typedef struct rs_meta_info RS_META_INFO;
72 
74 {
79  bool autocommit;
80  char *host;
81  short int port;
82 };
83 
85 {
91  bool lazy_exec;
92 };
93 
95 {
97  int err_code;
98  int line;
99  int column;
100  char *err_msg;
101 };
102 
103 /* connection structure */
104 struct ci_conn_s
105 {
110  char **host;
111  short int port;
113  char *username;
115 
116  /* for autocommit */
119 };
120 
122 {
126 };
127 
128 /* statement structure */
130 {
134 };
135 
137 {
139  union _data
140  {
143  } data;
144  size_t query_length;
145 };
146 
148 {
150  int err_code;
151  char *err_msg;
152 };
153 
155 {
158  int rs_count;
159 };
160 
161 struct ci_stmt_s
162 {
175 
176  /* for batch result */
180 };
181 
183 {
187  int stmt_idx;
192 };
193 
195 {
199  /* session's query_type[x] if prepared, */
200  /* else resultset's result->query_type */
201  int stmt_idx;
203 };
204 
206 {
212 };
213 
214 #if !defined(WINDOWS)
215 extern void (*prev_sigfpe_handler) (int);
216 
217 extern void sigfpe_handler (int sig);
218 #endif
219 
220 extern int db_type_to_type (DB_TYPE dt, CI_TYPE * xt);
221 extern int type_to_db_type (CI_TYPE xt, DB_TYPE * dt);
222 extern void xoid2oid (CI_OID * xoid, OID * oid);
223 extern void oid2xoid (OID * oid, BIND_HANDLE conn, CI_OID * xoid);
224 extern int coerce_value_to_db_value (CI_TYPE type, void *addr, size_t len, DB_VALUE * dbval, bool domain_initialized);
225 extern int coerce_db_value_to_value (const DB_VALUE * dbval, BIND_HANDLE conn, CI_TYPE type, void *addr, size_t len,
226  size_t * outlen, bool * isnull);
227 
228 extern int create_db_value_bind_table (int nvalue, void *impl, int auto_apply, BIND_HANDLE conn_handle,
229  int (*get_index_by_name) (void *, const char *, int *ri),
230  int (*get_db_value) (void *, int, DB_VALUE *), int (*set_db_value) (void *, int,
231  DB_VALUE *),
232  int (*init_domain) (void *, int, DB_VALUE *), VALUE_BIND_TABLE ** rtable);
233 
234 /* api_object.c */
236 /* api_collection.c */
238 extern int api_collection_set_to_db_value (API_COLLECTION * col, DB_VALUE * val);
239 extern int api_collection_create (BIND_HANDLE conn, API_COLLECTION ** rc);
240 extern int ci_err_set (int error_code);
241 
242 #endif /* _DB_STUB_H_ */
COMMON_API_STRUCTURE_HEADER
Definition: db_stub.h:163
CI_BATCH_RESULT_INFO * rs_info
Definition: db_stub.h:157
int api_collection_set_to_db_value(API_COLLECTION *col, DB_VALUE *val)
enum ci_conn_status CI_CONN_STATUS
Definition: api_common.h:79
RS_META_INFO metainfo
Definition: db_stub.h:149
DB_VALUE * val
Definition: db_stub.h:142
bool hold_cursors_over_commit
Definition: db_stub.h:86
void xoid2oid(CI_OID *xoid, OID *oid)
int current_err_idx
Definition: db_stub.h:171
bool * param_value_is_set
Definition: db_stub.h:174
CI_RESULTSET_STRUCTURE * rs
Definition: db_stub.h:132
DB_TYPE
Definition: dbtype_def.h:670
void oid2xoid(OID *oid, BIND_HANDLE conn, CI_OID *xoid)
bool autocommit
Definition: db_stub.h:79
CI_RESULTSET_META_STRUCTURE * rsmeta
Definition: db_stub.h:133
char * username
Definition: db_stub.h:113
void(* prev_sigfpe_handler)(int)
Definition: db_admin.c:70
DB_VALUE * param_val
Definition: db_stub.h:167
CUBRID_STMT_TYPE sql_type
Definition: db_stub.h:123
int ci_err_set(int error_code)
Definition: db_stub.c:3064
STMT_RESULT_INFO * rs_info
Definition: db_stub.h:169
bool need_immediate_commit
Definition: db_stub.h:118
CI_CONN_STATUS conn_status
Definition: db_stub.h:108
CI_RESULTSET_META_STRUCTURE * prsmeta
Definition: db_stub.h:188
API_OBJECT_RESULTSET_POOL * opool
Definition: db_stub.h:114
bool lazy_exec
Definition: db_stub.h:91
bool async_query
Definition: db_stub.h:89
bool current_row_isdeleted
Definition: db_stub.h:191
BH_INTERFACE * bh_interface
Definition: db_stub.h:197
int batch_count
Definition: db_stub.h:177
bool exec_continue_on_error
Definition: db_stub.h:90
bool has_result
Definition: db_stub.h:124
char cli_version[VERSION_LENGTH]
Definition: db_stub.h:75
short int port
Definition: db_stub.h:111
int api_collection_create_from_db_value(BIND_HANDLE conn, const DB_VALUE *val, API_COLLECTION **rc)
char ** host
Definition: db_stub.h:110
int type_to_db_type(CI_TYPE xt, DB_TYPE *dt)
int db_type_to_type(DB_TYPE dt, CI_TYPE *xt)
CI_PARAM_META_STRUCTURE * ppmeta
Definition: db_stub.h:173
STMT_ERROR_INFO * next
Definition: db_stub.h:96
int api_collection_create(BIND_HANDLE conn, API_COLLECTION **rc)
char * host
Definition: db_stub.h:80
CI_CONN_STRUCTURE * pconn
Definition: db_stub.h:168
DB_TRAN_ISOLATION
Definition: dbtran_def.h:26
COMMON_RESULTSET_HEADER
Definition: db_stub.h:184
DB_SESSION * session
Definition: db_stub.h:166
RS_META_INFO metainfo
Definition: db_stub.h:131
DB_MARKER * marker
Definition: db_stub.h:209
BH_INTERFACE * bh_interface
Definition: db_stub.h:208
CI_BATCH_DATA * batch_data
Definition: db_stub.h:178
#define VERSION_LENGTH
Definition: db_stub.h:54
STMT_ERROR_INFO * err_info
Definition: db_stub.h:170
bool * is_out_param
Definition: db_stub.h:210
CI_STMT_STATUS stmt_status
Definition: db_stub.h:165
int lock_timeout
Definition: db_stub.h:77
COMMON_API_STRUCTURE_HEADER
Definition: db_stub.h:106
enum ci_stmt_status CI_STMT_STATUS
Definition: api_common.h:92
static int rc
Definition: serial.c:50
CUBRID_STMT_TYPE
Definition: cas_dbms_util.h:40
bool current_row_isupdated
Definition: db_stub.h:190
int affected_row
Definition: db_stub.h:125
CI_CONN_OPT_STRUCTURE opt
Definition: db_stub.h:107
CI_STMT_OPT_STRUCTURE opt
Definition: db_stub.h:164
int current_rs_idx
Definition: db_stub.h:172
bool get_generated_key
Definition: db_stub.h:88
DB_QUERY_RESULT * result
Definition: db_stub.h:186
int create_db_value_bind_table(int nvalue, void *impl, int auto_apply, BIND_HANDLE conn_handle, int(*get_index_by_name)(void *, const char *, int *ri), int(*get_db_value)(void *, int, DB_VALUE *), int(*set_db_value)(void *, int, DB_VALUE *), int(*init_domain)(void *, int, DB_VALUE *), VALUE_BIND_TABLE **rtable)
int coerce_db_value_to_value(const DB_VALUE *dbval, BIND_HANDLE conn, CI_TYPE type, void *addr, size_t len, size_t *outlen, bool *isnull)
short int port
Definition: db_stub.h:81
char srv_version[VERSION_LENGTH]
Definition: db_stub.h:76
int api_object_resultset_pool_create(BH_INTERFACE *ifs, BIND_HANDLE conn, API_OBJECT_RESULTSET_POOL **pool)
Definition: db_object.c:1159
UINT64 BIND_HANDLE
Definition: api_handle.h:28
void sigfpe_handler(int sig)
Definition: db_admin.c:822
VALUE_BIND_TABLE * value_table
Definition: db_stub.h:189
int coerce_value_to_db_value(CI_TYPE type, void *addr, size_t len, DB_VALUE *dbval, bool domain_initialized)
BH_INTERFACE * bh_interface
Definition: db_stub.h:109
BH_INTERFACE * bh_interface
Definition: db_stub.h:185
DB_TRAN_ISOLATION isolation
Definition: db_stub.h:78
bool updatable_result
Definition: db_stub.h:87
DB_QUERY_TYPE * query_type
Definition: db_stub.h:198
size_t query_length
Definition: db_stub.h:144
char * databasename
Definition: db_stub.h:112
struct ci_batch_data * next
Definition: db_stub.h:138
bool need_defered_commit
Definition: db_stub.h:117
CI_BATCH_RESULT_STRUCTURE * batch_result
Definition: db_stub.h:179