1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2006 MySQL 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 |
/* This file is included by all internal myisam files */
|
|
17 |
||
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
18 |
#ifndef MYISAMDEF_H
|
77.1.3
by Monty Taylor
MyISAM cleanups. |
19 |
#define MYISAMDEF_H
|
20 |
||
1
by brian
clean slate |
21 |
#include "myisam.h" /* Structs & some defines */ |
22 |
#include "myisampack.h" /* packing of keys */ |
|
212.5.15
by Monty Taylor
Moved my_tree. |
23 |
#include <mysys/my_tree.h> |
212.5.13
by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys. |
24 |
#include <mysys/my_pthread.h> |
212.5.7
by Monty Taylor
Move thr_*h to mysys. |
25 |
#include <mysys/thr_lock.h> |
543
by Monty Taylor
Renamed drizzle_common again. Removed sql_common. (empty) |
26 |
#include <drizzled/common.h> |
1
by brian
clean slate |
27 |
|
489.1.6
by Monty Taylor
Removed RAID garbage. |
28 |
#if defined(my_write)
|
1
by brian
clean slate |
29 |
#undef my_write /* undef map from my_nosys; We need test-if-disk full */ |
30 |
#endif
|
|
31 |
||
32 |
typedef struct st_mi_status_info |
|
33 |
{
|
|
34 |
ha_rows records; /* Rows in table */ |
|
35 |
ha_rows del; /* Removed rows */ |
|
36 |
my_off_t empty; /* lost space in datafile */ |
|
37 |
my_off_t key_empty; /* lost space in indexfile */ |
|
38 |
my_off_t key_file_length; |
|
39 |
my_off_t data_file_length; |
|
40 |
ha_checksum checksum; |
|
41 |
} MI_STATUS_INFO; |
|
42 |
||
43 |
typedef struct st_mi_state_info |
|
44 |
{
|
|
45 |
struct { /* Fileheader */ |
|
481
by Brian Aker
Remove all of uchar. |
46 |
unsigned char file_version[4]; |
47 |
unsigned char options[2]; |
|
48 |
unsigned char header_length[2]; |
|
49 |
unsigned char state_info_length[2]; |
|
50 |
unsigned char base_info_length[2]; |
|
51 |
unsigned char base_pos[2]; |
|
52 |
unsigned char key_parts[2]; /* Key parts */ |
|
53 |
unsigned char unique_key_parts[2]; /* Key parts + unique parts */ |
|
54 |
unsigned char keys; /* number of keys in file */ |
|
55 |
unsigned char uniques; /* number of UNIQUE definitions */ |
|
56 |
unsigned char language; /* Language for indexes */ |
|
57 |
unsigned char max_block_size_index; /* max keyblock size */ |
|
58 |
unsigned char fulltext_keys; |
|
59 |
unsigned char not_used; /* To align to 8 */ |
|
1
by brian
clean slate |
60 |
} header; |
61 |
||
62 |
MI_STATUS_INFO state; |
|
63 |
ha_rows split; /* number of split blocks */ |
|
64 |
my_off_t dellink; /* Link to next removed block */ |
|
151
by Brian Aker
Ulonglong to uint64_t |
65 |
uint64_t auto_increment; |
1
by brian
clean slate |
66 |
ulong process; /* process that updated table last */ |
67 |
ulong unique; /* Unique number for this process */ |
|
68 |
ulong update_count; /* Updated for each write lock */ |
|
69 |
ulong status; |
|
70 |
ulong *rec_per_key_part; |
|
71 |
my_off_t *key_root; /* Start of key trees */ |
|
72 |
my_off_t *key_del; /* delete links for trees */ |
|
73 |
my_off_t rec_per_key_rows; /* Rows when calculating rec_per_key */ |
|
74 |
||
75 |
ulong sec_index_changed; /* Updated when new sec_index */ |
|
76 |
ulong sec_index_used; /* which extra index are in use */ |
|
151
by Brian Aker
Ulonglong to uint64_t |
77 |
uint64_t key_map; /* Which keys are in use */ |
1
by brian
clean slate |
78 |
ha_checksum checksum; /* Table checksum */ |
79 |
ulong version; /* timestamp of create */ |
|
80 |
time_t create_time; /* Time when created database */ |
|
81 |
time_t recover_time; /* Time for last recover */ |
|
82 |
time_t check_time; /* Time for last check */ |
|
83 |
uint sortkey; /* sorted by this key (not used) */ |
|
482
by Brian Aker
Remove uint. |
84 |
uint32_t open_count; |
206
by Brian Aker
Removed final uint dead types. |
85 |
uint8_t changed; /* Changed since myisamchk */ |
1
by brian
clean slate |
86 |
|
87 |
/* the following isn't saved on disk */
|
|
482
by Brian Aker
Remove uint. |
88 |
uint32_t state_diff_length; /* Should be 0 */ |
1
by brian
clean slate |
89 |
uint state_length; /* Length of state header in file */ |
90 |
ulong *key_info; |
|
91 |
} MI_STATE_INFO; |
|
92 |
||
93 |
#define MI_STATE_INFO_SIZE (24+14*8+7*4+2*2+8)
|
|
94 |
#define MI_STATE_KEY_SIZE 8
|
|
95 |
#define MI_STATE_KEYBLOCK_SIZE 8
|
|
96 |
#define MI_STATE_KEYSEG_SIZE 4
|
|
97 |
#define MI_STATE_EXTRA_SIZE ((MI_MAX_KEY+MI_MAX_KEY_BLOCK_SIZE)*MI_STATE_KEY_SIZE + MI_MAX_KEY*MI_MAX_KEY_SEG*MI_STATE_KEYSEG_SIZE)
|
|
98 |
#define MI_KEYDEF_SIZE (2+ 5*2)
|
|
99 |
#define MI_UNIQUEDEF_SIZE (2+1+1)
|
|
100 |
#define HA_KEYSEG_SIZE (6+ 2*2 + 4*2)
|
|
101 |
#define MI_COLUMNDEF_SIZE (2*3+1)
|
|
102 |
#define MI_BASE_INFO_SIZE (5*8 + 8*4 + 4 + 4*2 + 16)
|
|
103 |
#define MI_INDEX_BLOCK_MARGIN 16 /* Safety margin for .MYI tables */ |
|
104 |
||
105 |
typedef struct st_mi_base_info |
|
106 |
{
|
|
107 |
my_off_t keystart; /* Start of keys */ |
|
108 |
my_off_t max_data_file_length; |
|
109 |
my_off_t max_key_file_length; |
|
110 |
my_off_t margin_key_file_length; |
|
111 |
ha_rows records,reloc; /* Create information */ |
|
112 |
ulong mean_row_length; /* Create information */ |
|
113 |
ulong reclength; /* length of unpacked record */ |
|
114 |
ulong pack_reclength; /* Length of full packed rec. */ |
|
115 |
ulong min_pack_length; |
|
116 |
ulong max_pack_length; /* Max possibly length of packed rec.*/ |
|
117 |
ulong min_block_length; |
|
118 |
ulong fields, /* fields in table */ |
|
119 |
pack_fields; /* packed fields in table */ |
|
482
by Brian Aker
Remove uint. |
120 |
uint32_t rec_reflength; /* = 2-8 */ |
121 |
uint32_t key_reflength; /* = 2-8 */ |
|
122 |
uint32_t keys; /* same as in state.header */ |
|
123 |
uint32_t auto_key; /* Which key-1 is a auto key */ |
|
124 |
uint32_t blobs; /* Number of blobs */ |
|
125 |
uint32_t pack_bits; /* Length of packed bits */ |
|
126 |
uint32_t max_key_block_length; /* Max block length */ |
|
127 |
uint32_t max_key_length; /* Max key length */ |
|
1
by brian
clean slate |
128 |
/* Extra allocation when using dynamic record format */
|
482
by Brian Aker
Remove uint. |
129 |
uint32_t extra_alloc_bytes; |
130 |
uint32_t extra_alloc_procent; |
|
1
by brian
clean slate |
131 |
/* Info about raid */
|
482
by Brian Aker
Remove uint. |
132 |
uint32_t raid_type,raid_chunks; |
489.1.6
by Monty Taylor
Removed RAID garbage. |
133 |
uint32_t raid_chunksize; |
1
by brian
clean slate |
134 |
/* The following are from the header */
|
482
by Brian Aker
Remove uint. |
135 |
uint32_t key_parts,all_key_parts; |
1
by brian
clean slate |
136 |
} MI_BASE_INFO; |
137 |
||
138 |
||
139 |
/* Structs used intern in database */
|
|
140 |
||
141 |
typedef struct st_mi_blob /* Info of record */ |
|
142 |
{
|
|
143 |
ulong offset; /* Offset to blob in record */ |
|
482
by Brian Aker
Remove uint. |
144 |
uint32_t pack_length; /* Type of packed length */ |
1
by brian
clean slate |
145 |
ulong length; /* Calc:ed for each record */ |
146 |
} MI_BLOB; |
|
147 |
||
148 |
||
149 |
typedef struct st_mi_isam_pack { |
|
150 |
ulong header_length; |
|
482
by Brian Aker
Remove uint. |
151 |
uint32_t ref_length; |
481
by Brian Aker
Remove all of uchar. |
152 |
unsigned char version; |
1
by brian
clean slate |
153 |
} MI_PACK; |
154 |
||
155 |
#define MAX_NONMAPPED_INSERTS 1000
|
|
156 |
||
157 |
typedef struct st_mi_isam_share { /* Shared between opens */ |
|
158 |
MI_STATE_INFO state; |
|
159 |
MI_BASE_INFO base; |
|
160 |
MI_KEYDEF ft2_keyinfo; /* Second-level ft-key definition */ |
|
161 |
MI_KEYDEF *keyinfo; /* Key definitions */ |
|
162 |
MI_UNIQUEDEF *uniqueinfo; /* unique definitions */ |
|
163 |
HA_KEYSEG *keyparts; /* key part info */ |
|
164 |
MI_COLUMNDEF *rec; /* Pointer to field information */ |
|
165 |
MI_PACK pack; /* Data about packed records */ |
|
166 |
MI_BLOB *blobs; /* Pointer to blobs */ |
|
167 |
LIST *in_use; /* List of threads using this table */ |
|
168 |
char *unique_file_name; /* realpath() of index file */ |
|
169 |
char *data_file_name, /* Resolved path names from symlinks */ |
|
170 |
*index_file_name; |
|
481
by Brian Aker
Remove all of uchar. |
171 |
unsigned char *file_map; /* mem-map of file if possible */ |
1
by brian
clean slate |
172 |
KEY_CACHE *key_cache; /* ref to the current key cache */ |
173 |
MI_DECODE_TREE *decode_trees; |
|
206
by Brian Aker
Removed final uint dead types. |
174 |
uint16_t *decode_tables; |
481
by Brian Aker
Remove all of uchar. |
175 |
int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*); |
176 |
int (*write_record)(struct st_myisam_info*, const unsigned char*); |
|
177 |
int (*update_record)(struct st_myisam_info*, my_off_t, const unsigned char*); |
|
1
by brian
clean slate |
178 |
int (*delete_record)(struct st_myisam_info*); |
481
by Brian Aker
Remove all of uchar. |
179 |
int (*read_rnd)(struct st_myisam_info*, unsigned char*, my_off_t, bool); |
180 |
int (*compare_record)(struct st_myisam_info*, const unsigned char *); |
|
1
by brian
clean slate |
181 |
/* Function to use for a row checksum. */
|
481
by Brian Aker
Remove all of uchar. |
182 |
ha_checksum (*calc_checksum)(struct st_myisam_info*, const unsigned char *); |
1
by brian
clean slate |
183 |
int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *, |
481
by Brian Aker
Remove all of uchar. |
184 |
const unsigned char *record, my_off_t pos); |
185 |
size_t (*file_read)(MI_INFO *, unsigned char *, size_t, my_off_t, myf); |
|
186 |
size_t (*file_write)(MI_INFO *, const unsigned char *, size_t, my_off_t, myf); |
|
1
by brian
clean slate |
187 |
invalidator_by_filename invalidator; /* query cache invalidator */ |
188 |
ulong this_process; /* processid */ |
|
189 |
ulong last_process; /* For table-change-check */ |
|
190 |
ulong last_version; /* Version on start */ |
|
191 |
ulong options; /* Options used */ |
|
192 |
ulong min_pack_length; /* Theese are used by packed data */ |
|
193 |
ulong max_pack_length; |
|
194 |
ulong state_diff_length; |
|
195 |
uint rec_reflength; /* rec_reflength in use now */ |
|
482
by Brian Aker
Remove uint. |
196 |
uint32_t unique_name_length; |
1
by brian
clean slate |
197 |
File kfile; /* Shared keyfile */ |
198 |
File data_file; /* Shared data file */ |
|
199 |
int mode; /* mode of file on open */ |
|
200 |
uint reopen; /* How many times reopened */ |
|
201 |
uint w_locks,r_locks,tot_locks; /* Number of read/write locks */ |
|
202 |
uint blocksize; /* blocksize of keyfile */ |
|
203 |
myf write_flag; |
|
204 |
enum data_file_type data_file_type; |
|
205 |
/* Below flag is needed to make log tables work with concurrent insert */
|
|
281
by Brian Aker
Converted myisam away from my_bool |
206 |
bool is_log_table; |
1
by brian
clean slate |
207 |
|
281
by Brian Aker
Converted myisam away from my_bool |
208 |
bool changed, /* If changed since lock */ |
1
by brian
clean slate |
209 |
global_changed, /* If changed since open */ |
210 |
not_flushed, |
|
211 |
temporary,delay_key_write, |
|
212 |
concurrent_insert; |
|
213 |
THR_LOCK lock; |
|
214 |
pthread_mutex_t intern_lock; /* Locking for use with _locking */ |
|
215 |
rw_lock_t *key_root_lock; |
|
216 |
my_off_t mmaped_length; |
|
482
by Brian Aker
Remove uint. |
217 |
uint32_t nonmmaped_inserts; /* counter of writing in non-mmaped |
1
by brian
clean slate |
218 |
area */
|
219 |
rw_lock_t mmap_lock; |
|
220 |
} MYISAM_SHARE; |
|
221 |
||
222 |
||
482
by Brian Aker
Remove uint. |
223 |
typedef uint32_t mi_bit_type; |
1
by brian
clean slate |
224 |
|
225 |
typedef struct st_mi_bit_buff { /* Used for packing of record */ |
|
226 |
mi_bit_type current_byte; |
|
482
by Brian Aker
Remove uint. |
227 |
uint32_t bits; |
481
by Brian Aker
Remove all of uchar. |
228 |
unsigned char *pos,*end,*blob_pos,*blob_end; |
482
by Brian Aker
Remove uint. |
229 |
uint32_t error; |
1
by brian
clean slate |
230 |
} MI_BIT_BUFF; |
231 |
||
232 |
||
281
by Brian Aker
Converted myisam away from my_bool |
233 |
typedef bool (*index_cond_func_t)(void *param); |
1
by brian
clean slate |
234 |
|
235 |
struct st_myisam_info { |
|
236 |
MYISAM_SHARE *s; /* Shared between open:s */ |
|
237 |
MI_STATUS_INFO *state,save_state; |
|
238 |
MI_BLOB *blobs; /* Pointer to blobs */ |
|
239 |
MI_BIT_BUFF bit_buff; |
|
240 |
/* accumulate indexfile changes between write's */
|
|
241 |
TREE *bulk_insert; |
|
242 |
LIST in_use; /* Thread using this table */ |
|
243 |
char *filename; /* parameter to open filename */ |
|
481
by Brian Aker
Remove all of uchar. |
244 |
unsigned char *buff, /* Temp area for key */ |
1
by brian
clean slate |
245 |
*lastkey,*lastkey2; /* Last used search key */ |
481
by Brian Aker
Remove all of uchar. |
246 |
unsigned char *first_mbr_key; /* Searhed spatial key */ |
247 |
unsigned char *rec_buff; /* Tempbuff for recordpack */ |
|
248 |
unsigned char *int_keypos, /* Save position for next/previous */ |
|
1
by brian
clean slate |
249 |
*int_maxpos; /* -""- */ |
482
by Brian Aker
Remove uint. |
250 |
uint32_t int_nod_flag; /* -""- */ |
205
by Brian Aker
uint32 -> uin32_t |
251 |
uint32_t int_keytree_version; /* -""- */ |
481
by Brian Aker
Remove all of uchar. |
252 |
int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*); |
1
by brian
clean slate |
253 |
invalidator_by_filename invalidator; /* query cache invalidator */ |
254 |
ulong this_unique; /* uniq filenumber or thread */ |
|
255 |
ulong last_unique; /* last unique number */ |
|
256 |
ulong this_loop; /* counter for this open */ |
|
257 |
ulong last_loop; /* last used counter */ |
|
258 |
my_off_t lastpos, /* Last record position */ |
|
259 |
nextpos; /* Position to next record */ |
|
260 |
my_off_t save_lastpos; |
|
261 |
my_off_t pos; /* Intern variable */ |
|
262 |
my_off_t last_keypage; /* Last key page read */ |
|
263 |
my_off_t last_search_keypage; /* Last keypage when searching */ |
|
264 |
my_off_t dupp_key_pos; |
|
265 |
ha_checksum checksum; /* Temp storage for row checksum */ |
|
266 |
/* QQ: the folloing two xxx_length fields should be removed,
|
|
267 |
as they are not compatible with parallel repair */
|
|
268 |
ulong packed_length,blob_length; /* Length of found, packed record */ |
|
269 |
int dfile; /* The datafile */ |
|
482
by Brian Aker
Remove uint. |
270 |
uint32_t opt_flag; /* Optim. for space/speed */ |
271 |
uint32_t update; /* If file changed since open */ |
|
1
by brian
clean slate |
272 |
int lastinx; /* Last used index */ |
273 |
uint lastkey_length; /* Length of key in lastkey */ |
|
274 |
uint last_rkey_length; /* Last length in mi_rkey() */ |
|
275 |
enum ha_rkey_function last_key_func; /* CONTAIN, OVERLAP, etc */ |
|
482
by Brian Aker
Remove uint. |
276 |
uint32_t save_lastkey_length; |
277 |
uint32_t pack_key_length; /* For MYISAMMRG */ |
|
206
by Brian Aker
Removed final uint dead types. |
278 |
uint16_t last_used_keyseg; /* For MyISAMMRG */ |
1
by brian
clean slate |
279 |
int errkey; /* Got last error on this key */ |
280 |
int lock_type; /* How database was locked */ |
|
281 |
int tmp_lock_type; /* When locked by readinfo */ |
|
282 |
uint data_changed; /* Somebody has changed data */ |
|
283 |
uint save_update; /* When using KEY_READ */ |
|
284 |
int save_lastinx; |
|
285 |
LIST open_list; |
|
286 |
IO_CACHE rec_cache; /* When cacheing records */ |
|
482
by Brian Aker
Remove uint. |
287 |
uint32_t preload_buff_size; /* When preloading indexes */ |
1
by brian
clean slate |
288 |
myf lock_wait; /* is 0 or MY_DONT_WAIT */ |
281
by Brian Aker
Converted myisam away from my_bool |
289 |
bool was_locked; /* Was locked in panic */ |
290 |
bool append_insert_at_end; /* Set if concurrent insert */ |
|
291 |
bool quick_mode; |
|
292 |
bool page_changed; /* If info->buff can't be used for rnext */ |
|
293 |
bool buff_used; /* If info->buff has to be reread for rnext */ |
|
294 |
bool once_flags; /* For MYISAMMRG */ |
|
1
by brian
clean slate |
295 |
|
296 |
index_cond_func_t index_cond_func; /* Index condition function */ |
|
297 |
void *index_cond_func_arg; /* parameter for the func */ |
|
298 |
THR_LOCK_DATA lock; |
|
481
by Brian Aker
Remove all of uchar. |
299 |
unsigned char *rtree_recursion_state; /* For RTREE */ |
1
by brian
clean slate |
300 |
int rtree_recursion_depth; |
301 |
};
|
|
302 |
||
303 |
typedef struct st_buffpek { |
|
304 |
my_off_t file_pos; /* Where we are in the sort file */ |
|
481
by Brian Aker
Remove all of uchar. |
305 |
unsigned char *base,*key; /* Key pointers */ |
1
by brian
clean slate |
306 |
ha_rows count; /* Number of rows in table */ |
307 |
ulong mem_count; /* numbers of keys in memory */ |
|
308 |
ulong max_keys; /* Max keys in buffert */ |
|
309 |
} BUFFPEK; |
|
310 |
||
311 |
typedef struct st_mi_sort_param |
|
312 |
{
|
|
313 |
pthread_t thr; |
|
314 |
IO_CACHE read_cache, tempfile, tempfile_for_exceptions; |
|
315 |
DYNAMIC_ARRAY buffpek; |
|
316 |
MI_BIT_BUFF bit_buff; /* For parallel repair of packrec. */ |
|
317 |
||
318 |
/*
|
|
319 |
The next two are used to collect statistics, see update_key_parts for
|
|
320 |
description.
|
|
321 |
*/
|
|
151
by Brian Aker
Ulonglong to uint64_t |
322 |
uint64_t unique[MI_MAX_KEY_SEG+1]; |
323 |
uint64_t notnull[MI_MAX_KEY_SEG+1]; |
|
1
by brian
clean slate |
324 |
|
325 |
my_off_t pos,max_pos,filepos,start_recpos; |
|
482
by Brian Aker
Remove uint. |
326 |
uint32_t key, key_length,real_key_length,sortbuff_size; |
327 |
uint32_t maxbuffers, keys, find_length, sort_keys_length; |
|
281
by Brian Aker
Converted myisam away from my_bool |
328 |
bool fix_datafile, master; |
329 |
bool calc_checksum; /* calculate table checksum */ |
|
1
by brian
clean slate |
330 |
MI_KEYDEF *keyinfo; |
331 |
HA_KEYSEG *seg; |
|
332 |
SORT_INFO *sort_info; |
|
481
by Brian Aker
Remove all of uchar. |
333 |
unsigned char **sort_keys; |
334 |
unsigned char *rec_buff; |
|
1
by brian
clean slate |
335 |
void *wordlist, *wordptr; |
336 |
MEM_ROOT wordroot; |
|
481
by Brian Aker
Remove all of uchar. |
337 |
unsigned char *record; |
1
by brian
clean slate |
338 |
MY_TMPDIR *tmpdir; |
339 |
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *); |
|
340 |
int (*key_read)(struct st_mi_sort_param *,void *); |
|
341 |
int (*key_write)(struct st_mi_sort_param *, const void *); |
|
342 |
void (*lock_in_memory)(MI_CHECK *); |
|
481
by Brian Aker
Remove all of uchar. |
343 |
int (*write_keys)(struct st_mi_sort_param *, register unsigned char **, |
482
by Brian Aker
Remove uint. |
344 |
uint32_t , struct st_buffpek *, IO_CACHE *); |
1
by brian
clean slate |
345 |
unsigned int (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); |
481
by Brian Aker
Remove all of uchar. |
346 |
int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,unsigned char *, |
1
by brian
clean slate |
347 |
uint, uint); |
348 |
} MI_SORT_PARAM; |
|
349 |
||
350 |
/* Some defines used by isam-funktions */
|
|
351 |
||
352 |
#define USE_WHOLE_KEY MI_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */ |
|
353 |
#define F_EXTRA_LCK -1
|
|
354 |
||
355 |
/* bits in opt_flag */
|
|
356 |
#define MEMMAP_USED 32
|
|
357 |
#define REMEMBER_OLD_POS 64
|
|
358 |
||
359 |
#define WRITEINFO_UPDATE_KEYFILE 1
|
|
360 |
#define WRITEINFO_NO_UNLOCK 2
|
|
361 |
||
362 |
/* once_flags */
|
|
363 |
#define USE_PACKED_KEYS 1
|
|
364 |
#define RRND_PRESERVE_LASTINX 2
|
|
365 |
||
366 |
/* bits in state.changed */
|
|
367 |
||
368 |
#define STATE_CHANGED 1
|
|
369 |
#define STATE_CRASHED 2
|
|
370 |
#define STATE_CRASHED_ON_REPAIR 4
|
|
371 |
#define STATE_NOT_ANALYZED 8
|
|
372 |
#define STATE_NOT_OPTIMIZED_KEYS 16
|
|
373 |
#define STATE_NOT_SORTED_PAGES 32
|
|
374 |
||
375 |
/* options to mi_read_cache */
|
|
376 |
||
377 |
#define READING_NEXT 1
|
|
378 |
#define READING_HEADER 2
|
|
379 |
||
51.1.127
by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others) |
380 |
|
1
by brian
clean slate |
381 |
#define mi_getint(x) ((uint) mi_uint2korr(x) & 32767)
|
206
by Brian Aker
Removed final uint dead types. |
382 |
#define mi_putint(x,y,nod) { uint16_t boh=(nod ? (uint16_t) 32768 : 0) + (uint16_t) (y);\
|
1
by brian
clean slate |
383 |
mi_int2store(x,boh); }
|
384 |
#define mi_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0)
|
|
385 |
#define mi_report_crashed(A, B) _mi_report_crashed((A), (B), __FILE__, __LINE__)
|
|
386 |
#define mi_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \
|
|
387 |
mi_report_crashed((x), 0); \
|
|
388 |
}while(0)
|
|
389 |
#define mi_mark_crashed_on_repair(x) do{(x)->s->state.changed|= \
|
|
390 |
STATE_CRASHED|STATE_CRASHED_ON_REPAIR; \
|
|
391 |
(x)->update|= HA_STATE_CHANGED; \
|
|
392 |
}while(0)
|
|
393 |
#define mi_is_crashed(x) ((x)->s->state.changed & STATE_CRASHED)
|
|
394 |
#define mi_is_crashed_on_repair(x) ((x)->s->state.changed & STATE_CRASHED_ON_REPAIR)
|
|
395 |
#define mi_print_error(SHARE, ERRNO) \
|
|
396 |
mi_report_error((ERRNO), (SHARE)->index_file_name)
|
|
397 |
||
398 |
/* Functions to store length of space packed keys, VARCHAR or BLOB keys */
|
|
399 |
||
400 |
#define store_key_length(key,length) \
|
|
401 |
{ if ((length) < 255) \
|
|
402 |
{ *(key)=(length); } \
|
|
403 |
else \
|
|
404 |
{ *(key)=255; mi_int2store((key)+1,(length)); } \
|
|
405 |
}
|
|
406 |
||
407 |
#define get_key_full_length(length,key) \
|
|
481
by Brian Aker
Remove all of uchar. |
408 |
{ if ((unsigned char) *(key) != 255) \
|
409 |
length= ((uint) (unsigned char) *((key)++))+1; \
|
|
1
by brian
clean slate |
410 |
else \
|
411 |
{ length=mi_uint2korr((key)+1)+3; (key)+=3; } \
|
|
412 |
}
|
|
413 |
||
414 |
#define get_key_full_length_rdonly(length,key) \
|
|
481
by Brian Aker
Remove all of uchar. |
415 |
{ if ((unsigned char) *(key) != 255) \
|
416 |
length= ((uint) (unsigned char) *((key)))+1; \
|
|
1
by brian
clean slate |
417 |
else \
|
418 |
{ length=mi_uint2korr((key)+1)+3; } \
|
|
419 |
}
|
|
420 |
||
421 |
#define get_pack_length(length) ((length) >= 255 ? 3 : 1)
|
|
422 |
||
423 |
#define MI_MIN_BLOCK_LENGTH 20 /* Because of delete-link */ |
|
424 |
#define MI_EXTEND_BLOCK_LENGTH 20 /* Don't use to small record-blocks */ |
|
425 |
#define MI_SPLIT_LENGTH ((MI_EXTEND_BLOCK_LENGTH+4)*2)
|
|
426 |
#define MI_MAX_DYN_BLOCK_HEADER 20 /* Max prefix of record-block */ |
|
427 |
#define MI_BLOCK_INFO_HEADER_LENGTH 20
|
|
428 |
#define MI_DYN_DELETE_BLOCK_HEADER 20 /* length of delete-block-header */ |
|
429 |
#define MI_DYN_MAX_BLOCK_LENGTH ((1L << 24)-4L)
|
|
430 |
#define MI_DYN_MAX_ROW_LENGTH (MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH)
|
|
431 |
#define MI_DYN_ALIGN_SIZE 4 /* Align blocks on this */ |
|
432 |
#define MI_MAX_DYN_HEADER_BYTE 13 /* max header byte for dynamic rows */ |
|
433 |
#define MI_MAX_BLOCK_LENGTH ((((ulong) 1 << 24)-1) & (~ (ulong) (MI_DYN_ALIGN_SIZE-1)))
|
|
205
by Brian Aker
uint32 -> uin32_t |
434 |
#define MI_REC_BUFF_OFFSET ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER+sizeof(uint32_t))
|
1
by brian
clean slate |
435 |
|
436 |
#define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */ |
|
437 |
||
438 |
#define PACK_TYPE_SELECTED 1 /* Bits in field->pack_type */ |
|
439 |
#define PACK_TYPE_SPACE_FIELDS 2
|
|
440 |
#define PACK_TYPE_ZERO_FILL 4
|
|
441 |
#define MI_FOUND_WRONG_KEY 32738 /* Impossible value from ha_key_cmp */ |
|
442 |
||
443 |
#define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH)
|
|
444 |
#define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer,block_size) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size))
|
|
445 |
#define MI_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ |
|
446 |
#define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */ |
|
447 |
||
448 |
#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */ |
|
449 |
#define MI_MIN_ROWS_TO_USE_BULK_INSERT 100
|
|
450 |
#define MI_MIN_ROWS_TO_DISABLE_INDEXES 100
|
|
451 |
#define MI_MIN_ROWS_TO_USE_WRITE_CACHE 10
|
|
452 |
||
453 |
/* The UNIQUE check is done with a hashed long key */
|
|
454 |
||
455 |
#define MI_UNIQUE_HASH_TYPE HA_KEYTYPE_ULONG_INT
|
|
456 |
#define mi_unique_store(A,B) mi_int4store((A),(B))
|
|
457 |
||
458 |
extern pthread_mutex_t THR_LOCK_myisam; |
|
459 |
||
460 |
/* Some extern variables */
|
|
461 |
||
462 |
extern LIST *myisam_open_list; |
|
481
by Brian Aker
Remove all of uchar. |
463 |
extern unsigned char myisam_file_magic[], myisam_pack_file_magic[]; |
482
by Brian Aker
Remove uint. |
464 |
extern uint32_t myisam_read_vec[], myisam_readnext_vec[]; |
465 |
extern uint32_t myisam_quick_table_bits; |
|
1
by brian
clean slate |
466 |
extern ulong myisam_pid; |
467 |
||
468 |
/* This is used by _mi_calc_xxx_key_length och _mi_store_key */
|
|
469 |
||
470 |
typedef struct st_mi_s_param |
|
471 |
{
|
|
472 |
uint ref_length,key_length, |
|
473 |
n_ref_length, |
|
474 |
n_length, |
|
475 |
totlength, |
|
476 |
part_of_prev_key,prev_length,pack_marker; |
|
481
by Brian Aker
Remove all of uchar. |
477 |
unsigned char *key, *prev_key,*next_key_pos; |
281
by Brian Aker
Converted myisam away from my_bool |
478 |
bool store_not_null; |
1
by brian
clean slate |
479 |
} MI_KEY_PARAM; |
480 |
||
481 |
/* Prototypes for intern functions */
|
|
482 |
||
481
by Brian Aker
Remove all of uchar. |
483 |
extern int _mi_read_dynamic_record(MI_INFO *info,my_off_t filepos,unsigned char *buf); |
484 |
extern int _mi_write_dynamic_record(MI_INFO*, const unsigned char*); |
|
485 |
extern int _mi_update_dynamic_record(MI_INFO*, my_off_t, const unsigned char*); |
|
1
by brian
clean slate |
486 |
extern int _mi_delete_dynamic_record(MI_INFO *info); |
481
by Brian Aker
Remove all of uchar. |
487 |
extern int _mi_cmp_dynamic_record(MI_INFO *info,const unsigned char *record); |
488 |
extern int _mi_read_rnd_dynamic_record(MI_INFO *, unsigned char *,my_off_t, bool); |
|
489 |
extern int _mi_write_blob_record(MI_INFO*, const unsigned char*); |
|
490 |
extern int _mi_update_blob_record(MI_INFO*, my_off_t, const unsigned char*); |
|
491 |
extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos,unsigned char *buf); |
|
492 |
extern int _mi_write_static_record(MI_INFO*, const unsigned char*); |
|
493 |
extern int _mi_update_static_record(MI_INFO*, my_off_t, const unsigned char*); |
|
1
by brian
clean slate |
494 |
extern int _mi_delete_static_record(MI_INFO *info); |
481
by Brian Aker
Remove all of uchar. |
495 |
extern int _mi_cmp_static_record(MI_INFO *info,const unsigned char *record); |
496 |
extern int _mi_read_rnd_static_record(MI_INFO*, unsigned char *,my_off_t, bool); |
|
482
by Brian Aker
Remove uint. |
497 |
extern int _mi_ck_write(MI_INFO *info,uint32_t keynr,unsigned char *key,uint32_t length); |
1
by brian
clean slate |
498 |
extern int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo, |
482
by Brian Aker
Remove uint. |
499 |
unsigned char *key, uint32_t key_length, |
500 |
my_off_t *root, uint32_t comp_flag); |
|
481
by Brian Aker
Remove all of uchar. |
501 |
extern int _mi_enlarge_root(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, my_off_t *root); |
502 |
extern int _mi_insert(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, |
|
503 |
unsigned char *anc_buff,unsigned char *key_pos,unsigned char *key_buff, |
|
504 |
unsigned char *father_buff, unsigned char *father_keypos, |
|
281
by Brian Aker
Converted myisam away from my_bool |
505 |
my_off_t father_page, bool insert_last); |
481
by Brian Aker
Remove all of uchar. |
506 |
extern int _mi_split_page(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, |
507 |
unsigned char *buff,unsigned char *key_buff, bool insert_last); |
|
482
by Brian Aker
Remove uint. |
508 |
extern unsigned char *_mi_find_half_pos(uint32_t nod_flag,MI_KEYDEF *keyinfo,unsigned char *page, |
509 |
unsigned char *key,uint32_t *return_key_length, |
|
481
by Brian Aker
Remove all of uchar. |
510 |
unsigned char **after_key); |
482
by Brian Aker
Remove uint. |
511 |
extern int _mi_calc_static_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag, |
481
by Brian Aker
Remove all of uchar. |
512 |
unsigned char *key_pos, unsigned char *org_key, |
513 |
unsigned char *key_buff, |
|
514 |
unsigned char *key, MI_KEY_PARAM *s_temp); |
|
482
by Brian Aker
Remove uint. |
515 |
extern int _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag, |
481
by Brian Aker
Remove all of uchar. |
516 |
unsigned char *key_pos, unsigned char *org_key, |
517 |
unsigned char *key_buff, |
|
518 |
unsigned char *key, MI_KEY_PARAM *s_temp); |
|
482
by Brian Aker
Remove uint. |
519 |
extern int _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag, |
481
by Brian Aker
Remove all of uchar. |
520 |
unsigned char *key_pos, unsigned char *org_key, |
521 |
unsigned char *prev_key, |
|
522 |
unsigned char *key, MI_KEY_PARAM *s_temp); |
|
482
by Brian Aker
Remove uint. |
523 |
extern int _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag, |
481
by Brian Aker
Remove all of uchar. |
524 |
unsigned char *key_pos,unsigned char *org_key, |
525 |
unsigned char *prev_key, |
|
526 |
unsigned char *key, MI_KEY_PARAM *s_temp); |
|
527 |
void _mi_store_static_key(MI_KEYDEF *keyinfo, unsigned char *key_pos, |
|
1
by brian
clean slate |
528 |
MI_KEY_PARAM *s_temp); |
481
by Brian Aker
Remove all of uchar. |
529 |
void _mi_store_var_pack_key(MI_KEYDEF *keyinfo, unsigned char *key_pos, |
1
by brian
clean slate |
530 |
MI_KEY_PARAM *s_temp); |
531 |
#ifdef NOT_USED
|
|
481
by Brian Aker
Remove all of uchar. |
532 |
void _mi_store_pack_key(MI_KEYDEF *keyinfo, unsigned char *key_pos, |
1
by brian
clean slate |
533 |
MI_KEY_PARAM *s_temp); |
534 |
#endif
|
|
481
by Brian Aker
Remove all of uchar. |
535 |
void _mi_store_bin_pack_key(MI_KEYDEF *keyinfo, unsigned char *key_pos, |
1
by brian
clean slate |
536 |
MI_KEY_PARAM *s_temp); |
537 |
||
482
by Brian Aker
Remove uint. |
538 |
extern int _mi_ck_delete(MI_INFO *info,uint32_t keynr,unsigned char *key,uint32_t key_length); |
1
by brian
clean slate |
539 |
extern int _mi_readinfo(MI_INFO *info,int lock_flag,int check_keybuffer); |
482
by Brian Aker
Remove uint. |
540 |
extern int _mi_writeinfo(MI_INFO *info,uint32_t options); |
1
by brian
clean slate |
541 |
extern int _mi_test_if_changed(MI_INFO *info); |
542 |
extern int _mi_mark_file_changed(MI_INFO *info); |
|
543 |
extern int _mi_decrement_open_count(MI_INFO *info); |
|
544 |
extern int _mi_check_index(MI_INFO *info,int inx); |
|
482
by Brian Aker
Remove uint. |
545 |
extern int _mi_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,uint32_t key_len, |
546 |
uint32_t nextflag,my_off_t pos); |
|
1
by brian
clean slate |
547 |
extern int _mi_bin_search(struct st_myisam_info *info,MI_KEYDEF *keyinfo, |
482
by Brian Aker
Remove uint. |
548 |
unsigned char *page,unsigned char *key,uint32_t key_len,uint32_t comp_flag, |
481
by Brian Aker
Remove all of uchar. |
549 |
unsigned char * *ret_pos,unsigned char *buff, bool *was_last_key); |
550 |
extern int _mi_seq_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *page, |
|
482
by Brian Aker
Remove uint. |
551 |
unsigned char *key,uint32_t key_len,uint32_t comp_flag, |
481
by Brian Aker
Remove all of uchar. |
552 |
unsigned char **ret_pos,unsigned char *buff, bool *was_last_key); |
553 |
extern int _mi_prefix_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *page, |
|
482
by Brian Aker
Remove uint. |
554 |
unsigned char *key,uint32_t key_len,uint32_t comp_flag, |
481
by Brian Aker
Remove all of uchar. |
555 |
unsigned char **ret_pos,unsigned char *buff, bool *was_last_key); |
482
by Brian Aker
Remove uint. |
556 |
extern my_off_t _mi_kpos(uint32_t nod_flag,unsigned char *after_key); |
481
by Brian Aker
Remove all of uchar. |
557 |
extern void _mi_kpointer(MI_INFO *info,unsigned char *buff,my_off_t pos); |
482
by Brian Aker
Remove uint. |
558 |
extern my_off_t _mi_dpos(MI_INFO *info, uint32_t nod_flag,unsigned char *after_key); |
481
by Brian Aker
Remove all of uchar. |
559 |
extern my_off_t _mi_rec_pos(MYISAM_SHARE *info, unsigned char *ptr); |
560 |
extern void _mi_dpointer(MI_INFO *info, unsigned char *buff,my_off_t pos); |
|
482
by Brian Aker
Remove uint. |
561 |
extern uint32_t _mi_get_static_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page, |
481
by Brian Aker
Remove all of uchar. |
562 |
unsigned char *key); |
482
by Brian Aker
Remove uint. |
563 |
extern uint32_t _mi_get_pack_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page, |
481
by Brian Aker
Remove all of uchar. |
564 |
unsigned char *key); |
482
by Brian Aker
Remove uint. |
565 |
extern uint32_t _mi_get_binary_pack_key(MI_KEYDEF *keyinfo, uint32_t nod_flag, |
481
by Brian Aker
Remove all of uchar. |
566 |
unsigned char **page_pos, unsigned char *key); |
567 |
extern unsigned char *_mi_get_last_key(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *keypos, |
|
568 |
unsigned char *lastkey,unsigned char *endpos, |
|
482
by Brian Aker
Remove uint. |
569 |
uint32_t *return_key_length); |
481
by Brian Aker
Remove all of uchar. |
570 |
extern unsigned char *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, unsigned char *page, |
482
by Brian Aker
Remove uint. |
571 |
unsigned char *key, unsigned char *keypos, uint32_t *return_key_length); |
572 |
extern uint32_t _mi_keylength(MI_KEYDEF *keyinfo,unsigned char *key); |
|
573 |
extern uint32_t _mi_keylength_part(MI_KEYDEF *keyinfo, register unsigned char *key, |
|
1
by brian
clean slate |
574 |
HA_KEYSEG *end); |
481
by Brian Aker
Remove all of uchar. |
575 |
extern unsigned char *_mi_move_key(MI_KEYDEF *keyinfo,unsigned char *to,unsigned char *from); |
576 |
extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, |
|
482
by Brian Aker
Remove uint. |
577 |
uint32_t key_length,uint32_t nextflag,my_off_t pos); |
1
by brian
clean slate |
578 |
extern int _mi_search_first(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); |
579 |
extern int _mi_search_last(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos); |
|
481
by Brian Aker
Remove all of uchar. |
580 |
extern unsigned char *_mi_fetch_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page, |
581 |
int level,unsigned char *buff,int return_buffer); |
|
1
by brian
clean slate |
582 |
extern int _mi_write_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page, |
481
by Brian Aker
Remove all of uchar. |
583 |
int level, unsigned char *buff); |
1
by brian
clean slate |
584 |
extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos, |
585 |
int level); |
|
586 |
extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level); |
|
482
by Brian Aker
Remove uint. |
587 |
extern uint32_t _mi_make_key(MI_INFO *info,uint32_t keynr,unsigned char *key, |
481
by Brian Aker
Remove all of uchar. |
588 |
const unsigned char *record,my_off_t filepos); |
482
by Brian Aker
Remove uint. |
589 |
extern uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key, |
481
by Brian Aker
Remove all of uchar. |
590 |
unsigned char *old, key_part_map keypart_map, |
1
by brian
clean slate |
591 |
HA_KEYSEG **last_used_keyseg); |
481
by Brian Aker
Remove all of uchar. |
592 |
extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,unsigned char *buf); |
593 |
extern int _mi_read_cache(IO_CACHE *info,unsigned char *buff,my_off_t pos, |
|
482
by Brian Aker
Remove uint. |
594 |
uint32_t length,int re_read_if_possibly); |
481
by Brian Aker
Remove all of uchar. |
595 |
extern uint64_t retrieve_auto_increment(MI_INFO *info,const unsigned char *record); |
1
by brian
clean slate |
596 |
|
481
by Brian Aker
Remove all of uchar. |
597 |
extern unsigned char *mi_alloc_rec_buff(MI_INFO *,ulong, unsigned char**); |
1
by brian
clean slate |
598 |
#define mi_get_rec_buff_ptr(info,buf) \
|
599 |
((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \
|
|
600 |
(buf) - MI_REC_BUFF_OFFSET : (buf))
|
|
601 |
#define mi_get_rec_buff_len(info,buf) \
|
|
205
by Brian Aker
uint32 -> uin32_t |
602 |
(*((uint32_t *)(mi_get_rec_buff_ptr(info,buf))))
|
1
by brian
clean slate |
603 |
|
481
by Brian Aker
Remove all of uchar. |
604 |
extern ulong _mi_rec_unpack(MI_INFO *info,unsigned char *to,unsigned char *from, |
1
by brian
clean slate |
605 |
ulong reclength); |
481
by Brian Aker
Remove all of uchar. |
606 |
extern bool _mi_rec_check(MI_INFO *info,const unsigned char *record, unsigned char *packpos, |
281
by Brian Aker
Converted myisam away from my_bool |
607 |
ulong packed_length, bool with_checkum); |
1
by brian
clean slate |
608 |
extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length, |
481
by Brian Aker
Remove all of uchar. |
609 |
my_off_t next_filepos,unsigned char **record, |
1
by brian
clean slate |
610 |
ulong *reclength,int *flag); |
481
by Brian Aker
Remove all of uchar. |
611 |
extern void _mi_print_key(FILE *stream,HA_KEYSEG *keyseg,const unsigned char *key, |
482
by Brian Aker
Remove uint. |
612 |
uint32_t length); |
281
by Brian Aker
Converted myisam away from my_bool |
613 |
extern bool _mi_read_pack_info(MI_INFO *info,bool fix_keys); |
481
by Brian Aker
Remove all of uchar. |
614 |
extern int _mi_read_pack_record(MI_INFO *info,my_off_t filepos,unsigned char *buf); |
615 |
extern int _mi_read_rnd_pack_record(MI_INFO*, unsigned char *,my_off_t, bool); |
|
1
by brian
clean slate |
616 |
extern int _mi_pack_rec_unpack(MI_INFO *info, MI_BIT_BUFF *bit_buff, |
481
by Brian Aker
Remove all of uchar. |
617 |
unsigned char *to, unsigned char *from, ulong reclength); |
151
by Brian Aker
Ulonglong to uint64_t |
618 |
extern uint64_t mi_safe_mul(uint64_t a,uint64_t b); |
1
by brian
clean slate |
619 |
|
620 |
struct st_sort_info; |
|
621 |
||
622 |
||
623 |
typedef struct st_mi_block_info { /* Parameter to _mi_get_block_info */ |
|
481
by Brian Aker
Remove all of uchar. |
624 |
unsigned char header[MI_BLOCK_INFO_HEADER_LENGTH]; |
1
by brian
clean slate |
625 |
ulong rec_len; |
626 |
ulong data_len; |
|
627 |
ulong block_len; |
|
628 |
ulong blob_len; |
|
629 |
my_off_t filepos; |
|
630 |
my_off_t next_filepos; |
|
631 |
my_off_t prev_filepos; |
|
482
by Brian Aker
Remove uint. |
632 |
uint32_t second_read; |
633 |
uint32_t offset; |
|
1
by brian
clean slate |
634 |
} MI_BLOCK_INFO; |
635 |
||
636 |
/* bits in return from _mi_get_block_info */
|
|
637 |
||
638 |
#define BLOCK_FIRST 1
|
|
639 |
#define BLOCK_LAST 2
|
|
640 |
#define BLOCK_DELETED 4
|
|
641 |
#define BLOCK_ERROR 8 /* Wrong data */ |
|
642 |
#define BLOCK_SYNC_ERROR 16 /* Right data at wrong place */ |
|
643 |
#define BLOCK_FATAL_ERROR 32 /* hardware-error */ |
|
644 |
||
645 |
#define NEED_MEM ((uint) 10*4*(IO_SIZE+32)+32) /* Nead for recursion */ |
|
646 |
#define MAXERR 20
|
|
647 |
#define BUFFERS_WHEN_SORTING 16 /* Alloc for sort-key-tree */ |
|
648 |
#define WRITE_COUNT MY_HOW_OFTEN_TO_WRITE
|
|
649 |
#define INDEX_TMP_EXT ".TMM"
|
|
650 |
#define DATA_TMP_EXT ".TMD"
|
|
651 |
||
652 |
#define UPDATE_TIME 1
|
|
653 |
#define UPDATE_STAT 2
|
|
654 |
#define UPDATE_SORT 4
|
|
655 |
#define UPDATE_AUTO_INC 8
|
|
656 |
#define UPDATE_OPEN_COUNT 16
|
|
657 |
||
658 |
#define USE_BUFFER_INIT (((1024L*512L-MALLOC_OVERHEAD)/IO_SIZE)*IO_SIZE)
|
|
659 |
#define READ_BUFFER_INIT (1024L*256L-MALLOC_OVERHEAD)
|
|
660 |
#define SORT_BUFFER_INIT (2048L*1024L-MALLOC_OVERHEAD)
|
|
661 |
#define MIN_SORT_BUFFER (4096-MALLOC_OVERHEAD)
|
|
662 |
||
663 |
#define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0)
|
|
664 |
#define fast_mi_readinfo(INFO) ((INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1)
|
|
665 |
||
666 |
#ifdef __cplusplus
|
|
667 |
extern "C" { |
|
668 |
#endif
|
|
669 |
||
482
by Brian Aker
Remove uint. |
670 |
extern uint32_t _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t); |
671 |
extern uint32_t _mi_rec_pack(MI_INFO *info,unsigned char *to,const unsigned char *from); |
|
672 |
extern uint32_t _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, |
|
481
by Brian Aker
Remove all of uchar. |
673 |
MI_BLOCK_INFO *info, unsigned char **rec_buff_p, |
1
by brian
clean slate |
674 |
File file, my_off_t filepos); |
482
by Brian Aker
Remove uint. |
675 |
extern void _my_store_blob_length(unsigned char *pos,uint32_t pack_length,uint32_t length); |
1
by brian
clean slate |
676 |
extern void mi_report_error(int errcode, const char *file_name); |
481
by Brian Aker
Remove all of uchar. |
677 |
extern size_t mi_mmap_pread(MI_INFO *info, unsigned char *Buffer, |
1
by brian
clean slate |
678 |
size_t Count, my_off_t offset, myf MyFlags); |
481
by Brian Aker
Remove all of uchar. |
679 |
extern size_t mi_mmap_pwrite(MI_INFO *info, const unsigned char *Buffer, |
1
by brian
clean slate |
680 |
size_t Count, my_off_t offset, myf MyFlags); |
481
by Brian Aker
Remove all of uchar. |
681 |
extern size_t mi_nommap_pread(MI_INFO *info, unsigned char *Buffer, |
1
by brian
clean slate |
682 |
size_t Count, my_off_t offset, myf MyFlags); |
481
by Brian Aker
Remove all of uchar. |
683 |
extern size_t mi_nommap_pwrite(MI_INFO *info, const unsigned char *Buffer, |
1
by brian
clean slate |
684 |
size_t Count, my_off_t offset, myf MyFlags); |
685 |
||
482
by Brian Aker
Remove uint. |
686 |
uint32_t mi_state_info_write(File file, MI_STATE_INFO *state, uint32_t pWrite); |
481
by Brian Aker
Remove all of uchar. |
687 |
unsigned char *mi_state_info_read(unsigned char *ptr, MI_STATE_INFO *state); |
482
by Brian Aker
Remove uint. |
688 |
uint32_t mi_state_info_read_dsk(File file, MI_STATE_INFO *state, bool pRead); |
689 |
uint32_t mi_base_info_write(File file, MI_BASE_INFO *base); |
|
481
by Brian Aker
Remove all of uchar. |
690 |
unsigned char *my_n_base_info_read(unsigned char *ptr, MI_BASE_INFO *base); |
1
by brian
clean slate |
691 |
int mi_keyseg_write(File file, const HA_KEYSEG *keyseg); |
481
by Brian Aker
Remove all of uchar. |
692 |
unsigned char *mi_keyseg_read(unsigned char *ptr, HA_KEYSEG *keyseg); |
482
by Brian Aker
Remove uint. |
693 |
uint32_t mi_keydef_write(File file, MI_KEYDEF *keydef); |
481
by Brian Aker
Remove all of uchar. |
694 |
unsigned char *mi_keydef_read(unsigned char *ptr, MI_KEYDEF *keydef); |
482
by Brian Aker
Remove uint. |
695 |
uint32_t mi_uniquedef_write(File file, MI_UNIQUEDEF *keydef); |
481
by Brian Aker
Remove all of uchar. |
696 |
unsigned char *mi_uniquedef_read(unsigned char *ptr, MI_UNIQUEDEF *keydef); |
482
by Brian Aker
Remove uint. |
697 |
uint32_t mi_recinfo_write(File file, MI_COLUMNDEF *recinfo); |
481
by Brian Aker
Remove all of uchar. |
698 |
unsigned char *mi_recinfo_read(unsigned char *ptr, MI_COLUMNDEF *recinfo); |
1
by brian
clean slate |
699 |
extern int mi_disable_indexes(MI_INFO *info); |
700 |
extern int mi_enable_indexes(MI_INFO *info); |
|
701 |
extern int mi_indexes_are_disabled(MI_INFO *info); |
|
481
by Brian Aker
Remove all of uchar. |
702 |
ulong _my_calc_total_blob_length(MI_INFO *info, const unsigned char *record); |
703 |
ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf); |
|
704 |
ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *buf); |
|
705 |
bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, unsigned char *record, |
|
1
by brian
clean slate |
706 |
ha_checksum unique_hash, my_off_t pos); |
481
by Brian Aker
Remove all of uchar. |
707 |
ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const unsigned char *buf); |
1
by brian
clean slate |
708 |
int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def, |
481
by Brian Aker
Remove all of uchar. |
709 |
const unsigned char *record, my_off_t pos); |
1
by brian
clean slate |
710 |
int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, |
481
by Brian Aker
Remove all of uchar. |
711 |
const unsigned char *record, my_off_t pos); |
712 |
int mi_unique_comp(MI_UNIQUEDEF *def, const unsigned char *a, const unsigned char *b, |
|
281
by Brian Aker
Converted myisam away from my_bool |
713 |
bool null_are_equal); |
1
by brian
clean slate |
714 |
void mi_get_status(void* param, int concurrent_insert); |
715 |
void mi_update_status(void* param); |
|
716 |
void mi_restore_status(void* param); |
|
717 |
void mi_copy_status(void* to,void *from); |
|
153
by Brian Aker
Merging Monty's code, I did remove error on compile though (since it does |
718 |
bool mi_check_status(void* param); |
1
by brian
clean slate |
719 |
|
720 |
extern MI_INFO *test_if_reopen(char *filename); |
|
281
by Brian Aker
Converted myisam away from my_bool |
721 |
bool check_table_is_closed(const char *name, const char *where); |
1
by brian
clean slate |
722 |
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup); |
723 |
int mi_open_keyfile(MYISAM_SHARE *share); |
|
724 |
void mi_setup_functions(register MYISAM_SHARE *share); |
|
281
by Brian Aker
Converted myisam away from my_bool |
725 |
bool mi_dynmap_file(MI_INFO *info, my_off_t size); |
1
by brian
clean slate |
726 |
void mi_remap_file(MI_INFO *info, my_off_t size); |
727 |
||
482
by Brian Aker
Remove uint. |
728 |
int mi_check_index_cond(register MI_INFO *info, uint32_t keynr, unsigned char *record); |
1
by brian
clean slate |
729 |
|
730 |
/* Functions needed by mi_check */
|
|
731 |
volatile int *killed_ptr(MI_CHECK *param); |
|
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
732 |
void mi_check_print_error(MI_CHECK *param, const char *fmt,...); |
733 |
void mi_check_print_warning(MI_CHECK *param, const char *fmt,...); |
|
734 |
void mi_check_print_info(MI_CHECK *param, const char *fmt,...); |
|
1
by brian
clean slate |
735 |
int flush_pending_blocks(MI_SORT_PARAM *param); |
736 |
int thr_write_keys(MI_SORT_PARAM *sort_param); |
|
737 |
pthread_handler_t thr_find_all_keys(void *arg); |
|
738 |
int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file); |
|
739 |
||
740 |
int sort_write_record(MI_SORT_PARAM *sort_param); |
|
305
by Brian Aker
Another pass of ulong removal. |
741 |
int _create_index_by_sort(MI_SORT_PARAM *info,bool no_messages, uint32_t); |
1
by brian
clean slate |
742 |
|
743 |
extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func, |
|
744 |
void *func_arg); |
|
36
by Brian Aker
Moved pread over to just supporting myisam (someone can refactor from here |
745 |
/* Just for myisam legacy */
|
481
by Brian Aker
Remove all of uchar. |
746 |
extern size_t my_pwrite(File Filedes,const unsigned char *Buffer,size_t Count, |
36
by Brian Aker
Moved pread over to just supporting myisam (someone can refactor from here |
747 |
my_off_t offset,myf MyFlags); |
481
by Brian Aker
Remove all of uchar. |
748 |
extern size_t my_pread(File Filedes,unsigned char *Buffer,size_t Count,my_off_t offset, |
36
by Brian Aker
Moved pread over to just supporting myisam (someone can refactor from here |
749 |
myf MyFlags); |
77
by Brian Aker
Resolved merge from Monty |
750 |
|
751 |
/* Needed for handler */
|
|
752 |
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); |
|
51.1.127
by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others) |
753 |
void _mi_report_crashed(MI_INFO *file __attribute__((unused)), |
754 |
const char *message __attribute__((unused)), |
|
755 |
const char *sfile __attribute__((unused)), |
|
482
by Brian Aker
Remove uint. |
756 |
uint32_t sline __attribute__((unused))); |
51.1.127
by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others) |
757 |
|
1
by brian
clean slate |
758 |
#ifdef __cplusplus
|
759 |
}
|
|
760 |
#endif
|
|
761 |
||
51.1.127
by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others) |
762 |
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
763 |
#endif /* MYISAMDEF_H */ |