2929extern "C" {
3030#endif
3131
32- #define MARIA_CANNOT_ROLLBACK
33-
34- /*
35- Limit max keys according to HA_MAX_POSSIBLE_KEY; See myisamchk.h for details
36- */
37-
38- #if MAX_INDEXES > HA_MAX_POSSIBLE_KEY
39- #define MARIA_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */
40- #else
41- #define MARIA_MAX_KEY MAX_INDEXES /* Max allowed keys */
42- #endif
43-
44- #define MARIA_NAME_IEXT ".MAI"
45- #define MARIA_NAME_DEXT ".MAD"
46- /* Max extra space to use when sorting keys */
47- #define MARIA_MAX_TEMP_LENGTH (2*1024L*1024L*1024L)
48- /* Possible values for maria_block_size (must be power of 2) */
49- #define MARIA_KEY_BLOCK_LENGTH 8192/* default key block length */
50- #define MARIA_MIN_KEY_BLOCK_LENGTH 1024/* Min key block length */
51- #define MARIA_MAX_KEY_BLOCK_LENGTH 32768
52- /* Minimal page cache when we only want to be able to scan a table */
53- #define MARIA_MIN_PAGE_CACHE_SIZE (8192L*16L)
54-
55- /*
56- In the following macros '_keyno_' is 0 .. keys-1.
57- If there can be more keys than bits in the key_map, the highest bit
58- is for all upper keys. They cannot be switched individually.
59- This means that clearing of high keys is ignored, setting one high key
60- sets all high keys.
61- */
62- #define MARIA_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
63- #define MARIA_KEYMAP_HIGH_MASK (1ULL << (MARIA_KEYMAP_BITS - 1))
64- #define maria_get_mask_all_keys_active (_keys_ ) \
65- (((_keys_) < MARIA_KEYMAP_BITS) ? \
66- ((1ULL << (_keys_)) - 1ULL) : \
67- (~ 0ULL))
68- #if MARIA_MAX_KEY > MARIA_KEYMAP_BITS
69- #define maria_is_key_active (_keymap_ ,_keyno_ ) \
70- (((_keyno_) < MARIA_KEYMAP_BITS) ? \
71- MY_TEST((_keymap_) & (1ULL << (_keyno_))) : \
72- MY_TEST((_keymap_) & MARIA_KEYMAP_HIGH_MASK))
73- #define maria_set_key_active (_keymap_ ,_keyno_ ) \
74- (_keymap_)|= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
75- (1ULL << (_keyno_)) : \
76- MARIA_KEYMAP_HIGH_MASK)
77- #define maria_clear_key_active (_keymap_ ,_keyno_ ) \
78- (_keymap_)&= (((_keyno_) < MARIA_KEYMAP_BITS) ? \
79- (~ (1ULL << (_keyno_))) : \
80- (~ (0ULL)) /*ignore*/ )
81- #else
82- #define maria_is_key_active (_keymap_ ,_keyno_ ) \
83- MY_TEST((_keymap_) & (1ULL << (_keyno_)))
84- #define maria_set_key_active (_keymap_ ,_keyno_ ) \
85- (_keymap_)|= (1ULL << (_keyno_))
86- #define maria_clear_key_active (_keymap_ ,_keyno_ ) \
87- (_keymap_)&= (~ (1ULL << (_keyno_)))
88- #endif
89- #define maria_is_any_key_active (_keymap_ ) \
90- MY_TEST((_keymap_))
91- #define maria_is_all_keys_active (_keymap_ ,_keys_ ) \
92- ((_keymap_) == maria_get_mask_all_keys_active(_keys_))
93- #define maria_set_all_keys_active (_keymap_ ,_keys_ ) \
94- (_keymap_)= maria_get_mask_all_keys_active(_keys_)
95- #define maria_clear_all_keys_active (_keymap_ ) \
96- (_keymap_)= 0
97- #define maria_intersect_keys_active (_to_ ,_from_ ) \
98- (_to_)&= (_from_)
99- #define maria_is_any_intersect_keys_active (_keymap1_ ,_keys_ ,_keymap2_ ) \
100- ((_keymap1_) & (_keymap2_) & \
101- maria_get_mask_all_keys_active(_keys_))
102- #define maria_copy_keys_active (_to_ ,_maxkeys_ ,_from_ ) \
103- (_to_)= (maria_get_mask_all_keys_active(_maxkeys_) & \
104- (_from_))
105-
106- /* Param to/from maria_info */
107-
108- typedef ulonglong MARIA_RECORD_POS ;
109-
110- typedef struct st_maria_info
111- {
112- ha_rows records ;/* Records in database */
113- ha_rows deleted ;/* Deleted records in database */
114- MARIA_RECORD_POS recpos ;/* Pos for last used record */
115- MARIA_RECORD_POS newrecpos ;/* Pos if we write new record */
116- MARIA_RECORD_POS dup_key_pos ;/* Position to record with dup key */
117- my_off_t data_file_length ; /* Length of data file */
118- my_off_t max_data_file_length , index_file_length ;
119- my_off_t max_index_file_length , delete_length ;
120- ulonglong auto_increment ;
121- ulonglong key_map ; /* Which keys are used */
122- time_t create_time ; /* When table was created */
123- time_t check_time ;
124- time_t update_time ;
125- ulong record_offset ;
126- double * rec_per_key ; /* for sql optimizing */
127- ulong reclength ; /* Recordlength */
128- ulong mean_reclength ; /* Mean recordlength (if packed) */
129- char * data_file_name , * index_file_name ;
130- enum data_file_type data_file_type ;
131- uint keys ; /* Number of keys in use */
132- uint options ; /* HA_OPTION_... used */
133- uint reflength ;
134- int errkey , /* With key was dupplicated on err */
135- sortkey ; /* clustered by this key */
136- File filenr ; /* (uniq) filenr for datafile */
137- } MARIA_INFO ;
138-
139-
140- typedef struct st_maria_create_info
141- {
142- const char * index_file_name , * data_file_name ;/* If using symlinks */
143- ha_rows max_rows ;
144- ha_rows reloc_rows ;
145- ulonglong auto_increment ;
146- ulonglong data_file_length ;
147- ulonglong key_file_length ;
148- ulong s3_block_size ;
149- /* Size of null bitmap at start of row */
150- uint null_bytes ;
151- uint old_options ;
152- uint compression_algorithm ;
153- enum data_file_type org_data_file_type ;
154- uint16 language ;
155- my_bool with_auto_increment , transactional , encrypted ;
156- } MARIA_CREATE_INFO ;
32+ #define MARIA_UNIQUE_HASH_LENGTH 4
33+ extern my_bool maria_delay_key_write ;
34+ uint maria_max_key_length (void );
35+ #define maria_max_key_segments () HA_MAX_KEY_SEG
15736
37+ struct st_maria_bit_buff ;
38+ struct st_maria_page ;
39+ struct st_maria_s_param ;
15840struct st_maria_share ;
159- struct st_maria_handler ; /* For referense */
41+ typedef struct st_maria_decode_tree MARIA_DECODE_TREE ;
16042typedef struct st_maria_handler MARIA_HA ;
161- struct st_maria_s_param ;
162- struct st_maria_keydef ;
163- struct st_maria_page ;
164-
165- typedef struct st_maria_key /* Internal info about a key */
166- {
167- uchar * data ; /* Data for key */
168- struct st_maria_keydef * keyinfo ; /* Definition for key */
169- uint data_length ; /* Length of key data */
170- uint ref_length ; /* record ref + transid */
171- uint32 flag ; /* 0 or SEARCH_PART_KEY */
172- } MARIA_KEY ;
173-
43+ typedef struct st_maria_key MARIA_KEY ;
44+ typedef ulonglong MARIA_RECORD_POS ;
17445
17546typedef struct st_maria_keydef /* Key definition with open & info */
17647{
@@ -213,8 +84,6 @@ typedef struct st_maria_keydef /* Key definition with open & info */
21384} MARIA_KEYDEF ;
21485
21586
216- #define MARIA_UNIQUE_HASH_LENGTH 4
217-
21887typedef struct st_maria_unique_def /* Segment definition of unique */
21988{
22089 uint16 keysegs ; /* Number of key-segment */
@@ -223,17 +92,6 @@ typedef struct st_maria_unique_def /* Segment definition of unique */
22392 HA_KEYSEG * seg , * end ;
22493} MARIA_UNIQUEDEF ;
22594
226- typedef struct st_maria_decode_tree /* Decode huff-table */
227- {
228- uint16 * table ;
229- uint quick_table_bits ;
230- uchar * intervalls ;
231- } MARIA_DECODE_TREE ;
232-
233-
234- struct st_maria_bit_buff ;
235- typedef struct s3_info S3_INFO ;
236-
23795/*
23896 Note that null markers should always be first in a row !
23997 When creating a column, one should only specify:
@@ -265,157 +123,32 @@ typedef struct st_maria_columndef /* column information */
265123} MARIA_COLUMNDEF ;
266124
267125
268- extern ulong maria_block_size , maria_checkpoint_frequency ;
269- extern ulong maria_concurrent_insert ;
270- extern my_bool maria_flush , maria_single_user , maria_page_checksums ;
271- extern my_bool maria_delay_key_write ;
272- extern my_off_t maria_max_temp_length ;
273- extern ulong maria_bulk_insert_tree_size , maria_data_pointer_size ;
274- extern MY_TMPDIR * maria_tmpdir ;
275- extern my_bool maria_encrypt_tables ;
276-
277- /*
278- This is used to check if a symlink points into the mysql data home,
279- which is normally forbidden as it can be used to get access to
280- not privileged data
281- */
282- extern int ( * maria_test_invalid_symlink )( const char * filename ) ;
283-
284- /* Prototypes for maria-functions */
126+ typedef struct st_maria_create_info
127+ {
128+ const char * index_file_name , * data_file_name ; /* If using symlinks */
129+ ha_rows max_rows ;
130+ ha_rows reloc_rows ;
131+ ulonglong auto_increment ;
132+ ulonglong data_file_length ;
133+ ulonglong key_file_length ;
134+ ulong s3_block_size ;
135+ /* Size of null bitmap at start of row */
136+ uint null_bytes ;
137+ uint old_options ;
138+ uint compression_algorithm ;
139+ enum data_file_type org_data_file_type ;
140+ uint16 language ;
141+ my_bool with_auto_increment , transactional , encrypted ;
142+ } MARIA_CREATE_INFO ;
285143
286- extern int maria_init (void );
287- extern void maria_end (void );
288- extern my_bool maria_upgrade (void );
289- extern int maria_close (MARIA_HA * file );
290- extern int maria_delete (MARIA_HA * file , const uchar * buff );
291- extern MARIA_HA * maria_open (const char * name , int mode ,
292- uint wait_if_locked , S3_INFO * s3 );
293- extern int maria_panic (enum ha_panic_function function );
294- extern int maria_rfirst (MARIA_HA * file , uchar * buf , int inx );
295- extern int maria_rkey (MARIA_HA * file , uchar * buf , int inx ,
296- const uchar * key , key_part_map keypart_map ,
297- enum ha_rkey_function search_flag );
298- extern int maria_rlast (MARIA_HA * file , uchar * buf , int inx );
299- extern int maria_rnext (MARIA_HA * file , uchar * buf , int inx );
300- extern int maria_rnext_same (MARIA_HA * info , uchar * buf );
301- extern int maria_rprev (MARIA_HA * file , uchar * buf , int inx );
302- extern int maria_rrnd (MARIA_HA * file , uchar * buf ,
303- MARIA_RECORD_POS pos );
304- extern int maria_scan_init (MARIA_HA * file );
305- extern int maria_scan (MARIA_HA * file , uchar * buf );
306- extern void maria_scan_end (MARIA_HA * file );
307- extern int maria_rsame (MARIA_HA * file , uchar * record , int inx );
308- extern int maria_rsame_with_pos (MARIA_HA * file , uchar * record ,
309- int inx , MARIA_RECORD_POS pos );
310- extern int maria_update (MARIA_HA * file , const uchar * old ,
311- const uchar * new_record );
312- extern int maria_write (MARIA_HA * file , const uchar * buff );
313- extern MARIA_RECORD_POS maria_position (MARIA_HA * file );
314- extern int maria_status (MARIA_HA * info , MARIA_INFO * x , uint flag );
315- extern int maria_lock_database (MARIA_HA * file , int lock_type );
316144extern int maria_create (const char * name , enum data_file_type record_type ,
317145 uint keys , MARIA_KEYDEF * keydef ,
318- uint columns , MARIA_COLUMNDEF * columndef ,
319- uint uniques , MARIA_UNIQUEDEF * uniquedef ,
320- MARIA_CREATE_INFO * create_info , uint flags );
321- extern int maria_delete_table (const char * name );
322- extern int maria_rename (const char * from , const char * to );
323- extern int maria_extra (MARIA_HA * file ,
324- enum ha_extra_function function , void * extra_arg );
325- extern int maria_reset (MARIA_HA * file );
326- extern ha_rows maria_records_in_range (MARIA_HA * info , int inx ,
327- const key_range * min_key ,
328- const key_range * max_key ,
329- page_range * page );
330- extern int maria_is_changed (MARIA_HA * info );
331- extern int maria_delete_all_rows (MARIA_HA * info );
332- extern uint maria_get_pointer_length (ulonglong file_length , uint def );
333- extern int maria_commit (MARIA_HA * info );
334- extern int maria_begin (MARIA_HA * info );
335- extern void maria_disable_logging (MARIA_HA * info );
336- extern void maria_enable_logging (MARIA_HA * info );
337-
338- #define HA_RECOVER_NONE 0 /* No automatic recover */
339- #define HA_RECOVER_DEFAULT 1 /* Automatic recover active */
340- #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */
341- #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */
342- #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */
343-
344- #define HA_RECOVER_ANY (HA_RECOVER_DEFAULT | HA_RECOVER_BACKUP | HA_RECOVER_FORCE | HA_RECOVER_QUICK)
345-
346- /* this is used to pass to mysql_mariachk_table */
347-
348- #define MARIA_CHK_REPAIR 1 /* equivalent to mariachk -r */
349- #define MARIA_CHK_VERIFY 2 /* Verify, run repair if failure */
350-
351- typedef uint maria_bit_type ;
352-
353- typedef struct st_maria_bit_buff
354- {/* Used for packing of record */
355- maria_bit_type current_byte ;
356- uint bits ;
357- uchar * pos , * end , * blob_pos , * blob_end ;
358- uint error ;
359- } MARIA_BIT_BUFF ;
360-
361- /* functions in maria_check */
362- void maria_chk_init (HA_CHECK * param );
363- void maria_chk_init_for_check (HA_CHECK * param , MARIA_HA * info );
364- int maria_chk_status (HA_CHECK * param , MARIA_HA * info );
365- int maria_chk_del (HA_CHECK * param , MARIA_HA * info , ulonglong test_flag );
366- int maria_chk_size (HA_CHECK * param , MARIA_HA * info );
367- int maria_chk_key (HA_CHECK * param , MARIA_HA * info );
368- int maria_chk_data_link (HA_CHECK * param , MARIA_HA * info , my_bool extend );
369- int maria_repair (HA_CHECK * param , MARIA_HA * info , char * name , my_bool );
370- int maria_sort_index (HA_CHECK * param , MARIA_HA * info , char * name );
371- int maria_zerofill (HA_CHECK * param , MARIA_HA * info , const char * name );
372- int maria_repair_by_sort (HA_CHECK * param , MARIA_HA * info ,
373- const char * name , my_bool rep_quick );
374- int maria_repair_parallel (HA_CHECK * param , MARIA_HA * info ,
375- const char * name , my_bool rep_quick );
376- int maria_change_to_newfile (const char * filename , const char * old_ext ,
377- const char * new_ext , time_t backup_time ,
378- myf myflags );
379- void maria_lock_memory (HA_CHECK * param );
380- int maria_update_state_info (HA_CHECK * param , MARIA_HA * info , uint update );
381- void maria_update_key_parts (MARIA_KEYDEF * keyinfo , double * rec_per_key_part ,
382- ulonglong * unique , ulonglong * notnull ,
383- ulonglong records );
384- int maria_filecopy (HA_CHECK * param , File to , File from , my_off_t start ,
385- my_off_t length , const char * type );
386- int maria_movepoint (MARIA_HA * info , uchar * record , my_off_t oldpos ,
387- my_off_t newpos , uint prot_key );
388- int maria_test_if_almost_full (MARIA_HA * info );
389- int maria_recreate_table (HA_CHECK * param , MARIA_HA * * org_info , char * filename );
390- int maria_disable_indexes (MARIA_HA * info );
391- int maria_enable_indexes (MARIA_HA * info );
392- int maria_indexes_are_disabled (MARIA_HA * info );
393- void maria_disable_indexes_for_rebuild (MARIA_HA * info , ha_rows rows ,
394- my_bool all_keys );
395- my_bool maria_test_if_sort_rep (MARIA_HA * info , ha_rows rows , ulonglong key_map ,
396- my_bool force );
397-
398- int maria_init_bulk_insert (MARIA_HA * info , size_t cache_size , ha_rows rows );
399- void maria_flush_bulk_insert (MARIA_HA * info , uint inx );
400- int maria_end_bulk_insert (MARIA_HA * info , my_bool abort );
401- int maria_preload (MARIA_HA * info , ulonglong key_map , my_bool ignore_leaves );
402- void maria_versioning (MARIA_HA * info , my_bool versioning );
403- void maria_ignore_trids (MARIA_HA * info );
404- uint maria_max_key_length (void );
405- my_bool maria_too_big_key_for_sort (MARIA_KEYDEF * key , ha_rows rows );
406- #define maria_max_key_segments () HA_MAX_KEY_SEG
407-
408- /* fulltext functions */
409- FT_INFO * maria_ft_init_search (uint ,void * , uint , uchar * , size_t ,
410- CHARSET_INFO * , uchar * );
411-
412- /* 'Almost-internal' Maria functions */
413-
414- void _ma_update_auto_increment_key (HA_CHECK * param , MARIA_HA * info ,
415- my_bool repair );
416-
146+ uint columns , MARIA_COLUMNDEF * columndef ,
147+ uint uniques , MARIA_UNIQUEDEF * uniquedef ,
148+ MARIA_CREATE_INFO * create_info , uint flags );
417149
418150#ifdef __cplusplus
419151}
420152#endif
421153#endif
154+
0 commit comments