CUBRID Engine  latest
cas_handle.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  * cas_handle.h -
22  */
23 
24 #ifndef _CAS_HANDLE_H_
25 #define _CAS_HANDLE_H_
26 
27 #ident "$Id$"
28 
29 #if defined(CAS_FOR_ORACLE)
30 #include "cas_oracle.h"
31 #elif defined(CAS_FOR_MYSQL)
32 #include "cas_mysql.h"
33 #else /* CAS_FOR_MYSQL */
34 #include "cas_db_inc.h"
35 #endif /* !CAS_FOR_ORACLE && !CAS_FOR_MYSQL */
36 
37 #define SRV_HANDLE_QUERY_SEQ_NUM(SRV_HANDLE) \
38  ((SRV_HANDLE) ? (SRV_HANDLE)->query_seq_num : 0)
39 
40 #if defined(CAS_FOR_ORACLE)
41 #define CLOB_LOCATOR_LIMIT 32 * 1000 /* 32K */
42 #define MAX_LOCP_COUNT 1024
43 #define DATA_SIZE 1024 * 1000
44 #endif
45 
48 {
49  void *dbval_ret;
50  void *dbval_args;
51 #if defined(CAS_FOR_ORACLE)
52  void **bind; /* OCIBind ** */
53 #elif defined(CAS_FOR_MYSQL)
54  void *bind; /* MYSQL_BIND * */
55 #endif
56  char *param_mode;
57  int num_args;
59 };
60 
63 {
64  char *attr_name;
65  char *class_name;
66  char updatable;
67 };
68 
69 #if defined(CAS_FOR_ORACLE) || defined(CAS_FOR_MYSQL)
70 typedef union db_data DB_DATA;
71 union db_data
72 {
73  int i;
74  short sh;
75  int64_t bi;
76  float f;
77  double d;
78 #if defined(CAS_FOR_ORACLE)
79  OCIDate date;
80  OCINumber number;
81  OCIStmt *cursor;
82 #else /* CAS_FOR_ORACLE */
83  MYSQL_TIME t;
84 #endif /* !CAS_FOR_ORACLE */
85  void *p;
86 };
87 
88 #if defined(CAS_FOR_ORACLE)
89 typedef struct locator_list LOCATOR_LIST;
90 struct locator_list
91 {
92  OCILobLocator *locp[MAX_LOCP_COUNT];
93  int locp_count;
94 };
95 #endif
96 
97 typedef struct db_value DB_VALUE;
98 #if defined(CAS_FOR_ORACLE)
99 struct db_value
100 {
101  unsigned short db_type;
102  sb2 is_null;
103  void *define;
104  void *buf; /* data pointer */
105  DB_DATA data;
106  unsigned int size;
107  unsigned short rlen;
108  bool need_clear;
109 };
110 #else
111 struct db_value
112 {
113  unsigned short db_type;
114  my_bool is_null;
115  void *buf; /* data pointer */
116  DB_DATA data;
117  unsigned long size;
118  bool need_clear;
119 };
120 #endif /* CAS_FOR_ORACLE */
121 #endif /* CAS_FOR_ORACLE || CAS_FOR_MYSQL */
122 
125 {
126 #if defined(CAS_FOR_ORACLE)
127  int column_count;
128  DB_VALUE *columns;
129 #elif defined(CAS_FOR_MYSQL)
130  int column_count;
131  DB_VALUE *columns;
132  MYSQL_BIND *defines;
133 #else /* CAS_FOR_MYSQL */
134  void *result;
137  void *column_info;
138  int copied;
140  int stmt_id;
142  char stmt_type;
146 #endif /* !CAS_FOR_ORACLE && !CAS_FOR_MYSQL */
147 };
148 
149 typedef struct t_srv_handle T_SRV_HANDLE;
151 {
152  int id;
153  void *session; /* query : DB_SESSION* schema : schema info table pointer */
154 #if defined(CAS_FOR_ORACLE)
155  bool has_out_result;
156 #endif
157  /* CAS4MySQL : MYSQL_STMT* */
160 #if defined(CAS_FOR_ORACLE) || defined(CAS_FOR_MYSQL)
161  int stmt_type;
162  int next_cursor_pos;
163  int tuple_count;
164  bool is_no_data;
165  bool send_metadata_before_execute;
166 #else /* CAS_FOR_ORACLE || CAS_FOR_MYSQL */
167  void *cur_result; /* query : &(q_result[cur_result]) schema info : &(session[cursor_pos]) */
168 #endif /* !CAS_FOR_ORACLE && !CAS_FOR_MYSQL */
169  char *sql_stmt;
170 #if !defined(CAS_FOR_ORACLE) && !defined(CAS_FOR_MYSQL)
171  void **classes;
176 #endif /* !CAS_FOR_ORACLE && !CAS_FOR_MYSQL */
182  int max_row;
184  unsigned int query_seq_num;
189  char is_pooled;
198 
199 #if defined(CAS_FOR_MYSQL)
200  bool has_mysql_last_insert_id;
201 #endif /* CAS_FOR_MYSQL */
202 };
203 
204 extern int hm_new_srv_handle (T_SRV_HANDLE ** new_handle, unsigned int seq_num);
205 extern void hm_srv_handle_free (int h_id);
206 extern void hm_srv_handle_free_all (bool free_holdable);
207 extern void hm_srv_handle_qresult_end_all (bool end_holdable);
208 extern T_SRV_HANDLE *hm_find_srv_handle (int h_id);
209 extern void hm_qresult_clear (T_QUERY_RESULT * q_result);
210 extern void hm_qresult_end (T_SRV_HANDLE * srv_handle, char free_flag);
211 extern void hm_session_free (T_SRV_HANDLE * srv_handle);
212 extern void hm_col_update_info_clear (T_COL_UPDATE_INFO * col_update_info);
213 #if defined (ENABLE_UNUSED_FUNCTION)
214 extern void hm_srv_handle_set_pooled (void);
215 #endif
216 
217 extern int hm_srv_handle_get_current_count (void);
218 extern void hm_srv_handle_unset_prepare_flag_all (void);
219 #endif /* _CAS_HANDLE_H_ */
T_QUERY_RESULT * q_result
Definition: cas_handle.h:159
void hm_srv_handle_qresult_end_all(bool end_holdable)
Definition: cas_handle.c:246
int sch_tuple_num
Definition: cas_handle.h:181
int cur_result_index
Definition: cas_handle.h:173
char need_force_commit
Definition: cas_handle.h:190
char * sql_stmt
Definition: cas_handle.h:169
char forward_only_cursor
Definition: cas_handle.h:192
bool is_holdable
Definition: cas_handle.h:196
void * column_info
Definition: cas_handle.h:137
int hm_srv_handle_get_current_count(void)
Definition: cas_handle.c:494
char * null_type_column
Definition: cas_handle.h:135
bool use_query_cache
Definition: cas_handle.h:194
void hm_qresult_clear(T_QUERY_RESULT *q_result)
Definition: cas_handle.c:308
bool has_result_set
Definition: cas_handle.h:175
void * cur_result
Definition: cas_handle.h:167
int * classes_chn
Definition: cas_handle.h:172
void hm_srv_handle_free(int h_id)
Definition: cas_handle.c:155
T_PREPARE_CALL_INFO * prepare_call_info
Definition: cas_handle.h:158
void hm_qresult_end(T_SRV_HANDLE *srv_handle, char free_flag)
Definition: cas_handle.c:314
void * session
Definition: cas_handle.h:153
T_SRV_HANDLE * hm_find_srv_handle(int h_id)
Definition: cas_handle.c:144
char prepare_flag
Definition: cas_handle.h:185
bool use_plan_cache
Definition: cas_handle.h:193
T_COL_UPDATE_INFO * col_update_info
Definition: cas_handle.h:136
void hm_srv_handle_free_all(bool free_holdable)
Definition: cas_handle.c:186
bool is_from_current_transaction
Definition: cas_handle.h:197
unsigned int query_seq_num
Definition: cas_handle.h:184
char col_updatable
Definition: cas_handle.h:143
char is_pooled
Definition: cas_handle.h:189
int hm_new_srv_handle(T_SRV_HANDLE **new_handle, unsigned int seq_num)
Definition: cas_handle.c:62
int max_col_size
Definition: cas_handle.h:178
bool is_fetch_completed
Definition: cas_handle.h:195
void hm_col_update_info_clear(T_COL_UPDATE_INFO *col_update_info)
Definition: cas_handle.c:402
char is_prepared
Definition: cas_handle.h:186
void ** classes
Definition: cas_handle.h:171
char query_info_flag
Definition: cas_handle.h:188
int i
Definition: dynamic_load.c:954
void hm_srv_handle_unset_prepare_flag_all(void)
Definition: cas_handle.c:226
int num_q_result
Definition: cas_handle.h:174
char is_updatable
Definition: cas_handle.h:187
char auto_commit_mode
Definition: cas_handle.h:191
void hm_session_free(T_SRV_HANDLE *srv_handle)
Definition: cas_handle.c:386
const char ** p
Definition: dynamic_load.c:945