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 | #ifdef USE_PRAGMA_INTERFACE |
17 | #pragma interface |
18 | #endif |
19 | |
20 | #define SPIDER_CONNECT_INFO_MAX_LEN 64 |
21 | #define SPIDER_CONNECT_INFO_PATH_MAX_LEN FN_REFLEN |
22 | #define SPIDER_LONGLONG_LEN 20 |
23 | #define SPIDER_MAX_KEY_LENGTH 16384 |
24 | |
25 | #define SPIDER_SET_CONNS_PARAM(param_name, param_val, conns, link_statuses, conn_link_idx, link_count, link_status) \ |
26 | for ( \ |
27 | roop_count = spider_conn_link_idx_next(link_statuses, \ |
28 | conn_link_idx, -1, link_count, link_status); \ |
29 | roop_count < link_count; \ |
30 | roop_count = spider_conn_link_idx_next(link_statuses, \ |
31 | conn_link_idx, roop_count, link_count, link_status) \ |
32 | ) { \ |
33 | if (conns[roop_count]) \ |
34 | conns[roop_count]->param_name = param_val; \ |
35 | } |
36 | |
37 | class ha_spider; |
38 | struct st_spider_ft_info |
39 | { |
40 | struct _ft_vft *please; |
41 | st_spider_ft_info *next; |
42 | ha_spider *file; |
43 | uint target; |
44 | bool used_in_where; |
45 | float score; |
46 | uint flags; |
47 | uint inx; |
48 | String *key; |
49 | }; |
50 | |
51 | class ha_spider: public handler |
52 | { |
53 | public: |
54 | THR_LOCK_DATA lock; |
55 | SPIDER_SHARE *share; |
56 | SPIDER_TRX *trx; |
57 | ulonglong spider_thread_id; |
58 | ulonglong trx_conn_adjustment; |
59 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
60 | ulonglong trx_hs_r_conn_adjustment; |
61 | ulonglong trx_hs_w_conn_adjustment; |
62 | #endif |
63 | uint mem_calc_id; |
64 | const char *mem_calc_func_name; |
65 | const char *mem_calc_file_name; |
66 | ulong mem_calc_line_no; |
67 | uint sql_kinds; |
68 | uint *sql_kind; |
69 | ulonglong *connection_ids; |
70 | uint conn_kinds; |
71 | uint *conn_kind; |
72 | char *conn_keys_first_ptr; |
73 | char **conn_keys; |
74 | SPIDER_CONN **conns; |
75 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
76 | char **hs_r_conn_keys; |
77 | SPIDER_CONN **hs_r_conns; |
78 | ulonglong *hs_r_conn_ages; |
79 | char **hs_w_conn_keys; |
80 | SPIDER_CONN **hs_w_conns; |
81 | ulonglong *hs_w_conn_ages; |
82 | #endif |
83 | /* for active-standby mode */ |
84 | uint *conn_link_idx; |
85 | uchar *conn_can_fo; |
86 | void **quick_targets; |
87 | int *need_mons; |
88 | query_id_t search_link_query_id; |
89 | int search_link_idx; |
90 | int result_link_idx; |
91 | SPIDER_RESULT_LIST result_list; |
92 | SPIDER_CONDITION *condition; |
93 | spider_string *blob_buff; |
94 | uchar *searched_bitmap; |
95 | uchar *ft_discard_bitmap; |
96 | bool position_bitmap_init; |
97 | uchar *position_bitmap; |
98 | SPIDER_POSITION *pushed_pos; |
99 | SPIDER_POSITION pushed_pos_buf; |
100 | #ifdef WITH_PARTITION_STORAGE_ENGINE |
101 | SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share; |
102 | ha_spider *pt_handler_share_creator; |
103 | #endif |
104 | #ifdef HA_CAN_BULK_ACCESS |
105 | int pre_direct_init_result; |
106 | bool is_bulk_access_clone; |
107 | bool synced_from_clone_source; |
108 | bool bulk_access_started; |
109 | bool bulk_access_executing; |
110 | bool bulk_access_pre_called; |
111 | SPIDER_BULK_ACCESS_LINK *bulk_access_link_first; |
112 | SPIDER_BULK_ACCESS_LINK *bulk_access_link_current; |
113 | SPIDER_BULK_ACCESS_LINK *bulk_access_link_exec_tgt; |
114 | /* |
115 | bool init_ha_mem_root; |
116 | MEM_ROOT ha_mem_root; |
117 | */ |
118 | ulonglong external_lock_cnt; |
119 | #endif |
120 | bool is_clone; |
121 | bool clone_bitmap_init; |
122 | ha_spider *pt_clone_source_handler; |
123 | ha_spider *pt_clone_last_searcher; |
124 | bool use_index_merge; |
125 | |
126 | bool init_index_handler; |
127 | bool init_rnd_handler; |
128 | |
129 | bool da_status; |
130 | bool use_spatial_index; |
131 | |
132 | #ifdef SPIDER_HAS_GROUP_BY_HANDLER |
133 | uint idx_for_direct_join; |
134 | bool use_fields; |
135 | spider_fields *fields; |
136 | SPIDER_LINK_IDX_CHAIN *link_idx_chain; |
137 | SPIDER_LINK_IDX_CHAIN *result_link_idx_chain; |
138 | #endif |
139 | |
140 | /* for mrr */ |
141 | bool mrr_with_cnt; |
142 | uint multi_range_cnt; |
143 | uint multi_range_hit_point; |
144 | #ifdef HA_MRR_USE_DEFAULT_IMPL |
145 | int multi_range_num; |
146 | bool have_second_range; |
147 | KEY_MULTI_RANGE mrr_second_range; |
148 | spider_string *mrr_key_buff; |
149 | #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 |
150 | range_id_t *multi_range_keys; |
151 | #else |
152 | char **multi_range_keys; |
153 | #endif |
154 | #else |
155 | KEY_MULTI_RANGE *multi_range_ranges; |
156 | #endif |
157 | |
158 | char *append_tblnm_alias; |
159 | uint append_tblnm_alias_length; |
160 | |
161 | ha_spider *next; |
162 | |
163 | bool rnd_scan_and_first; |
164 | bool quick_mode; |
165 | bool keyread; |
166 | bool ignore_dup_key; |
167 | bool write_can_replace; |
168 | bool insert_with_update; |
169 | bool low_priority; |
170 | bool high_priority; |
171 | bool insert_delayed; |
172 | bool use_pre_call; |
173 | bool use_pre_records; |
174 | bool pre_bitmap_checked; |
175 | enum thr_lock_type lock_type; |
176 | int lock_mode; |
177 | uint sql_command; |
178 | int selupd_lock_mode; |
179 | bool bulk_insert; |
180 | #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC |
181 | bool info_auto_called; |
182 | #endif |
183 | #ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT |
184 | bool auto_inc_temporary; |
185 | #endif |
186 | int bulk_size; |
187 | int direct_dup_insert; |
188 | int store_error_num; |
189 | uint dup_key_idx; |
190 | int select_column_mode; |
191 | bool update_request; |
192 | bool pk_update; |
193 | bool force_auto_increment; |
194 | int bka_mode; |
195 | bool cond_check; |
196 | int cond_check_error; |
197 | int error_mode; |
198 | ulonglong store_last_insert_id; |
199 | |
200 | ulonglong *db_request_id; |
201 | uchar *db_request_phase; |
202 | uchar *m_handler_opened; |
203 | uint *m_handler_id; |
204 | char **m_handler_cid; |
205 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
206 | uchar *r_handler_opened; |
207 | uint *r_handler_id; |
208 | uint *r_handler_index; |
209 | uchar *w_handler_opened; |
210 | uint *w_handler_id; |
211 | uint *w_handler_index; |
212 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
213 | uchar *do_hs_direct_update; |
214 | uint32 **hs_r_ret_fields; |
215 | uint32 **hs_w_ret_fields; |
216 | size_t *hs_r_ret_fields_num; |
217 | size_t *hs_w_ret_fields_num; |
218 | uint32 *hs_pushed_ret_fields; |
219 | size_t hs_pushed_ret_fields_num; |
220 | size_t hs_pushed_ret_fields_size; |
221 | size_t hs_pushed_lcl_fields_num; |
222 | uchar *tmp_column_bitmap; |
223 | bool hs_increment; |
224 | bool hs_decrement; |
225 | uint32 hs_pushed_strref_num; |
226 | #endif |
227 | #endif |
228 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
229 | bool do_direct_update; |
230 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
231 | bool maybe_do_hs_direct_update; |
232 | #endif |
233 | uint direct_update_kinds; |
234 | List<Item> *direct_update_fields; |
235 | List<Item> *direct_update_values; |
236 | #endif |
237 | #ifdef INFO_KIND_FORCE_LIMIT_BEGIN |
238 | longlong info_limit; |
239 | #endif |
240 | spider_index_rnd_init prev_index_rnd_init; |
241 | #ifdef HANDLER_HAS_DIRECT_AGGREGATE |
242 | SPIDER_ITEM_HLD *direct_aggregate_item_first; |
243 | SPIDER_ITEM_HLD *direct_aggregate_item_current; |
244 | #endif |
245 | ha_rows table_rows; |
246 | |
247 | /* for fulltext search */ |
248 | bool ft_init_and_first; |
249 | uint ft_init_idx; |
250 | uint ft_count; |
251 | bool ft_init_without_index_init; |
252 | st_spider_ft_info *ft_first; |
253 | st_spider_ft_info *ft_current; |
254 | |
255 | /* for dbton */ |
256 | spider_db_handler **dbton_handler; |
257 | |
258 | /* for direct limit offset */ |
259 | longlong direct_select_offset; |
260 | longlong direct_current_offset; |
261 | longlong direct_select_limit; |
262 | |
263 | ha_spider(); |
264 | ha_spider( |
265 | handlerton *hton, |
266 | TABLE_SHARE *table_arg |
267 | ); |
268 | virtual ~ha_spider(); |
269 | handler *clone( |
270 | const char *name, |
271 | MEM_ROOT *mem_root |
272 | ); |
273 | const char **bas_ext() const; |
274 | int open( |
275 | const char* name, |
276 | int mode, |
277 | uint test_if_locked |
278 | ); |
279 | int close(); |
280 | int check_access_kind( |
281 | THD *thd, |
282 | bool write_request |
283 | ); |
284 | #ifdef HA_CAN_BULK_ACCESS |
285 | int additional_lock( |
286 | THD *thd, |
287 | enum thr_lock_type lock_type |
288 | ); |
289 | #endif |
290 | THR_LOCK_DATA **store_lock( |
291 | THD *thd, |
292 | THR_LOCK_DATA **to, |
293 | enum thr_lock_type lock_type |
294 | ); |
295 | int external_lock( |
296 | THD *thd, |
297 | int lock_type |
298 | ); |
299 | int reset(); |
300 | int ( |
301 | enum ha_extra_function operation |
302 | ); |
303 | int index_init( |
304 | uint idx, |
305 | bool sorted |
306 | ); |
307 | #ifdef HA_CAN_BULK_ACCESS |
308 | int pre_index_init( |
309 | uint idx, |
310 | bool sorted |
311 | ); |
312 | #endif |
313 | int index_end(); |
314 | #ifdef HA_CAN_BULK_ACCESS |
315 | int pre_index_end(); |
316 | #endif |
317 | int index_read_map( |
318 | uchar *buf, |
319 | const uchar *key, |
320 | key_part_map keypart_map, |
321 | enum ha_rkey_function find_flag |
322 | ); |
323 | int index_read_last_map( |
324 | uchar *buf, |
325 | const uchar *key, |
326 | key_part_map keypart_map |
327 | ); |
328 | int index_next( |
329 | uchar *buf |
330 | ); |
331 | int index_prev( |
332 | uchar *buf |
333 | ); |
334 | int index_first( |
335 | uchar *buf |
336 | ); |
337 | int index_last( |
338 | uchar *buf |
339 | ); |
340 | int index_next_same( |
341 | uchar *buf, |
342 | const uchar *key, |
343 | uint keylen |
344 | ); |
345 | int read_range_first( |
346 | const key_range *start_key, |
347 | const key_range *end_key, |
348 | bool eq_range, |
349 | bool sorted |
350 | ); |
351 | int read_range_next(); |
352 | #ifdef HA_MRR_USE_DEFAULT_IMPL |
353 | #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 |
354 | ha_rows multi_range_read_info_const( |
355 | uint keyno, |
356 | RANGE_SEQ_IF *seq, |
357 | void *seq_init_param, |
358 | uint n_ranges, |
359 | uint *bufsz, |
360 | uint *flags, |
361 | Cost_estimate *cost |
362 | ); |
363 | ha_rows multi_range_read_info( |
364 | uint keyno, |
365 | uint n_ranges, |
366 | uint keys, |
367 | uint key_parts, |
368 | uint *bufsz, |
369 | uint *flags, |
370 | Cost_estimate *cost |
371 | ); |
372 | #else |
373 | ha_rows multi_range_read_info_const( |
374 | uint keyno, |
375 | RANGE_SEQ_IF *seq, |
376 | void *seq_init_param, |
377 | uint n_ranges, |
378 | uint *bufsz, |
379 | uint *flags, |
380 | COST_VECT *cost |
381 | ); |
382 | ha_rows multi_range_read_info( |
383 | uint keyno, |
384 | uint n_ranges, |
385 | uint keys, |
386 | uint key_parts, |
387 | uint *bufsz, |
388 | uint *flags, |
389 | COST_VECT *cost |
390 | ); |
391 | #endif |
392 | int multi_range_read_init( |
393 | RANGE_SEQ_IF *seq, |
394 | void *seq_init_param, |
395 | uint n_ranges, |
396 | uint mode, |
397 | HANDLER_BUFFER *buf |
398 | ); |
399 | #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 |
400 | int multi_range_read_next( |
401 | range_id_t *range_info |
402 | ); |
403 | int multi_range_read_next_first( |
404 | range_id_t *range_info |
405 | ); |
406 | int multi_range_read_next_next( |
407 | range_id_t *range_info |
408 | ); |
409 | #else |
410 | int multi_range_read_next( |
411 | char **range_info |
412 | ); |
413 | int multi_range_read_next_first( |
414 | char **range_info |
415 | ); |
416 | int multi_range_read_next_next( |
417 | char **range_info |
418 | ); |
419 | #endif |
420 | #else |
421 | int read_multi_range_first( |
422 | KEY_MULTI_RANGE **found_range_p, |
423 | KEY_MULTI_RANGE *ranges, |
424 | uint range_count, |
425 | bool sorted, |
426 | HANDLER_BUFFER *buffer |
427 | ); |
428 | int read_multi_range_next( |
429 | KEY_MULTI_RANGE **found_range_p |
430 | ); |
431 | #endif |
432 | int rnd_init( |
433 | bool scan |
434 | ); |
435 | #ifdef HA_CAN_BULK_ACCESS |
436 | int pre_rnd_init( |
437 | bool scan |
438 | ); |
439 | #endif |
440 | int rnd_end(); |
441 | #ifdef HA_CAN_BULK_ACCESS |
442 | int pre_rnd_end(); |
443 | #endif |
444 | int rnd_next( |
445 | uchar *buf |
446 | ); |
447 | void position( |
448 | const uchar *record |
449 | ); |
450 | int rnd_pos( |
451 | uchar *buf, |
452 | uchar *pos |
453 | ); |
454 | int cmp_ref( |
455 | const uchar *ref1, |
456 | const uchar *ref2 |
457 | ); |
458 | int ft_init(); |
459 | void ft_end(); |
460 | FT_INFO *ft_init_ext( |
461 | uint flags, |
462 | uint inx, |
463 | String *key |
464 | ); |
465 | int ft_read( |
466 | uchar *buf |
467 | ); |
468 | int pre_index_read_map( |
469 | const uchar *key, |
470 | key_part_map keypart_map, |
471 | enum ha_rkey_function find_flag, |
472 | bool use_parallel |
473 | ); |
474 | int pre_index_first(bool use_parallel); |
475 | int pre_index_last(bool use_parallel); |
476 | int pre_index_read_last_map( |
477 | const uchar *key, |
478 | key_part_map keypart_map, |
479 | bool use_parallel |
480 | ); |
481 | #ifdef HA_MRR_USE_DEFAULT_IMPL |
482 | int pre_multi_range_read_next( |
483 | bool use_parallel |
484 | ); |
485 | #else |
486 | int pre_read_multi_range_first( |
487 | KEY_MULTI_RANGE **found_range_p, |
488 | KEY_MULTI_RANGE *ranges, |
489 | uint range_count, |
490 | bool sorted, |
491 | HANDLER_BUFFER *buffer, |
492 | bool use_parallel |
493 | ); |
494 | #endif |
495 | int pre_read_range_first( |
496 | const key_range *start_key, |
497 | const key_range *end_key, |
498 | bool eq_range, |
499 | bool sorted, |
500 | bool use_parallel |
501 | ); |
502 | int pre_ft_read(bool use_parallel); |
503 | int pre_rnd_next(bool use_parallel); |
504 | int info( |
505 | uint flag |
506 | ); |
507 | ha_rows records_in_range( |
508 | uint inx, |
509 | key_range *start_key, |
510 | key_range *end_key |
511 | ); |
512 | int check_crd(); |
513 | int pre_records(); |
514 | ha_rows records(); |
515 | const char *table_type() const; |
516 | ulonglong table_flags() const; |
517 | const char *index_type( |
518 | uint key_number |
519 | ); |
520 | ulong index_flags( |
521 | uint idx, |
522 | uint part, |
523 | bool all_parts |
524 | ) const; |
525 | uint max_supported_record_length() const; |
526 | uint max_supported_keys() const; |
527 | uint max_supported_key_parts() const; |
528 | uint max_supported_key_length() const; |
529 | uint max_supported_key_part_length() const; |
530 | uint8 table_cache_type(); |
531 | #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC |
532 | bool need_info_for_auto_inc(); |
533 | #endif |
534 | #ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT |
535 | bool can_use_for_auto_inc_init(); |
536 | #endif |
537 | int update_auto_increment(); |
538 | void get_auto_increment( |
539 | ulonglong offset, |
540 | ulonglong increment, |
541 | ulonglong nb_desired_values, |
542 | ulonglong *first_value, |
543 | ulonglong *nb_reserved_values |
544 | ); |
545 | int reset_auto_increment( |
546 | ulonglong value |
547 | ); |
548 | void release_auto_increment(); |
549 | #ifdef SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS |
550 | void start_bulk_insert( |
551 | ha_rows rows, |
552 | uint flags |
553 | ); |
554 | #else |
555 | void start_bulk_insert( |
556 | ha_rows rows |
557 | ); |
558 | #endif |
559 | int end_bulk_insert(); |
560 | int write_row( |
561 | uchar *buf |
562 | ); |
563 | #ifdef HA_CAN_BULK_ACCESS |
564 | int pre_write_row( |
565 | uchar *buf |
566 | ); |
567 | #endif |
568 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
569 | void direct_update_init( |
570 | THD *thd, |
571 | bool hs_request |
572 | ); |
573 | #endif |
574 | bool start_bulk_update(); |
575 | int exec_bulk_update( |
576 | ha_rows *dup_key_found |
577 | ); |
578 | int end_bulk_update(); |
579 | int bulk_update_row( |
580 | const uchar *old_data, |
581 | const uchar *new_data, |
582 | ha_rows *dup_key_found |
583 | ); |
584 | int update_row( |
585 | const uchar *old_data, |
586 | const uchar *new_data |
587 | ); |
588 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
589 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
590 | inline int direct_update_rows_init() |
591 | { |
592 | return direct_update_rows_init(2, NULL, 0, FALSE, NULL); |
593 | } |
594 | int direct_update_rows_init( |
595 | uint mode, |
596 | KEY_MULTI_RANGE *ranges, |
597 | uint range_count, |
598 | bool sorted, |
599 | const uchar *new_data |
600 | ); |
601 | #else |
602 | int direct_update_rows_init(); |
603 | #endif |
604 | #ifdef HA_CAN_BULK_ACCESS |
605 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
606 | inline int pre_direct_update_rows_init() |
607 | { |
608 | return pre_direct_update_rows_init(2, NULL, 0, FALSE, NULL); |
609 | } |
610 | int pre_direct_update_rows_init( |
611 | uint mode, |
612 | KEY_MULTI_RANGE *ranges, |
613 | uint range_count, |
614 | bool sorted, |
615 | uchar *new_data |
616 | ); |
617 | #else |
618 | int pre_direct_update_rows_init(); |
619 | #endif |
620 | #endif |
621 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
622 | inline int direct_update_rows(ha_rows *update_rows) |
623 | { |
624 | return direct_update_rows(NULL, 0, FALSE, NULL, update_rows); |
625 | } |
626 | int direct_update_rows( |
627 | KEY_MULTI_RANGE *ranges, |
628 | uint range_count, |
629 | bool sorted, |
630 | uchar *new_data, |
631 | ha_rows *update_rows |
632 | ); |
633 | #else |
634 | int direct_update_rows( |
635 | ha_rows *update_rows |
636 | ); |
637 | #endif |
638 | #ifdef HA_CAN_BULK_ACCESS |
639 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
640 | inline int pre_direct_update_rows() |
641 | { |
642 | ha_rows update_rows; |
643 | |
644 | return pre_direct_update_rows(NULL, 0, FALSE, NULL, &update_rows); |
645 | } |
646 | int pre_direct_update_rows( |
647 | KEY_MULTI_RANGE *ranges, |
648 | uint range_count, |
649 | bool sorted, |
650 | uchar *new_data, |
651 | ha_rows *update_rows |
652 | ); |
653 | #else |
654 | int pre_direct_update_rows(); |
655 | #endif |
656 | #endif |
657 | #endif |
658 | bool start_bulk_delete(); |
659 | int end_bulk_delete(); |
660 | int delete_row( |
661 | const uchar *buf |
662 | ); |
663 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
664 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
665 | inline int direct_delete_rows_init() |
666 | { |
667 | return direct_delete_rows_init(2, NULL, 0, FALSE); |
668 | } |
669 | int direct_delete_rows_init( |
670 | uint mode, |
671 | KEY_MULTI_RANGE *ranges, |
672 | uint range_count, |
673 | bool sorted |
674 | ); |
675 | #else |
676 | int direct_delete_rows_init(); |
677 | #endif |
678 | #ifdef HA_CAN_BULK_ACCESS |
679 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
680 | inline int pre_direct_delete_rows_init() |
681 | { |
682 | return pre_direct_delete_rows_init(2, NULL, 0, FALSE); |
683 | } |
684 | int pre_direct_delete_rows_init( |
685 | uint mode, |
686 | KEY_MULTI_RANGE *ranges, |
687 | uint range_count, |
688 | bool sorted |
689 | ); |
690 | #else |
691 | int pre_direct_delete_rows_init(); |
692 | #endif |
693 | #endif |
694 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
695 | inline int direct_delete_rows(ha_rows *delete_rows) |
696 | { |
697 | return direct_delete_rows(NULL, 0, FALSE, delete_rows); |
698 | } |
699 | int direct_delete_rows( |
700 | KEY_MULTI_RANGE *ranges, |
701 | uint range_count, |
702 | bool sorted, |
703 | ha_rows *delete_rows |
704 | ); |
705 | #else |
706 | int direct_delete_rows( |
707 | ha_rows *delete_rows |
708 | ); |
709 | #endif |
710 | #ifdef HA_CAN_BULK_ACCESS |
711 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS |
712 | inline int pre_direct_delete_rows() |
713 | { |
714 | ha_rows delete_rows; |
715 | |
716 | return pre_direct_delete_rows(NULL, 0, FALSE, &delete_rows); |
717 | } |
718 | int pre_direct_delete_rows( |
719 | KEY_MULTI_RANGE *ranges, |
720 | uint range_count, |
721 | bool sorted, |
722 | ha_rows *delete_rows |
723 | ); |
724 | #else |
725 | int pre_direct_delete_rows(); |
726 | #endif |
727 | #endif |
728 | #endif |
729 | int delete_all_rows(); |
730 | int truncate(); |
731 | double scan_time(); |
732 | double read_time( |
733 | uint index, |
734 | uint ranges, |
735 | ha_rows rows |
736 | ); |
737 | #ifdef HA_CAN_BULK_ACCESS |
738 | void bulk_req_exec(); |
739 | #endif |
740 | const key_map *keys_to_use_for_scanning(); |
741 | ha_rows estimate_rows_upper_bound(); |
742 | void print_error( |
743 | int error, |
744 | myf errflag |
745 | ); |
746 | bool get_error_message( |
747 | int error, |
748 | String *buf |
749 | ); |
750 | int create( |
751 | const char *name, |
752 | TABLE *form, |
753 | HA_CREATE_INFO *info |
754 | ); |
755 | void update_create_info( |
756 | HA_CREATE_INFO* create_info |
757 | ); |
758 | int rename_table( |
759 | const char *from, |
760 | const char *to |
761 | ); |
762 | int delete_table( |
763 | const char *name |
764 | ); |
765 | bool is_crashed() const; |
766 | #ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR |
767 | bool auto_repair(int error) const; |
768 | #else |
769 | bool auto_repair() const; |
770 | #endif |
771 | int disable_indexes( |
772 | uint mode |
773 | ); |
774 | int enable_indexes( |
775 | uint mode |
776 | ); |
777 | int check( |
778 | THD* thd, |
779 | HA_CHECK_OPT* check_opt |
780 | ); |
781 | int repair( |
782 | THD* thd, |
783 | HA_CHECK_OPT* check_opt |
784 | ); |
785 | bool check_and_repair( |
786 | THD *thd |
787 | ); |
788 | int analyze( |
789 | THD* thd, |
790 | HA_CHECK_OPT* check_opt |
791 | ); |
792 | int optimize( |
793 | THD* thd, |
794 | HA_CHECK_OPT* check_opt |
795 | ); |
796 | bool is_fatal_error( |
797 | int error_num, |
798 | uint flags |
799 | ); |
800 | Field *get_top_table_field( |
801 | uint16 field_index |
802 | ); |
803 | Field *field_exchange( |
804 | Field *field |
805 | ); |
806 | const COND *cond_push( |
807 | const COND* cond |
808 | ); |
809 | void cond_pop(); |
810 | int info_push( |
811 | uint info_type, |
812 | void *info |
813 | ); |
814 | #ifdef HANDLER_HAS_DIRECT_AGGREGATE |
815 | void return_record_by_parent(); |
816 | #endif |
817 | TABLE *get_table(); |
818 | TABLE *get_top_table(); |
819 | void set_ft_discard_bitmap(); |
820 | void set_searched_bitmap(); |
821 | void set_clone_searched_bitmap(); |
822 | void set_searched_bitmap_from_item_list(); |
823 | void set_select_column_mode(); |
824 | #ifdef WITH_PARTITION_STORAGE_ENGINE |
825 | void check_select_column(bool rnd); |
826 | #endif |
827 | bool check_and_start_bulk_update( |
828 | spider_bulk_upd_start bulk_upd_start |
829 | ); |
830 | int check_and_end_bulk_update( |
831 | spider_bulk_upd_start bulk_upd_start |
832 | ); |
833 | uint check_partitioned(); |
834 | void check_direct_order_limit(); |
835 | void check_distinct_key_query(); |
836 | bool is_sole_projection_field( |
837 | uint16 field_index |
838 | ); |
839 | int check_ha_range_eof(); |
840 | int drop_tmp_tables(); |
841 | bool handler_opened( |
842 | int link_idx, |
843 | uint tgt_conn_kind |
844 | ); |
845 | void set_handler_opened( |
846 | int link_idx |
847 | ); |
848 | void clear_handler_opened( |
849 | int link_idx, |
850 | uint tgt_conn_kind |
851 | ); |
852 | int close_opened_handler( |
853 | int link_idx, |
854 | bool release_conn |
855 | ); |
856 | int index_handler_init(); |
857 | int rnd_handler_init(); |
858 | void set_error_mode(); |
859 | void backup_error_status(); |
860 | int check_error_mode( |
861 | int error_num |
862 | ); |
863 | int check_error_mode_eof( |
864 | int error_num |
865 | ); |
866 | int index_read_map_internal( |
867 | uchar *buf, |
868 | const uchar *key, |
869 | key_part_map keypart_map, |
870 | enum ha_rkey_function find_flag |
871 | ); |
872 | int index_read_last_map_internal( |
873 | uchar *buf, |
874 | const uchar *key, |
875 | key_part_map keypart_map |
876 | ); |
877 | int index_first_internal(uchar *buf); |
878 | int index_last_internal(uchar *buf); |
879 | int read_range_first_internal( |
880 | uchar *buf, |
881 | const key_range *start_key, |
882 | const key_range *end_key, |
883 | bool eq_range, |
884 | bool sorted |
885 | ); |
886 | #ifdef HA_MRR_USE_DEFAULT_IMPL |
887 | #else |
888 | int read_multi_range_first_internal( |
889 | uchar *buf, |
890 | KEY_MULTI_RANGE **found_range_p, |
891 | KEY_MULTI_RANGE *ranges, |
892 | uint range_count, |
893 | bool sorted, |
894 | HANDLER_BUFFER *buffer |
895 | ); |
896 | #endif |
897 | int ft_read_internal(uchar *buf); |
898 | int rnd_next_internal(uchar *buf); |
899 | void check_pre_call( |
900 | bool use_parallel |
901 | ); |
902 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
903 | void check_insert_dup_update_pushdown(); |
904 | #endif |
905 | #ifdef HA_CAN_BULK_ACCESS |
906 | SPIDER_BULK_ACCESS_LINK *create_bulk_access_link(); |
907 | void delete_bulk_access_link( |
908 | SPIDER_BULK_ACCESS_LINK *bulk_access_link |
909 | ); |
910 | int sync_from_clone_source( |
911 | ha_spider *spider |
912 | ); |
913 | #endif |
914 | void sync_from_clone_source_base( |
915 | ha_spider *spider |
916 | ); |
917 | void set_first_link_idx(); |
918 | void reset_first_link_idx(); |
919 | int reset_sql_sql( |
920 | ulong sql_type |
921 | ); |
922 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
923 | int reset_hs_sql( |
924 | ulong sql_type |
925 | ); |
926 | int reset_hs_keys( |
927 | ulong sql_type |
928 | ); |
929 | int reset_hs_upds( |
930 | ulong sql_type |
931 | ); |
932 | int reset_hs_strs( |
933 | ulong sql_type |
934 | ); |
935 | int reset_hs_strs_pos( |
936 | ulong sql_type |
937 | ); |
938 | int push_back_hs_upds( |
939 | SPIDER_HS_STRING_REF &info |
940 | ); |
941 | #endif |
942 | int append_tmp_table_and_sql_for_bka( |
943 | const key_range *start_key |
944 | ); |
945 | int reuse_tmp_table_and_sql_for_bka(); |
946 | int append_union_table_and_sql_for_bka( |
947 | const key_range *start_key |
948 | ); |
949 | int reuse_union_table_and_sql_for_bka(); |
950 | int append_insert_sql_part(); |
951 | int append_update_sql_part(); |
952 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
953 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
954 | int append_increment_update_set_sql_part(); |
955 | #endif |
956 | #endif |
957 | int append_update_set_sql_part(); |
958 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
959 | int append_direct_update_set_sql_part(); |
960 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
961 | int append_direct_update_set_hs_part(); |
962 | #endif |
963 | #endif |
964 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
965 | int append_dup_update_pushdown_sql_part( |
966 | const char *alias, |
967 | uint alias_length |
968 | ); |
969 | int append_update_columns_sql_part( |
970 | const char *alias, |
971 | uint alias_length |
972 | ); |
973 | int check_update_columns_sql_part(); |
974 | #endif |
975 | int append_delete_sql_part(); |
976 | int append_select_sql_part( |
977 | ulong sql_type |
978 | ); |
979 | int append_table_select_sql_part( |
980 | ulong sql_type |
981 | ); |
982 | int append_key_select_sql_part( |
983 | ulong sql_type, |
984 | uint idx |
985 | ); |
986 | int append_minimum_select_sql_part( |
987 | ulong sql_type |
988 | ); |
989 | int append_from_sql_part( |
990 | ulong sql_type |
991 | ); |
992 | int append_hint_after_table_sql_part( |
993 | ulong sql_type |
994 | ); |
995 | void set_where_pos_sql( |
996 | ulong sql_type |
997 | ); |
998 | void set_where_to_pos_sql( |
999 | ulong sql_type |
1000 | ); |
1001 | int check_item_type_sql( |
1002 | Item *item |
1003 | ); |
1004 | int append_values_connector_sql_part( |
1005 | ulong sql_type |
1006 | ); |
1007 | int append_values_terminator_sql_part( |
1008 | ulong sql_type |
1009 | ); |
1010 | int append_union_table_connector_sql_part( |
1011 | ulong sql_type |
1012 | ); |
1013 | int append_union_table_terminator_sql_part( |
1014 | ulong sql_type |
1015 | ); |
1016 | int append_key_column_values_sql_part( |
1017 | const key_range *start_key, |
1018 | ulong sql_type |
1019 | ); |
1020 | int append_key_column_values_with_name_sql_part( |
1021 | const key_range *start_key, |
1022 | ulong sql_type |
1023 | ); |
1024 | int append_key_where_sql_part( |
1025 | const key_range *start_key, |
1026 | const key_range *end_key, |
1027 | ulong sql_type |
1028 | ); |
1029 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
1030 | int append_key_where_hs_part( |
1031 | const key_range *start_key, |
1032 | const key_range *end_key, |
1033 | ulong sql_type |
1034 | ); |
1035 | #endif |
1036 | int append_match_where_sql_part( |
1037 | ulong sql_type |
1038 | ); |
1039 | int append_condition_sql_part( |
1040 | const char *alias, |
1041 | uint alias_length, |
1042 | ulong sql_type, |
1043 | bool test_flg |
1044 | ); |
1045 | #ifdef HANDLER_HAS_DIRECT_AGGREGATE |
1046 | int append_sum_select_sql_part( |
1047 | ulong sql_type, |
1048 | const char *alias, |
1049 | uint alias_length |
1050 | ); |
1051 | #endif |
1052 | int append_match_select_sql_part( |
1053 | ulong sql_type, |
1054 | const char *alias, |
1055 | uint alias_length |
1056 | ); |
1057 | void set_order_pos_sql( |
1058 | ulong sql_type |
1059 | ); |
1060 | void set_order_to_pos_sql( |
1061 | ulong sql_type |
1062 | ); |
1063 | #ifdef HANDLER_HAS_DIRECT_AGGREGATE |
1064 | int append_group_by_sql_part( |
1065 | const char *alias, |
1066 | uint alias_length, |
1067 | ulong sql_type |
1068 | ); |
1069 | #endif |
1070 | int append_key_order_for_merge_with_alias_sql_part( |
1071 | const char *alias, |
1072 | uint alias_length, |
1073 | ulong sql_type |
1074 | ); |
1075 | int append_key_order_for_direct_order_limit_with_alias_sql_part( |
1076 | const char *alias, |
1077 | uint alias_length, |
1078 | ulong sql_type |
1079 | ); |
1080 | int append_key_order_with_alias_sql_part( |
1081 | const char *alias, |
1082 | uint alias_length, |
1083 | ulong sql_type |
1084 | ); |
1085 | int append_limit_sql_part( |
1086 | longlong offset, |
1087 | longlong limit, |
1088 | ulong sql_type |
1089 | ); |
1090 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
1091 | int append_limit_hs_part( |
1092 | longlong offset, |
1093 | longlong limit, |
1094 | ulong sql_type |
1095 | ); |
1096 | #endif |
1097 | int reappend_limit_sql_part( |
1098 | longlong offset, |
1099 | longlong limit, |
1100 | ulong sql_type |
1101 | ); |
1102 | int append_insert_terminator_sql_part( |
1103 | ulong sql_type |
1104 | ); |
1105 | int append_insert_values_sql_part( |
1106 | ulong sql_type |
1107 | ); |
1108 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
1109 | int append_insert_values_hs_part( |
1110 | ulong sql_type |
1111 | ); |
1112 | #endif |
1113 | int append_into_sql_part( |
1114 | ulong sql_type |
1115 | ); |
1116 | void set_insert_to_pos_sql( |
1117 | ulong sql_type |
1118 | ); |
1119 | bool is_bulk_insert_exec_period( |
1120 | bool bulk_end |
1121 | ); |
1122 | int append_select_lock_sql_part( |
1123 | ulong sql_type |
1124 | ); |
1125 | int append_union_all_start_sql_part( |
1126 | ulong sql_type |
1127 | ); |
1128 | int append_union_all_sql_part( |
1129 | ulong sql_type |
1130 | ); |
1131 | int append_union_all_end_sql_part( |
1132 | ulong sql_type |
1133 | ); |
1134 | int append_multi_range_cnt_sql_part( |
1135 | ulong sql_type, |
1136 | uint multi_range_cnt, |
1137 | bool with_comma |
1138 | ); |
1139 | int append_multi_range_cnt_with_name_sql_part( |
1140 | ulong sql_type, |
1141 | uint multi_range_cnt |
1142 | ); |
1143 | int append_delete_all_rows_sql_part( |
1144 | ulong sql_type |
1145 | ); |
1146 | int append_update_sql( |
1147 | const TABLE *table, |
1148 | my_ptrdiff_t ptr_diff, |
1149 | bool bulk |
1150 | ); |
1151 | int append_delete_sql( |
1152 | const TABLE *table, |
1153 | my_ptrdiff_t ptr_diff, |
1154 | bool bulk |
1155 | ); |
1156 | bool sql_is_filled_up( |
1157 | ulong sql_type |
1158 | ); |
1159 | bool sql_is_empty( |
1160 | ulong sql_type |
1161 | ); |
1162 | bool support_multi_split_read_sql(); |
1163 | bool support_bulk_update_sql(); |
1164 | int bulk_tmp_table_insert(); |
1165 | int bulk_tmp_table_end_bulk_insert(); |
1166 | int bulk_tmp_table_rnd_init(); |
1167 | int bulk_tmp_table_rnd_next(); |
1168 | int bulk_tmp_table_rnd_end(); |
1169 | int mk_bulk_tmp_table_and_bulk_start(); |
1170 | void rm_bulk_tmp_table(); |
1171 | bool bulk_tmp_table_created(); |
1172 | int print_item_type( |
1173 | Item *item, |
1174 | spider_string *str, |
1175 | const char *alias, |
1176 | uint alias_length |
1177 | ); |
1178 | bool support_use_handler_sql( |
1179 | int use_handler |
1180 | ); |
1181 | #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) |
1182 | bool support_bulk_access_hs() const; |
1183 | #endif |
1184 | int init_union_table_name_pos_sql(); |
1185 | int set_union_table_name_pos_sql(); |
1186 | }; |
1187 | |