MySQL 8.4.2
Source Code Documentation
mysqlcheck.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2014, 2024, Oracle and/or its affiliates.
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, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQLCHECK_INCLUDED
27#define MYSQLCHECK_INCLUDED
28
29#include <sys/types.h>
30#include <string>
31#include <vector>
32
33#include "mysql.h"
34
35namespace Mysql {
36namespace Tools {
37namespace Check {
38
45};
46
47extern void mysql_check(MYSQL *connection, int what_to_do, bool opt_alldbs,
49 bool opt_databases, bool opt_fast,
50 bool opt_medium_check, bool opt_quick,
51 bool opt_all_in_1, bool opt_silent,
52 bool opt_auto_repair, bool ignore_errors, bool opt_frm,
55 unsigned int verbose, std::string opt_skip_database,
56 std::vector<std::string> arguments,
57 void (*dberror)(MYSQL *mysql, const std::string &when));
58
59/**
60 This class is object wrapper to mysql_check function. It looks like
61 it is implementing Abstract_program, but it is not explicitly implementing
62 it now. This is to make future implementation of Abstract_program easier.
63 */
64class Program {
65 public:
66 /**
67 Default constructor.
68 */
69 Program();
70
71 /**
72 Checks specified databases on MySQL server.
73 */
74 int check_databases(MYSQL *connection,
75 const std::vector<std::string> &databases);
76 /**
77 Checks all databases on MySQL server.
78 */
79 int check_all_databases(MYSQL *connection);
80
81 /**
82 Automatically try to fix table when upgrade is needed.
83 */
84 Program *enable_auto_repair(bool enable);
85 /**
86 Check and upgrade tables.
87 */
88 Program *enable_upgrade(bool enable);
89 /**
90 Turns on verbose messages.
91 */
92 Program *enable_verbosity(bool enable);
93 /**
94 Enables logging repairing queries to binlog.
95 */
96 Program *enable_writing_binlog(bool enable);
97 /**
98 Enables table name fixing for all encountered tables.
99 */
101 /**
102 Enables database name fixing for all encountered databases.
103 */
104 Program *enable_fixing_db_names(bool enable);
105 /**
106 Ignores all errors and don't print error messages.
107 */
108 Program *set_ignore_errors(bool ignore);
109 /**
110 Sets a name of database to ignore during process.
111 */
112 Program *set_skip_database(std::string database);
113 /**
114 Sets error callback to be called when error is encountered.
115 */
116 Program *set_error_callback(void (*error_callback)(MYSQL *mysql,
117 const std::string &when));
118
119 private:
120 /**
121 Sets mysqlcheck program operation type to perform.
122 */
123 Program *set_what_to_do(int functionality);
124 /**
125 Starts mysqlcheck process.
126 */
127 int execute(const std::vector<std::string> &positional_options);
128
140 void (*m_error_callback)(MYSQL *mysql, const std::string &when);
141};
142
143} // namespace Check
144} // namespace Tools
145} // namespace Mysql
146
147#endif
This class is object wrapper to mysql_check function.
Definition: mysqlcheck.h:64
Program * set_skip_database(std::string database)
Sets a name of database to ignore during process.
Definition: mysqlcheck_core.cc:490
Program * enable_writing_binlog(bool enable)
Enables logging repairing queries to binlog.
Definition: mysqlcheck_core.cc:470
bool m_process_all_dbs
Definition: mysqlcheck.h:135
bool m_upgrade
Definition: mysqlcheck.h:131
bool m_verbose
Definition: mysqlcheck.h:132
Program * enable_fixing_db_names(bool enable)
Enables database name fixing for all encountered databases.
Definition: mysqlcheck_core.cc:480
bool m_write_binlog
Definition: mysqlcheck.h:134
Program * enable_auto_repair(bool enable)
Automatically try to fix table when upgrade is needed.
Definition: mysqlcheck_core.cc:455
int check_databases(MYSQL *connection, const std::vector< std::string > &databases)
Checks specified databases on MySQL server.
Definition: mysqlcheck_core.cc:442
Program * set_what_to_do(int functionality)
Sets mysqlcheck program operation type to perform.
Definition: mysqlcheck_core.cc:501
int m_what_to_do
Definition: mysqlcheck.h:129
std::string m_database_to_skip
Definition: mysqlcheck.h:139
Program * enable_upgrade(bool enable)
Check and upgrade tables.
Definition: mysqlcheck_core.cc:460
Program()
Default constructor.
Definition: mysqlcheck_core.cc:429
Program * enable_verbosity(bool enable)
Turns on verbose messages.
Definition: mysqlcheck_core.cc:465
Program * set_ignore_errors(bool ignore)
Ignores all errors and don't print error messages.
Definition: mysqlcheck_core.cc:485
Program * enable_fixing_table_names(bool enable)
Enables table name fixing for all encountered tables.
Definition: mysqlcheck_core.cc:475
void(* m_error_callback)(MYSQL *mysql, const std::string &when)
Definition: mysqlcheck.h:140
bool m_ignore_errors
Definition: mysqlcheck.h:133
int execute(const std::vector< std::string > &positional_options)
Starts mysqlcheck process.
bool m_fix_db_names
Definition: mysqlcheck.h:137
MYSQL * m_connection
Definition: mysqlcheck.h:138
bool m_fix_table_names
Definition: mysqlcheck.h:136
bool m_auto_repair
Definition: mysqlcheck.h:130
int check_all_databases(MYSQL *connection)
Checks all databases on MySQL server.
Definition: mysqlcheck_core.cc:449
Program * set_error_callback(void(*error_callback)(MYSQL *mysql, const std::string &when))
Sets error callback to be called when error is encountered.
Definition: mysqlcheck_core.cc:495
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
static bool opt_fix_db_names
Definition: mysqlcheck.cc:64
static bool opt_silent
Definition: mysqlcheck.cc:61
static bool opt_extended
Definition: mysqlcheck.cc:59
static bool opt_frm
Definition: mysqlcheck.cc:62
static bool opt_write_binlog
Definition: mysqlcheck.cc:65
static bool opt_fast
Definition: mysqlcheck.cc:60
static bool opt_medium_check
Definition: mysqlcheck.cc:60
static bool opt_upgrade
Definition: mysqlcheck.cc:64
static const char * opt_skip_database
Definition: mysqlcheck.cc:75
static bool opt_databases
Definition: mysqlcheck.cc:59
static bool opt_auto_repair
Definition: mysqlcheck.cc:61
static bool opt_check_only_changed
Definition: mysqlcheck.cc:58
static bool ignore_errors
Definition: mysqlcheck.cc:62
static uint verbose
Definition: mysqlcheck.cc:66
static bool opt_all_in_1
Definition: mysqlcheck.cc:61
static bool opt_alldbs
Definition: mysqlcheck.cc:58
static bool opt_fix_table_names
Definition: mysqlcheck.cc:63
static bool opt_quick
Definition: mysqlcheck.cc:60
int what_to_do
Definition: mysqlcheck_core.cc:58
static MYSQL * mysql
Definition: mysqldump.cc:147
void mysql_check(MYSQL *connection, int what_to_do, bool opt_alldbs, bool opt_check_only_changed, bool opt_extended, bool opt_databases, bool opt_fast, bool opt_medium_check, bool opt_quick, bool opt_all_in_1, bool opt_silent, bool opt_auto_repair, bool ignore_errors, bool opt_frm, bool opt_fix_table_names, bool opt_fix_db_names, bool opt_upgrade, bool opt_write_binlog, unsigned int verbose, std::string opt_skip_database, std::vector< std::string > arguments, void(*dberror)(MYSQL *mysql, const std::string &when))
operations
Definition: mysqlcheck.h:39
@ DO_ANALYZE
Definition: mysqlcheck.h:42
@ DO_OPTIMIZE
Definition: mysqlcheck.h:43
@ DO_CHECK
Definition: mysqlcheck.h:40
@ DO_REPAIR
Definition: mysqlcheck.h:41
@ DO_UPGRADE
Definition: mysqlcheck.h:44
Definition: mysqlcheck.h:35
Definition: instrumented_condition_variable.h:32
Functor to validate the flush list.
Definition: buf0flu.cc:3629
Definition: mysql.h:300