summaryrefslogtreecommitdiff
path: root/storage/spider/ha_spider.h
blob: 3b16be09d38b64a6ce0996fe54f96811c10ed3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
/* Copyright (C) 2008-2015 Kentoku Shiba

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */

#ifdef USE_PRAGMA_INTERFACE
#pragma interface
#endif

#if (defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000)
#define SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS
#endif

#define SPIDER_CONNECT_INFO_MAX_LEN 64
#define SPIDER_CONNECT_INFO_PATH_MAX_LEN FN_REFLEN
#define SPIDER_LONGLONG_LEN 20
#define SPIDER_MAX_KEY_LENGTH 16384

#define SPIDER_SET_CONNS_PARAM(param_name, param_val, conns, link_statuses, conn_link_idx, link_count, link_status) \
  for ( \
    roop_count = spider_conn_link_idx_next(link_statuses, \
      conn_link_idx, -1, link_count, link_status); \
    roop_count < link_count; \
    roop_count = spider_conn_link_idx_next(link_statuses, \
      conn_link_idx, roop_count, link_count, link_status) \
  ) { \
    if (conns[roop_count]) \
      conns[roop_count]->param_name = param_val; \
  }

class ha_spider;
struct st_spider_ft_info
{
  struct _ft_vft *please;
  st_spider_ft_info *next;
  ha_spider *file;
  uint target;
  bool used_in_where;
  float score;
  uint flags;
  uint inx;
  String *key;
};

class ha_spider: public handler
{
public:
  THR_LOCK_DATA      lock;
  SPIDER_SHARE       *share;
  SPIDER_TRX         *trx;
  ulonglong          spider_thread_id;
  ulonglong          trx_conn_adjustment;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  ulonglong          trx_hs_r_conn_adjustment;
  ulonglong          trx_hs_w_conn_adjustment;
#endif
  uint               mem_calc_id;
  const char         *mem_calc_func_name;
  const char         *mem_calc_file_name;
  ulong              mem_calc_line_no;
  uint               sql_kinds;
  uint               *sql_kind;
  ulonglong          *connection_ids;
  uint               conn_kinds;
  uint               *conn_kind;
  char               *conn_keys_first_ptr;
  char               **conn_keys;
  SPIDER_CONN        **conns;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  char               **hs_r_conn_keys;
  SPIDER_CONN        **hs_r_conns;
  ulonglong          *hs_r_conn_ages;
  char               **hs_w_conn_keys;
  SPIDER_CONN        **hs_w_conns;
  ulonglong          *hs_w_conn_ages;
#endif
  /* for active-standby mode */
  uint               *conn_link_idx;
  uchar              *conn_can_fo;
  void               **quick_targets;
  int                *need_mons;
  query_id_t         search_link_query_id;
  int                search_link_idx;
  int                result_link_idx;
  SPIDER_RESULT_LIST result_list;
  SPIDER_CONDITION   *condition;
  spider_string      *blob_buff;
  uchar              *searched_bitmap;
  uchar              *ft_discard_bitmap;
  bool               position_bitmap_init;
  uchar              *position_bitmap;
  SPIDER_POSITION    *pushed_pos;
  SPIDER_POSITION    pushed_pos_buf;
#ifdef WITH_PARTITION_STORAGE_ENGINE
  SPIDER_PARTITION_HANDLER_SHARE *partition_handler_share;
  ha_spider          *pt_handler_share_creator;
#endif
#ifdef HA_CAN_BULK_ACCESS
  int                pre_direct_init_result;
  bool               is_bulk_access_clone;
  bool               synced_from_clone_source;
  bool               bulk_access_started;
  bool               bulk_access_executing;
  bool               bulk_access_pre_called;
  SPIDER_BULK_ACCESS_LINK *bulk_access_link_first;
  SPIDER_BULK_ACCESS_LINK *bulk_access_link_current;
  SPIDER_BULK_ACCESS_LINK *bulk_access_link_exec_tgt;
/*
  bool               init_ha_mem_root;
  MEM_ROOT           ha_mem_root;
*/
  ulonglong          external_lock_cnt;
#endif
  bool               is_clone;
  bool               clone_bitmap_init;
  ha_spider          *pt_clone_source_handler;
  ha_spider          *pt_clone_last_searcher;
  bool               use_index_merge;

  bool               init_index_handler;
  bool               init_rnd_handler;

  bool               da_status;
  bool               use_spatial_index;

  /* for mrr */
  bool               mrr_with_cnt;
  uint               multi_range_cnt;
  uint               multi_range_hit_point;
#ifdef HA_MRR_USE_DEFAULT_IMPL
  int                multi_range_num;
  bool               have_second_range;
  KEY_MULTI_RANGE    mrr_second_range;
  spider_string      *mrr_key_buff;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
  range_id_t         *multi_range_keys;
#else
  char               **multi_range_keys;
#endif
#else
  KEY_MULTI_RANGE    *multi_range_ranges;
#endif

  char               *append_tblnm_alias;
  uint               append_tblnm_alias_length;

  ha_spider          *next;

  bool               rnd_scan_and_first;
  bool               quick_mode;
  bool               keyread;
  bool               ignore_dup_key;
  bool               write_can_replace;
  bool               insert_with_update;
  bool               low_priority;
  bool               high_priority;
  bool               insert_delayed;
  bool               use_pre_call;
  bool               use_pre_records;
  bool               pre_bitmap_checked;
  enum thr_lock_type lock_type;
  int                lock_mode;
  uint               sql_command;
  int                selupd_lock_mode;
  bool               bulk_insert;
#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
  bool               info_auto_called;
#endif
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
  bool               auto_inc_temporary;
#endif
  int                bulk_size;
  int                direct_dup_insert;
  int                store_error_num;
  uint               dup_key_idx;
  int                select_column_mode;
  bool               update_request;
  bool               pk_update;
  bool               force_auto_increment;
  int                bka_mode;
  bool               cond_check;
  int                cond_check_error;
  int                error_mode;
  ulonglong          store_last_insert_id;

  ulonglong          *db_request_id;
  uchar              *db_request_phase;
  uchar              *m_handler_opened;
  uint               *m_handler_id;
  char               **m_handler_cid;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  uchar              *r_handler_opened;
  uint               *r_handler_id;
  uint               *r_handler_index;
  uchar              *w_handler_opened;
  uint               *w_handler_id;
  uint               *w_handler_index;
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  uchar              *do_hs_direct_update;
  uint32             **hs_r_ret_fields;
  uint32             **hs_w_ret_fields;
  size_t             *hs_r_ret_fields_num;
  size_t             *hs_w_ret_fields_num;
  uint32             *hs_pushed_ret_fields;
  size_t             hs_pushed_ret_fields_num;
  size_t             hs_pushed_ret_fields_size;
  size_t             hs_pushed_lcl_fields_num;
  uchar              *tmp_column_bitmap;
  bool               hs_increment;
  bool               hs_decrement;
  uint32             hs_pushed_strref_num;
#endif
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  bool               do_direct_update;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  bool               maybe_do_hs_direct_update;
#endif
  uint               direct_update_kinds;
  List<Item>         *direct_update_fields;
  List<Item>         *direct_update_values;
#endif
#ifdef INFO_KIND_FORCE_LIMIT_BEGIN
  longlong           info_limit;
#endif
  spider_index_rnd_init prev_index_rnd_init;
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
  SPIDER_ITEM_HLD    *direct_aggregate_item_first;
  SPIDER_ITEM_HLD    *direct_aggregate_item_current;
#endif
  ha_rows            table_rows;

  /* for fulltext search */
  bool               ft_init_and_first;
  uint               ft_init_idx;
  uint               ft_count;
  bool               ft_init_without_index_init;
  st_spider_ft_info  *ft_first;
  st_spider_ft_info  *ft_current;

  /* for dbton */
  spider_db_handler  **dbton_handler;

  ha_spider();
  ha_spider(
    handlerton *hton,
    TABLE_SHARE *table_arg
  );
  virtual ~ha_spider();
  handler *clone(
    const char *name,
    MEM_ROOT *mem_root
  );
  const char **bas_ext() const;
  int open(
    const char* name,
    int mode,
    uint test_if_locked
  );
  int close();
  int check_access_kind(
    THD *thd,
    bool write_request
  );
#ifdef HA_CAN_BULK_ACCESS
  int additional_lock(
    THD *thd,
    enum thr_lock_type lock_type
  );
#endif
  THR_LOCK_DATA **store_lock(
    THD *thd,
    THR_LOCK_DATA **to,
    enum thr_lock_type lock_type
  );
  int external_lock(
    THD *thd,
    int lock_type
  );
  int reset();
  int extra(
    enum ha_extra_function operation
  );
  int index_init(
    uint idx,
    bool sorted
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_index_init(
    uint idx,
    bool sorted
  );
#endif
  int index_end();
#ifdef HA_CAN_BULK_ACCESS
  int pre_index_end();
#endif
  int index_read_map(
    uchar *buf,
    const uchar *key,
    key_part_map keypart_map,
    enum ha_rkey_function find_flag
  );
  int index_read_last_map(
    uchar *buf,
    const uchar *key,
    key_part_map keypart_map
  );
  int index_next(
    uchar *buf
  );
  int index_prev(
    uchar *buf
  );
  int index_first(
    uchar *buf
  );
  int index_last(
    uchar *buf
  );
  int index_next_same(
    uchar *buf,
    const uchar *key,
    uint keylen
  );
  int read_range_first(
    const key_range *start_key,
    const key_range *end_key,
    bool eq_range,
    bool sorted
  );
  int read_range_next();
#ifdef HA_MRR_USE_DEFAULT_IMPL
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
  ha_rows multi_range_read_info_const(
    uint keyno,
    RANGE_SEQ_IF *seq,
    void *seq_init_param,
    uint n_ranges,
    uint *bufsz,
    uint *flags,
    Cost_estimate *cost
  );
  ha_rows multi_range_read_info(
    uint keyno,
    uint n_ranges,
    uint keys,
    uint key_parts,
    uint *bufsz,
    uint *flags,
    Cost_estimate *cost
  );
#else
  ha_rows multi_range_read_info_const(
    uint keyno,
    RANGE_SEQ_IF *seq,
    void *seq_init_param,
    uint n_ranges,
    uint *bufsz,
    uint *flags,
    COST_VECT *cost
  );
  ha_rows multi_range_read_info(
    uint keyno,
    uint n_ranges,
    uint keys,
    uint key_parts,
    uint *bufsz,
    uint *flags,
    COST_VECT *cost
  );
#endif
  int multi_range_read_init(
    RANGE_SEQ_IF *seq,
    void *seq_init_param,
    uint n_ranges,
    uint mode,
    HANDLER_BUFFER *buf
  );
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
  int multi_range_read_next(
    range_id_t *range_info
  );
  int multi_range_read_next_first(
    range_id_t *range_info
  );
  int multi_range_read_next_next(
    range_id_t *range_info
  );
#else
  int multi_range_read_next(
    char **range_info
  );
  int multi_range_read_next_first(
    char **range_info
  );
  int multi_range_read_next_next(
    char **range_info
  );
#endif
#else
  int read_multi_range_first(
    KEY_MULTI_RANGE **found_range_p,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    HANDLER_BUFFER *buffer
  );
  int read_multi_range_next(
    KEY_MULTI_RANGE **found_range_p
  );
#endif
  int rnd_init(
    bool scan
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_rnd_init(
    bool scan
  );
#endif
  int rnd_end();
#ifdef HA_CAN_BULK_ACCESS
  int pre_rnd_end();
#endif
  int rnd_next(
    uchar *buf
  );
  void position(
    const uchar *record
  );
  int rnd_pos(
    uchar *buf,
    uchar *pos
  );
  int cmp_ref(
    const uchar *ref1,
    const uchar *ref2
  );
  int ft_init();
  void ft_end();
  FT_INFO *ft_init_ext(
    uint flags,
    uint inx,
    String *key
  );
  int ft_read(
    uchar *buf
  );
  int pre_index_read_map(
    const uchar *key,
    key_part_map keypart_map,
    enum ha_rkey_function find_flag,
    bool use_parallel
  );
  int pre_index_first(bool use_parallel);
  int pre_index_last(bool use_parallel);
  int pre_index_read_last_map(
    const uchar *key,
    key_part_map keypart_map,
    bool use_parallel
  );
#ifdef HA_MRR_USE_DEFAULT_IMPL
  int pre_multi_range_read_next(
    bool use_parallel
  );
#else
  int pre_read_multi_range_first(
    KEY_MULTI_RANGE **found_range_p,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    HANDLER_BUFFER *buffer,
    bool use_parallel
  );
#endif
  int pre_read_range_first(
    const key_range *start_key,
    const key_range *end_key,
    bool eq_range,
    bool sorted,
    bool use_parallel
  );
  int pre_ft_read(bool use_parallel);
  int pre_rnd_next(bool use_parallel);
  int info(
    uint flag
  );
  ha_rows records_in_range(
    uint inx,
    key_range *start_key,
    key_range *end_key
  );
  int check_crd();
  int pre_records();
  ha_rows records();
  const char *table_type() const;
  ulonglong table_flags() const;
  const char *index_type(
    uint key_number
  );
  ulong index_flags(
    uint idx,
    uint part,
    bool all_parts
  ) const;
  uint max_supported_record_length() const;
  uint max_supported_keys() const;
  uint max_supported_key_parts() const;
  uint max_supported_key_length() const;
  uint max_supported_key_part_length() const;
  uint8 table_cache_type();
#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
  bool need_info_for_auto_inc();
#endif
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
  bool can_use_for_auto_inc_init();
#endif
  int update_auto_increment();
  void get_auto_increment(
    ulonglong offset,
    ulonglong increment,
    ulonglong nb_desired_values,
    ulonglong *first_value,
    ulonglong *nb_reserved_values
  );
  int reset_auto_increment(
    ulonglong value
  );
  void release_auto_increment();
#ifdef SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS
  void start_bulk_insert(
    ha_rows rows,
    uint flags
  );
#else
  void start_bulk_insert(
    ha_rows rows
  );
#endif
  int end_bulk_insert();
  int write_row(
    uchar *buf
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_write_row(
    uchar *buf
  );
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  void direct_update_init(
    THD *thd,
    bool hs_request
  );
#endif
  bool start_bulk_update();
  int exec_bulk_update(
    uint *dup_key_found
  );
  void end_bulk_update();
  int bulk_update_row(
    const uchar *old_data,
    uchar *new_data,
    uint *dup_key_found
  );
  int update_row(
    const uchar *old_data,
    uchar *new_data
  );
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  int direct_update_rows_init(
    uint mode,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    uchar *new_data
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_direct_update_rows_init(
    uint mode,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    uchar *new_data
  );
#endif
  int direct_update_rows(
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    uchar *new_data,
    uint *update_rows
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_direct_update_rows(
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    uchar *new_data,
    uint *update_rows
  );
#endif
#endif
  bool start_bulk_delete();
  int end_bulk_delete();
  int delete_row(
    const uchar *buf
  );
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  int direct_delete_rows_init(
    uint mode,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_direct_delete_rows_init(
    uint mode,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted
  );
#endif
  int direct_delete_rows(
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    uint *delete_rows
  );
#ifdef HA_CAN_BULK_ACCESS
  int pre_direct_delete_rows(
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    uint *delete_rows
  );
#endif
#endif
  int delete_all_rows();
  int truncate();
  double scan_time();
  double read_time(
    uint index,
    uint ranges,
    ha_rows rows
  );
#ifdef HA_CAN_BULK_ACCESS
  void bulk_req_exec();
#endif
  const key_map *keys_to_use_for_scanning();
  ha_rows estimate_rows_upper_bound();
  void print_error(
    int error,
    myf errflag
  );
  bool get_error_message(
    int error,
    String *buf
  );
  int create(
    const char *name,
    TABLE *form,
    HA_CREATE_INFO *info
  );
  void update_create_info(
    HA_CREATE_INFO* create_info
  );
  int rename_table(
    const char *from,
    const char *to
  );
  int delete_table(
    const char *name
  );
  bool is_crashed() const;
#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
  bool auto_repair(int error) const;
#else
  bool auto_repair() const;
#endif
  int disable_indexes(
    uint mode
  );
  int enable_indexes(
    uint mode
  );
  int check(
    THD* thd,
    HA_CHECK_OPT* check_opt
  );
  int repair(
    THD* thd,
    HA_CHECK_OPT* check_opt
  );
  bool check_and_repair(
    THD *thd
  );
  int analyze(
    THD* thd,
    HA_CHECK_OPT* check_opt
  );
  int optimize(
    THD* thd,
    HA_CHECK_OPT* check_opt
  );
  bool is_fatal_error(
    int error_num,
    uint flags
  );
  Field *get_top_table_field(
    uint16 field_index
  );
  Field *field_exchange(
    Field *field
  );
  const COND *cond_push(
    const COND* cond
  );
  void cond_pop();
  int info_push(
    uint info_type,
    void *info
  );
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
  void return_record_by_parent();
#endif
  TABLE *get_table();
  TABLE *get_top_table();
  void set_ft_discard_bitmap();
  void set_searched_bitmap();
  void set_clone_searched_bitmap();
  void set_searched_bitmap_from_item_list();
  void set_select_column_mode();
#ifdef WITH_PARTITION_STORAGE_ENGINE
  void check_select_column(bool rnd);
#endif
  bool check_and_start_bulk_update(
    spider_bulk_upd_start bulk_upd_start
  );
  int check_and_end_bulk_update(
    spider_bulk_upd_start bulk_upd_start
  );
  uint check_partitioned();
  void check_direct_order_limit();
  void check_distinct_key_query();
  bool is_sole_projection_field( uint16 field_index );
  int check_ha_range_eof();
  int drop_tmp_tables();
  bool handler_opened(
    int link_idx,
    uint tgt_conn_kind
  );
  void set_handler_opened(
    int link_idx
  );
  void clear_handler_opened(
    int link_idx,
    uint tgt_conn_kind
  );
  int close_opened_handler(
    int link_idx,
    bool release_conn
  );
  int index_handler_init();
  int rnd_handler_init();
  void set_error_mode();
  void backup_error_status();
  int check_error_mode(
    int error_num
  );
  int check_error_mode_eof(
    int error_num
  );
  int index_read_map_internal(
    uchar *buf,
    const uchar *key,
    key_part_map keypart_map,
    enum ha_rkey_function find_flag
  );
  int index_read_last_map_internal(
    uchar *buf,
    const uchar *key,
    key_part_map keypart_map
  );
  int index_first_internal(uchar *buf);
  int index_last_internal(uchar *buf);
  int read_range_first_internal(
    uchar *buf,
    const key_range *start_key,
    const key_range *end_key,
    bool eq_range,
    bool sorted
  );
#ifdef HA_MRR_USE_DEFAULT_IMPL
#else
  int read_multi_range_first_internal(
    uchar *buf,
    KEY_MULTI_RANGE **found_range_p,
    KEY_MULTI_RANGE *ranges,
    uint range_count,
    bool sorted,
    HANDLER_BUFFER *buffer
  );
#endif
  int ft_read_internal(uchar *buf);
  int rnd_next_internal(uchar *buf);
  void check_pre_call(
    bool use_parallel
  );
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  void check_insert_dup_update_pushdown();
#endif
#ifdef HA_CAN_BULK_ACCESS
  SPIDER_BULK_ACCESS_LINK *create_bulk_access_link();
  void delete_bulk_access_link(
    SPIDER_BULK_ACCESS_LINK *bulk_access_link
  );
  int sync_from_clone_source(
    ha_spider *spider
  );
#endif
  void sync_from_clone_source_base(
    ha_spider *spider
  );
  void set_first_link_idx();
  void reset_first_link_idx();
  int reset_sql_sql(
    ulong sql_type
  );
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  int reset_hs_sql(
    ulong sql_type
  );
  int reset_hs_keys(
    ulong sql_type
  );
  int reset_hs_upds(
    ulong sql_type
  );
  int reset_hs_strs(
    ulong sql_type
  );
  int reset_hs_strs_pos(
    ulong sql_type
  );
  int push_back_hs_upds(
    SPIDER_HS_STRING_REF &info
  );
#endif
  int append_tmp_table_and_sql_for_bka(
    const key_range *start_key
  );
  int reuse_tmp_table_and_sql_for_bka();
  int append_union_table_and_sql_for_bka(
    const key_range *start_key
  );
  int reuse_union_table_and_sql_for_bka();
  int append_insert_sql_part();
  int append_update_sql_part();
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  int append_increment_update_set_sql_part();
#endif
#endif
  int append_update_set_sql_part();
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  int append_direct_update_set_sql_part();
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  int append_direct_update_set_hs_part();
#endif
#endif
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
  int append_dup_update_pushdown_sql_part(
    const char *alias,
    uint alias_length
  );
  int append_update_columns_sql_part(
    const char *alias,
    uint alias_length
  );
  int check_update_columns_sql_part();
#endif
  int append_delete_sql_part();
  int append_select_sql_part(
    ulong sql_type
  );
  int append_table_select_sql_part(
    ulong sql_type
  );
  int append_key_select_sql_part(
    ulong sql_type,
    uint idx
  );
  int append_minimum_select_sql_part(
    ulong sql_type
  );
  int append_from_sql_part(
    ulong sql_type
  );
  int append_hint_after_table_sql_part(
    ulong sql_type
  );
  void set_where_pos_sql(
    ulong sql_type
  );
  void set_where_to_pos_sql(
    ulong sql_type
  );
  int check_item_type_sql(
    Item *item
  );
  int append_values_connector_sql_part(
    ulong sql_type
  );
  int append_values_terminator_sql_part(
    ulong sql_type
  );
  int append_union_table_connector_sql_part(
    ulong sql_type
  );
  int append_union_table_terminator_sql_part(
    ulong sql_type
  );
  int append_key_column_values_sql_part(
    const key_range *start_key,
    ulong sql_type
  );
  int append_key_column_values_with_name_sql_part(
    const key_range *start_key,
    ulong sql_type
  );
  int append_key_where_sql_part(
    const key_range *start_key,
    const key_range *end_key,
    ulong sql_type
  );
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  int append_key_where_hs_part(
    const key_range *start_key,
    const key_range *end_key,
    ulong sql_type
  );
#endif
  int append_match_where_sql_part(
    ulong sql_type
  );
  int append_condition_sql_part(
    const char *alias,
    uint alias_length,
    ulong sql_type,
    bool test_flg
  );
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
  int append_sum_select_sql_part(
    ulong sql_type,
    const char *alias,
    uint alias_length
  );
#endif
  int append_match_select_sql_part(
    ulong sql_type,
    const char *alias,
    uint alias_length
  );
  void set_order_pos_sql(
    ulong sql_type
  );
  void set_order_to_pos_sql(
    ulong sql_type
  );
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
  int append_group_by_sql_part(
    const char *alias,
    uint alias_length,
    ulong sql_type
  );
#endif
  int append_key_order_for_merge_with_alias_sql_part(
    const char *alias,
    uint alias_length,
    ulong sql_type
  );
  int append_key_order_for_direct_order_limit_with_alias_sql_part(
    const char *alias,
    uint alias_length,
    ulong sql_type
  );
  int append_key_order_with_alias_sql_part(
    const char *alias,
    uint alias_length,
    ulong sql_type
  );
  int append_limit_sql_part(
    longlong offset,
    longlong limit,
    ulong sql_type
  );
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  int append_limit_hs_part(
    longlong offset,
    longlong limit,
    ulong sql_type
  );
#endif
  int reappend_limit_sql_part(
    longlong offset,
    longlong limit,
    ulong sql_type
  );
  int append_insert_terminator_sql_part(
    ulong sql_type
  );
  int append_insert_values_sql_part(
    ulong sql_type
  );
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  int append_insert_values_hs_part(
    ulong sql_type
  );
#endif
  int append_into_sql_part(
    ulong sql_type
  );
  void set_insert_to_pos_sql(
    ulong sql_type
  );
  bool is_bulk_insert_exec_period(
    bool bulk_end
  );
  int append_select_lock_sql_part(
    ulong sql_type
  );
  int append_union_all_start_sql_part(
    ulong sql_type
  );
  int append_union_all_sql_part(
    ulong sql_type
  );
  int append_union_all_end_sql_part(
    ulong sql_type
  );
  int append_multi_range_cnt_sql_part(
    ulong sql_type,
    uint multi_range_cnt,
    bool with_comma
  );
  int append_multi_range_cnt_with_name_sql_part(
    ulong sql_type,
    uint multi_range_cnt
  );
  int append_delete_all_rows_sql_part(
    ulong sql_type
  );
  int append_update_sql(
    const TABLE *table,
    my_ptrdiff_t ptr_diff,
    bool bulk
  );
  int append_delete_sql(
    const TABLE *table,
    my_ptrdiff_t ptr_diff,
    bool bulk
  );
  bool sql_is_filled_up(
    ulong sql_type
  );
  bool sql_is_empty(
    ulong sql_type
  );
  bool support_multi_split_read_sql();
  bool support_bulk_update_sql();
  int bulk_tmp_table_insert();
  int bulk_tmp_table_end_bulk_insert();
  int bulk_tmp_table_rnd_init();
  int bulk_tmp_table_rnd_next();
  int bulk_tmp_table_rnd_end();
  int mk_bulk_tmp_table_and_bulk_start();
  void rm_bulk_tmp_table();
  bool bulk_tmp_table_created();
  int print_item_type(
    Item *item,
    spider_string *str,
    const char *alias,
    uint alias_length
  );
  bool support_use_handler_sql(
    int use_handler
  );
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
  bool support_bulk_access_hs() const;
#endif
  int init_union_table_name_pos_sql();
  int set_union_table_name_pos_sql();
};