1 : /* Copyright (C) 2006,2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
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 :
17 : #ifdef USE_PRAGMA_INTERFACE
18 : #pragma interface /* gcc class implementation */
19 : #endif
20 :
21 : /* class for the maria handler */
22 :
23 : #include <maria.h>
24 :
25 : #define HA_RECOVER_NONE 0 /* No automatic recover */
26 : #define HA_RECOVER_DEFAULT 1 /* Automatic recover active */
27 : #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */
28 : #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */
29 : #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */
30 :
31 : extern ulong maria_sort_buffer_size;
32 : extern TYPELIB maria_recover_typelib;
33 : extern ulong maria_recover_options;
34 :
35 : class ha_maria :public handler
36 : {
37 : MARIA_HA *file;
38 : ulonglong int_table_flags;
39 : MARIA_RECORD_POS remember_pos;
40 : char *data_file_name, *index_file_name;
41 : enum data_file_type data_file_type;
42 : bool can_enable_indexes;
43 : /**
44 : If a transactional table is doing bulk insert with a single
45 : UNDO_BULK_INSERT with/without repair.
46 : */
47 : uint8 bulk_insert_single_undo;
48 : int repair(THD * thd, HA_CHECK *param, bool optimize);
49 : int zerofill(THD * thd, HA_CHECK_OPT *check_opt);
50 :
51 : public:
52 : ha_maria(handlerton *hton, TABLE_SHARE * table_arg);
53 10 : ~ha_maria() {}
54 : handler *clone(MEM_ROOT *mem_root);
55 0 : const char *table_type() const
56 0 : { return "MARIA"; }
57 : const char *index_type(uint key_number);
58 : const char **bas_ext() const;
59 18 : ulonglong table_flags() const
60 18 : { return int_table_flags; }
61 0 : ulong index_flags(uint inx, uint part, bool all_parts) const
62 : {
63 : return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ?
64 : 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
65 0 : HA_READ_ORDER | HA_KEYREAD_ONLY);
66 : }
67 0 : uint max_supported_keys() const
68 0 : { return MARIA_MAX_KEY; }
69 : uint max_supported_key_length() const;
70 0 : uint max_supported_key_part_length() const
71 0 : { return max_supported_key_length(); }
72 : enum row_type get_row_type() const;
73 : uint checksum() const;
74 : virtual double scan_time();
75 :
76 : int open(const char *name, int mode, uint test_if_locked);
77 : int close(void);
78 : int write_row(uchar * buf);
79 : int update_row(const uchar * old_data, uchar * new_data);
80 : int delete_row(const uchar * buf);
81 : int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map,
82 : enum ha_rkey_function find_flag);
83 : int index_read_idx_map(uchar * buf, uint idx, const uchar * key,
84 : key_part_map keypart_map,
85 : enum ha_rkey_function find_flag);
86 : int index_read_last_map(uchar * buf, const uchar * key,
87 : key_part_map keypart_map);
88 : int index_next(uchar * buf);
89 : int index_prev(uchar * buf);
90 : int index_first(uchar * buf);
91 : int index_last(uchar * buf);
92 : int index_next_same(uchar * buf, const uchar * key, uint keylen);
93 0 : int ft_init()
94 : {
95 0 : if (!ft_handler)
96 0 : return 1;
97 0 : ft_handler->please->reinit_search(ft_handler);
98 0 : return 0;
99 : }
100 0 : FT_INFO *ft_init_ext(uint flags, uint inx, String * key)
101 : {
102 : return maria_ft_init_search(flags, file, inx,
103 : (uchar *) key->ptr(), key->length(),
104 0 : key->charset(), table->record[0]);
105 : }
106 : int ft_read(uchar * buf);
107 : int rnd_init(bool scan);
108 : int rnd_end(void);
109 : int rnd_next(uchar * buf);
110 : int rnd_pos(uchar * buf, uchar * pos);
111 : int remember_rnd_pos();
112 : int restart_rnd_next(uchar * buf);
113 : void position(const uchar * record);
114 : int info(uint);
115 : int info(uint, my_bool);
116 : int extra(enum ha_extra_function operation);
117 : int extra_opt(enum ha_extra_function operation, ulong cache_size);
118 : int reset(void);
119 : int external_lock(THD * thd, int lock_type);
120 : int start_stmt(THD *thd, thr_lock_type lock_type);
121 : int delete_all_rows(void);
122 : int disable_indexes(uint mode);
123 : int enable_indexes(uint mode);
124 : int indexes_are_disabled(void);
125 : void start_bulk_insert(ha_rows rows);
126 : int end_bulk_insert(bool abort);
127 : ha_rows records_in_range(uint inx, key_range * min_key, key_range * max_key);
128 : void update_create_info(HA_CREATE_INFO * create_info);
129 : int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info);
130 : THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
131 : enum thr_lock_type lock_type);
132 : virtual void get_auto_increment(ulonglong offset, ulonglong increment,
133 : ulonglong nb_desired_values,
134 : ulonglong *first_value,
135 : ulonglong *nb_reserved_values);
136 : int rename_table(const char *from, const char *to);
137 : int delete_table(const char *name);
138 : int check(THD * thd, HA_CHECK_OPT * check_opt);
139 : int analyze(THD * thd, HA_CHECK_OPT * check_opt);
140 : int repair(THD * thd, HA_CHECK_OPT * check_opt);
141 : bool check_and_repair(THD * thd);
142 : bool is_crashed() const;
143 : bool is_changed() const;
144 0 : bool auto_repair() const { return 1; }
145 : int optimize(THD * thd, HA_CHECK_OPT * check_opt);
146 : int restore(THD * thd, HA_CHECK_OPT * check_opt);
147 : int backup(THD * thd, HA_CHECK_OPT * check_opt);
148 : int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt);
149 : int preload_keys(THD * thd, HA_CHECK_OPT * check_opt);
150 : bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
151 : #ifdef HAVE_REPLICATION
152 : int dump(THD * thd, int fd);
153 : int net_read_dump(NET * net);
154 : #endif
155 : #ifdef HAVE_QUERY_CACHE
156 : my_bool register_query_cache_table(THD *thd, char *table_key,
157 : uint key_length,
158 : qc_engine_callback
159 : *engine_callback,
160 : ulonglong *engine_data);
161 : #endif
162 : MARIA_HA *file_ptr(void)
163 : {
164 : return file;
165 : }
166 : static int implicit_commit(THD *thd, bool new_trn);
167 : };
|