1 | /* Copyright (C) 2008-2017 Kentoku Shiba |
2 | |
3 | This program is free software; you can redistribute it and/or modify |
4 | it under the terms of the GNU General Public License as published by |
5 | the Free Software Foundation; version 2 of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software |
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
15 | |
16 | #define SPIDER_LOCK_MODE_NO_LOCK 0 |
17 | #define SPIDER_LOCK_MODE_SHARED 1 |
18 | #define SPIDER_LOCK_MODE_EXCLUSIVE 2 |
19 | |
20 | #define SPIDER_BG_SIMPLE_NO_ACTION 0 |
21 | #define SPIDER_BG_SIMPLE_CONNECT 1 |
22 | #define SPIDER_BG_SIMPLE_DISCONNECT 2 |
23 | #define SPIDER_BG_SIMPLE_RECORDS 3 |
24 | |
25 | uchar *spider_conn_get_key( |
26 | SPIDER_CONN *conn, |
27 | size_t *length, |
28 | my_bool not_used __attribute__ ((unused)) |
29 | ); |
30 | |
31 | uchar *spider_ipport_conn_get_key( |
32 | SPIDER_IP_PORT_CONN *ip_port, |
33 | size_t *length, |
34 | my_bool not_used __attribute__ ((unused)) |
35 | ); |
36 | |
37 | int spider_reset_conn_setted_parameter( |
38 | SPIDER_CONN *conn, |
39 | THD *thd |
40 | ); |
41 | |
42 | int spider_free_conn_alloc( |
43 | SPIDER_CONN *conn |
44 | ); |
45 | |
46 | void spider_free_conn_from_trx( |
47 | SPIDER_TRX *trx, |
48 | SPIDER_CONN *conn, |
49 | bool another, |
50 | bool trx_free, |
51 | int *roop_count |
52 | ); |
53 | |
54 | SPIDER_CONN *spider_create_conn( |
55 | SPIDER_SHARE *share, |
56 | ha_spider *spider, |
57 | int link_id, |
58 | int base_link_id, |
59 | uint conn_kind, |
60 | int *error_num |
61 | ); |
62 | |
63 | SPIDER_CONN *spider_get_conn( |
64 | SPIDER_SHARE *share, |
65 | int link_idx, |
66 | char *conn_key, |
67 | SPIDER_TRX *trx, |
68 | ha_spider *spider, |
69 | bool another, |
70 | bool thd_chg, |
71 | uint conn_kind, |
72 | int *error_num |
73 | ); |
74 | |
75 | int spider_free_conn( |
76 | SPIDER_CONN *conn |
77 | ); |
78 | |
79 | int spider_check_and_get_casual_read_conn( |
80 | THD *thd, |
81 | ha_spider *spider, |
82 | int link_idx |
83 | ); |
84 | |
85 | int spider_check_and_init_casual_read( |
86 | THD *thd, |
87 | ha_spider *spider, |
88 | int link_idx |
89 | ); |
90 | |
91 | void spider_conn_queue_connect( |
92 | SPIDER_SHARE *share, |
93 | SPIDER_CONN *conn, |
94 | int link_idx |
95 | ); |
96 | |
97 | void spider_conn_queue_connect_rewrite( |
98 | SPIDER_SHARE *share, |
99 | SPIDER_CONN *conn, |
100 | int link_idx |
101 | ); |
102 | |
103 | void spider_conn_queue_ping( |
104 | ha_spider *spider, |
105 | SPIDER_CONN *conn, |
106 | int link_idx |
107 | ); |
108 | |
109 | void spider_conn_queue_ping_rewrite( |
110 | ha_spider *spider, |
111 | SPIDER_CONN *conn, |
112 | int link_idx |
113 | ); |
114 | |
115 | void spider_conn_queue_trx_isolation( |
116 | SPIDER_CONN *conn, |
117 | int trx_isolation |
118 | ); |
119 | |
120 | void spider_conn_queue_semi_trx_isolation( |
121 | SPIDER_CONN *conn, |
122 | int trx_isolation |
123 | ); |
124 | |
125 | void spider_conn_queue_autocommit( |
126 | SPIDER_CONN *conn, |
127 | bool autocommit |
128 | ); |
129 | |
130 | void spider_conn_queue_sql_log_off( |
131 | SPIDER_CONN *conn, |
132 | bool sql_log_off |
133 | ); |
134 | |
135 | void spider_conn_queue_time_zone( |
136 | SPIDER_CONN *conn, |
137 | Time_zone *time_zone |
138 | ); |
139 | |
140 | void spider_conn_queue_start_transaction( |
141 | SPIDER_CONN *conn |
142 | ); |
143 | |
144 | void spider_conn_queue_xa_start( |
145 | SPIDER_CONN *conn, |
146 | XID *xid |
147 | ); |
148 | |
149 | void spider_conn_clear_queue( |
150 | SPIDER_CONN *conn |
151 | ); |
152 | |
153 | void spider_conn_clear_queue_at_commit( |
154 | SPIDER_CONN *conn |
155 | ); |
156 | |
157 | void spider_conn_set_timeout( |
158 | SPIDER_CONN *conn, |
159 | uint net_read_timeout, |
160 | uint net_write_timeout |
161 | ); |
162 | |
163 | void spider_conn_set_timeout_from_share( |
164 | SPIDER_CONN *conn, |
165 | int link_idx, |
166 | THD *thd, |
167 | SPIDER_SHARE *share |
168 | ); |
169 | |
170 | void spider_conn_set_timeout_from_direct_sql( |
171 | SPIDER_CONN *conn, |
172 | THD *thd, |
173 | SPIDER_DIRECT_SQL *direct_sql |
174 | ); |
175 | |
176 | void spider_tree_insert( |
177 | SPIDER_CONN *top, |
178 | SPIDER_CONN *conn |
179 | ); |
180 | |
181 | SPIDER_CONN *spider_tree_first( |
182 | SPIDER_CONN *top |
183 | ); |
184 | |
185 | SPIDER_CONN *spider_tree_last( |
186 | SPIDER_CONN *top |
187 | ); |
188 | |
189 | SPIDER_CONN *spider_tree_next( |
190 | SPIDER_CONN *current |
191 | ); |
192 | |
193 | SPIDER_CONN *spider_tree_delete( |
194 | SPIDER_CONN *conn, |
195 | SPIDER_CONN *top |
196 | ); |
197 | |
198 | #ifndef WITHOUT_SPIDER_BG_SEARCH |
199 | int spider_set_conn_bg_param( |
200 | ha_spider *spider |
201 | ); |
202 | |
203 | int spider_create_conn_thread( |
204 | SPIDER_CONN *conn |
205 | ); |
206 | |
207 | void spider_free_conn_thread( |
208 | SPIDER_CONN *conn |
209 | ); |
210 | |
211 | void spider_bg_conn_wait( |
212 | SPIDER_CONN *conn |
213 | ); |
214 | |
215 | void spider_bg_all_conn_wait( |
216 | ha_spider *spider |
217 | ); |
218 | |
219 | int spider_bg_all_conn_pre_next( |
220 | ha_spider *spider, |
221 | int link_idx |
222 | ); |
223 | |
224 | void spider_bg_conn_break( |
225 | SPIDER_CONN *conn, |
226 | ha_spider *spider |
227 | ); |
228 | |
229 | void spider_bg_all_conn_break( |
230 | ha_spider *spider |
231 | ); |
232 | |
233 | bool spider_bg_conn_get_job( |
234 | SPIDER_CONN *conn |
235 | ); |
236 | |
237 | int spider_bg_conn_search( |
238 | ha_spider *spider, |
239 | int link_idx, |
240 | int first_link_idx, |
241 | bool first, |
242 | bool pre_next, |
243 | bool discard_result |
244 | ); |
245 | |
246 | void spider_bg_conn_simple_action( |
247 | SPIDER_CONN *conn, |
248 | uint simple_action, |
249 | bool caller_wait, |
250 | void *target, |
251 | uint link_idx, |
252 | int *error_num |
253 | ); |
254 | |
255 | void *spider_bg_conn_action( |
256 | void *arg |
257 | ); |
258 | |
259 | int spider_create_sts_thread( |
260 | SPIDER_SHARE *share |
261 | ); |
262 | |
263 | void spider_free_sts_thread( |
264 | SPIDER_SHARE *share |
265 | ); |
266 | |
267 | void *spider_bg_sts_action( |
268 | void *arg |
269 | ); |
270 | |
271 | int spider_create_crd_thread( |
272 | SPIDER_SHARE *share |
273 | ); |
274 | |
275 | void spider_free_crd_thread( |
276 | SPIDER_SHARE *share |
277 | ); |
278 | |
279 | void *spider_bg_crd_action( |
280 | void *arg |
281 | ); |
282 | |
283 | int spider_create_mon_threads( |
284 | SPIDER_TRX *trx, |
285 | SPIDER_SHARE *share |
286 | ); |
287 | |
288 | void spider_free_mon_threads( |
289 | SPIDER_SHARE *share |
290 | ); |
291 | |
292 | void *spider_bg_mon_action( |
293 | void *arg |
294 | ); |
295 | #endif |
296 | |
297 | int spider_conn_first_link_idx( |
298 | THD *thd, |
299 | long *link_statuses, |
300 | long *access_balances, |
301 | uint *conn_link_idx, |
302 | int link_count, |
303 | int link_status |
304 | ); |
305 | |
306 | int spider_conn_next_link_idx( |
307 | THD *thd, |
308 | long *link_statuses, |
309 | long *access_balances, |
310 | uint *conn_link_idx, |
311 | int link_idx, |
312 | int link_count, |
313 | int link_status |
314 | ); |
315 | |
316 | int spider_conn_link_idx_next( |
317 | long *link_statuses, |
318 | uint *conn_link_idx, |
319 | int link_idx, |
320 | int link_count, |
321 | int link_status |
322 | ); |
323 | |
324 | int spider_conn_get_link_status( |
325 | long *link_statuses, |
326 | uint *conn_link_idx, |
327 | int link_idx |
328 | ); |
329 | |
330 | int spider_conn_lock_mode( |
331 | ha_spider *spider |
332 | ); |
333 | |
334 | bool spider_conn_check_recovery_link( |
335 | SPIDER_SHARE *share |
336 | ); |
337 | |
338 | bool spider_conn_use_handler( |
339 | ha_spider *spider, |
340 | int lock_mode, |
341 | int link_idx |
342 | ); |
343 | |
344 | bool spider_conn_need_open_handler( |
345 | ha_spider *spider, |
346 | uint idx, |
347 | int link_idx |
348 | ); |
349 | |
350 | SPIDER_IP_PORT_CONN *spider_create_ipport_conn(SPIDER_CONN *conn); |
351 | SPIDER_CONN* spider_get_conn_from_idle_connection |
352 | ( |
353 | SPIDER_SHARE *share, |
354 | int link_idx, |
355 | char *conn_key, |
356 | ha_spider *spider, |
357 | uint conn_kind, |
358 | int base_link_idx, |
359 | int *error_num |
360 | ); |
361 | void spider_free_ipport_conn(void *info); |
362 | |