1/* Copyright (C) 2006 MySQL AB
2 Copyright (c) 2017, MariaDB Corporation.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
17
18/* Definitions needed for myisamchk/mariachk.c */
19
20#ifndef _myisamchk_h
21#define _myisamchk_h
22
23/*
24 Flags used by xxxxchk.c or/and ha_xxxx.cc that are NOT passed
25 to xxxcheck.c follows:
26*/
27
28#define TT_USEFRM 1U
29#define TT_FOR_UPGRADE 2U
30#define TT_FROM_MYSQL 4U
31
32/* Bits set in out_flag */
33#define O_NEW_DATA 2U
34#define O_DATA_LOST 4U
35
36typedef struct st_sort_key_blocks /* Used when sorting */
37{
38 uchar *buff, *end_pos;
39 uchar lastkey[HA_MAX_POSSIBLE_KEY_BUFF];
40 uint last_length;
41 int inited;
42} SORT_KEY_BLOCKS;
43
44
45/*
46 MARIA/MYISAM supports several statistics collection
47 methods. Currently statistics collection method is not stored in
48 MARIA file and has to be specified for each table analyze/repair
49 operation in MI_CHECK::stats_method.
50*/
51
52typedef enum
53{
54 /* Treat NULLs as inequal when collecting statistics (default for 4.1/5.0) */
55 MI_STATS_METHOD_NULLS_NOT_EQUAL,
56 /* Treat NULLs as equal when collecting statistics (like 4.0 did) */
57 MI_STATS_METHOD_NULLS_EQUAL,
58 /* Ignore NULLs - count only tuples without NULLs in the index components */
59 MI_STATS_METHOD_IGNORE_NULLS
60} enum_handler_stats_method;
61
62struct st_myisam_info;
63
64typedef struct st_handler_check_param
65{
66 char *isam_file_name;
67 MY_TMPDIR *tmpdir;
68 void *thd;
69 const char *db_name, *table_name, *op_name;
70 ulonglong auto_increment_value;
71 ulonglong max_data_file_length;
72 ulonglong keys_in_use;
73 ulonglong max_record_length;
74 /*
75 The next two are used to collect statistics, see update_key_parts for
76 description.
77 */
78 ulonglong unique_count[HA_MAX_KEY_SEG + 1];
79 ulonglong notnull_count[HA_MAX_KEY_SEG + 1];
80
81 my_off_t search_after_block;
82 my_off_t new_file_pos, key_file_blocks;
83 my_off_t keydata, totaldata, key_blocks, start_check_pos;
84 my_off_t used, empty, splits, del_length, link_used, lost;
85 ha_rows total_records, total_deleted, records,del_blocks;
86 ha_rows full_page_count, tail_count;
87 ha_checksum record_checksum, glob_crc;
88 ha_checksum key_crc[HA_MAX_POSSIBLE_KEY];
89 ha_checksum tmp_key_crc[HA_MAX_POSSIBLE_KEY];
90 ha_checksum tmp_record_checksum;
91 ulonglong org_key_map;
92 ulonglong testflag;
93
94 /* Following is used to check if rows are visible */
95 ulonglong max_trid, max_found_trid;
96 ulonglong not_visible_rows_found;
97 ulonglong sort_buffer_length;
98 ulonglong use_buffers; /* Used as param to getopt() */
99 size_t read_buffer_length, write_buffer_length, sort_key_blocks;
100 time_t backup_time; /* To sign backup files */
101 ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY];
102 double new_rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY];
103 uint out_flag, warning_printed, error_printed, note_printed, verbose;
104 uint opt_sort_key, total_files, max_level;
105 uint key_cache_block_size, pagecache_block_size;
106 int tmpfile_createflag, err_count;
107 myf myf_rw;
108 uint16 language;
109 my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
110 my_bool retry_repair, force_sort, calc_checksum, static_row_size;
111 char temp_filename[FN_REFLEN];
112 IO_CACHE read_cache;
113 enum_handler_stats_method stats_method;
114 /* For reporting progress */
115 uint stage, max_stage;
116 uint progress_counter; /* How often to call _report_progress() */
117 ulonglong progress, max_progress;
118
119 int (*fix_record)(struct st_myisam_info *info, uchar *record, int keynum);
120
121 mysql_mutex_t print_msg_mutex;
122 my_bool need_print_msg_lock;
123 myf malloc_flags;
124} HA_CHECK;
125
126
127typedef struct st_sort_ftbuf
128{
129 uchar *buf, *end;
130 int count;
131 uchar lastkey[HA_MAX_KEY_BUFF];
132} SORT_FT_BUF;
133
134
135typedef struct st_buffpek {
136 my_off_t file_pos; /* Where we are in the sort file */
137 uchar *base, *key; /* Key pointers */
138 ha_rows count; /* Number of rows in table */
139 ha_rows mem_count; /* Numbers of keys in memory */
140 ha_rows max_keys; /* Max keys in buffert */
141} BUFFPEK;
142
143#endif /* _myisamchk_h */
144