1 #ifndef HA_MARIA_INCLUDED 2 #define HA_MARIA_INCLUDED 3 /* Copyright (C) 2006, 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 4 Copyright (c) 2009, 2020, MariaDB Corporation Ab 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; version 2 of the License. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ 18 19 #ifdef USE_PRAGMA_INTERFACE 20 #pragma interface /* gcc class implementation */ 21 #endif 22 23 /* class for the maria handler */ 24 25 #include "maria_def.h" 26 #include "handler.h" 27 #include "table.h" 28 29 #define HA_RECOVER_NONE 0 /* No automatic recover */ 30 #define HA_RECOVER_DEFAULT 1 /* Automatic recover active */ 31 #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */ 32 #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */ 33 #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */ 34 35 C_MODE_START 36 check_result_t index_cond_func_maria(void *arg); 37 C_MODE_END 38 39 extern TYPELIB maria_recover_typelib; 40 extern ulonglong maria_recover_options; 41 42 /* 43 In the ha_maria class there are a few virtual methods that are not marked as 44 'final'. This is because they are re-defined by the ha_s3 engine. 45 */ 46 47 class __attribute__((visibility("default"))) ha_maria :public handler 48 { 49 public: 50 MARIA_HA *file; 51 private: 52 ulonglong int_table_flags; 53 MARIA_RECORD_POS remember_pos; 54 char *data_file_name, *index_file_name; 55 enum data_file_type data_file_type; 56 bool can_enable_indexes; 57 /** 58 If a transactional table is doing bulk insert with a single 59 UNDO_BULK_INSERT with/without repair. 60 */ 61 uint8 bulk_insert_single_undo; 62 int repair(THD * thd, HA_CHECK *param, bool optimize); 63 int zerofill(THD * thd, HA_CHECK_OPT *check_opt); 64 65 public: 66 ha_maria(handlerton *hton, TABLE_SHARE * table_arg); ~ha_maria()67 ~ha_maria() {} 68 handler *clone(const char *name, MEM_ROOT *mem_root) override final; 69 const char *index_type(uint key_number) override final; table_flags()70 ulonglong table_flags() const override final 71 { return int_table_flags; } 72 ulong index_flags(uint inx, uint part, bool all_parts) const override final; max_supported_keys()73 uint max_supported_keys() const override final 74 { return MARIA_MAX_KEY; } 75 uint max_supported_key_length() const override final; max_supported_key_part_length()76 uint max_supported_key_part_length() const override final 77 { return max_supported_key_length(); } 78 enum row_type get_row_type() const override final; 79 void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) override final; 80 virtual double scan_time() override final; 81 82 int open(const char *name, int mode, uint test_if_locked) override; 83 int close(void) override final; 84 int write_row(const uchar * buf) override; 85 int update_row(const uchar * old_data, const uchar * new_data) override; 86 int delete_row(const uchar * buf) override; 87 int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map, 88 enum ha_rkey_function find_flag) override final; 89 int index_read_idx_map(uchar * buf, uint idx, const uchar * key, 90 key_part_map keypart_map, 91 enum ha_rkey_function find_flag) override final; 92 int index_read_last_map(uchar * buf, const uchar * key, 93 key_part_map keypart_map) override final; 94 int index_next(uchar * buf) override final; 95 int index_prev(uchar * buf) override final; 96 int index_first(uchar * buf) override final; 97 int index_last(uchar * buf) override final; 98 int index_next_same(uchar * buf, const uchar * key, uint keylen) override final; ft_init()99 int ft_init() override final 100 { 101 if (!ft_handler) 102 return 1; 103 ft_handler->please->reinit_search(ft_handler); 104 return 0; 105 } 106 FT_INFO *ft_init_ext(uint flags, uint inx, String * key) override final; 107 int ft_read(uchar * buf) override final; 108 int index_init(uint idx, bool sorted) override final; 109 int index_end() override final; 110 int rnd_init(bool scan) override final; 111 int rnd_end(void) override final; 112 int rnd_next(uchar * buf) override final; 113 int rnd_pos(uchar * buf, uchar * pos) override final; 114 int remember_rnd_pos() override final; 115 int restart_rnd_next(uchar * buf) override final; 116 void position(const uchar * record) override final; 117 int info(uint) override final; 118 int info(uint, my_bool); 119 int extra(enum ha_extra_function operation) override final; 120 int extra_opt(enum ha_extra_function operation, ulong cache_size) override final; 121 int reset(void) override final; 122 int external_lock(THD * thd, int lock_type) override; 123 int start_stmt(THD *thd, thr_lock_type lock_type) override final; 124 int delete_all_rows(void) override final; 125 int disable_indexes(uint mode) override final; 126 int enable_indexes(uint mode) override final; 127 int indexes_are_disabled(void) override final; 128 void start_bulk_insert(ha_rows rows, uint flags) override final; 129 int end_bulk_insert() override final; 130 ha_rows records_in_range(uint inx, const key_range *min_key, 131 const key_range *max_key, 132 page_range *pages) override final; 133 void update_create_info(HA_CREATE_INFO * create_info) override final; 134 int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info) override; 135 THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, 136 enum thr_lock_type lock_type) override final; 137 virtual void get_auto_increment(ulonglong offset, ulonglong increment, 138 ulonglong nb_desired_values, 139 ulonglong *first_value, 140 ulonglong *nb_reserved_values) override final; 141 int rename_table(const char *from, const char *to) override; 142 int delete_table(const char *name) override; 143 void drop_table(const char *name) override; 144 int check(THD * thd, HA_CHECK_OPT * check_opt) override; 145 int analyze(THD * thd, HA_CHECK_OPT * check_opt) override; 146 int repair(THD * thd, HA_CHECK_OPT * check_opt) override; 147 int check_for_upgrade(HA_CHECK_OPT *check_opt) override; 148 bool check_and_repair(THD * thd) override final; 149 bool is_crashed() const override final; 150 bool is_changed() const; 151 bool auto_repair(int error) const override final; 152 int optimize(THD * thd, HA_CHECK_OPT * check_opt) override final; 153 int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt) override final; 154 int preload_keys(THD * thd, HA_CHECK_OPT * check_opt) override; 155 bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes) override final; 156 #ifdef HAVE_QUERY_CACHE 157 my_bool register_query_cache_table(THD *thd, const char *table_key, 158 uint key_length, 159 qc_engine_callback 160 *engine_callback, 161 ulonglong *engine_data) override final; 162 #endif file_ptr(void)163 MARIA_HA *file_ptr(void) 164 { 165 return file; 166 } 167 static bool has_active_transaction(THD *thd); 168 static int implicit_commit(THD *thd, bool new_trn); 169 /** 170 * Multi Range Read interface 171 */ 172 int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, 173 uint n_ranges, uint mode, HANDLER_BUFFER *buf) override final; 174 int multi_range_read_next(range_id_t *range_info) override final; 175 ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, 176 void *seq_init_param, 177 uint n_ranges, uint *bufsz, 178 uint *flags, Cost_estimate *cost) override final; 179 ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, 180 uint key_parts, uint *bufsz, 181 uint *flags, Cost_estimate *cost) override final; 182 int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size) override final; 183 184 /* Index condition pushdown implementation */ 185 Item *idx_cond_push(uint keyno, Item* idx_cond) override final; 186 187 int find_unique_row(uchar *record, uint unique_idx) override final; 188 189 /* Following functions are needed by the S3 handler */ s3_open_args()190 virtual S3_INFO *s3_open_args() { return 0; } register_handler(MARIA_HA * file)191 virtual void register_handler(MARIA_HA *file) {} 192 193 private: 194 DsMrr_impl ds_mrr; 195 friend check_result_t index_cond_func_maria(void *arg); 196 friend void reset_thd_trn(THD *thd); 197 friend class ha_s3; 198 }; 199 200 #endif /* HA_MARIA_INCLUDED */ 201