MySQL 8.0.30
Source Code Documentation
mysqlcheck.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2014, 2022, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQLCHECK_INCLUDED
26#define MYSQLCHECK_INCLUDED
27
28#include <sys/types.h>
29#include <string>
30#include <vector>
31
32#include "mysql.h"
33
34namespace Mysql {
35namespace Tools {
36namespace Check {
37
44};
45
46extern void mysql_check(MYSQL *connection, int what_to_do, bool opt_alldbs,
48 bool opt_databases, bool opt_fast,
49 bool opt_medium_check, bool opt_quick,
50 bool opt_all_in_1, bool opt_silent,
51 bool opt_auto_repair, bool ignore_errors, bool opt_frm,
54 unsigned int verbose, std::string opt_skip_database,
55 std::vector<std::string> arguments,
56 void (*dberror)(MYSQL *mysql, const std::string &when));
57
58/**
59 This class is object wrapper to mysql_check function. It looks like
60 it is implementing Abstract_program, but it is not explicitly implementing
61 it now. This is to make future implementation of Abstract_program easier.
62 */
63class Program {
64 public:
65 /**
66 Default constructor.
67 */
68 Program();
69
70 /**
71 Checks specified databases on MySQL server.
72 */
73 int check_databases(MYSQL *connection,
74 const std::vector<std::string> &databases);
75 /**
76 Checks all databases on MySQL server.
77 */
78 int check_all_databases(MYSQL *connection);
79
80 /**
81 Automatically try to fix table when upgrade is needed.
82 */
83 Program *enable_auto_repair(bool enable);
84 /**
85 Check and upgrade tables.
86 */
87 Program *enable_upgrade(bool enable);
88 /**
89 Turns on verbose messages.
90 */
91 Program *enable_verbosity(bool enable);
92 /**
93 Enables logging repairing queries to binlog.
94 */
95 Program *enable_writing_binlog(bool enable);
96 /**
97 Enables table name fixing for all encountered tables.
98 */
100 /**
101 Enables database name fixing for all encountered databases.
102 */
103 Program *enable_fixing_db_names(bool enable);
104 /**
105 Ignores all errors and don't print error messages.
106 */
108 /**
109 Sets a name of database to ignore during process.
110 */
111 Program *set_skip_database(std::string database);
112 /**
113 Sets error callback to be called when error is encountered.
114 */
115 Program *set_error_callback(void (*error_callback)(MYSQL *mysql,
116 const std::string &when));
117
118 private:
119 /**
120 Sets mysqlcheck program operation type to perform.
121 */
122 Program *set_what_to_do(int functionality);
123 /**
124 Starts mysqlcheck process.
125 */
126 int execute(const std::vector<std::string> &positional_options);
127
139 void (*m_error_callback)(MYSQL *mysql, const std::string &when);
140};
141
142} // namespace Check
143} // namespace Tools
144} // namespace Mysql
145
146#endif
This class is object wrapper to mysql_check function.
Definition: mysqlcheck.h:63
Program * set_skip_database(std::string database)
Sets a name of database to ignore during process.
Definition: mysqlcheck_core.cc:484
Program * enable_writing_binlog(bool enable)
Enables logging repairing queries to binlog.
Definition: mysqlcheck_core.cc:464
bool m_process_all_dbs
Definition: mysqlcheck.h:134
bool m_upgrade
Definition: mysqlcheck.h:130
bool m_verbose
Definition: mysqlcheck.h:131
Program * enable_fixing_db_names(bool enable)
Enables database name fixing for all encountered databases.
Definition: mysqlcheck_core.cc:474
bool m_write_binlog
Definition: mysqlcheck.h:133
Program * enable_auto_repair(bool enable)
Automatically try to fix table when upgrade is needed.
Definition: mysqlcheck_core.cc:449
int check_databases(MYSQL *connection, const std::vector< std::string > &databases)
Checks specified databases on MySQL server.
Definition: mysqlcheck_core.cc:436
Program * set_what_to_do(int functionality)
Sets mysqlcheck program operation type to perform.
Definition: mysqlcheck_core.cc:495
int m_what_to_do
Definition: mysqlcheck.h:128
std::string m_database_to_skip
Definition: mysqlcheck.h:138
Program * enable_upgrade(bool enable)
Check and upgrade tables.
Definition: mysqlcheck_core.cc:454
Program()
Default constructor.
Definition: mysqlcheck_core.cc:423
Program * enable_verbosity(bool enable)
Turns on verbose messages.
Definition: mysqlcheck_core.cc:459
Program * set_ignore_errors(bool ignore)
Ignores all errors and don't print error messages.
Definition: mysqlcheck_core.cc:479
Program * enable_fixing_table_names(bool enable)
Enables table name fixing for all encountered tables.
Definition: mysqlcheck_core.cc:469
void(* m_error_callback)(MYSQL *mysql, const std::string &when)
Definition: mysqlcheck.h:139
bool m_ignore_errors
Definition: mysqlcheck.h:132
int execute(const std::vector< std::string > &positional_options)
Starts mysqlcheck process.
bool m_fix_db_names
Definition: mysqlcheck.h:136
MYSQL * m_connection
Definition: mysqlcheck.h:137
bool m_fix_table_names
Definition: mysqlcheck.h:135
bool m_auto_repair
Definition: mysqlcheck.h:129
int check_all_databases(MYSQL *connection)
Checks all databases on MySQL server.
Definition: mysqlcheck_core.cc:443
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:489
static MYSQL mysql
Definition: mysql.cc:153
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:62
static bool opt_silent
Definition: mysqlcheck.cc:59
static bool opt_extended
Definition: mysqlcheck.cc:57
static bool opt_frm
Definition: mysqlcheck.cc:60
static bool opt_write_binlog
Definition: mysqlcheck.cc:63
static bool opt_fast
Definition: mysqlcheck.cc:58
static bool opt_medium_check
Definition: mysqlcheck.cc:58
static bool opt_upgrade
Definition: mysqlcheck.cc:62
static const char * opt_skip_database
Definition: mysqlcheck.cc:73
static bool opt_databases
Definition: mysqlcheck.cc:57
static bool opt_auto_repair
Definition: mysqlcheck.cc:59
static bool opt_check_only_changed
Definition: mysqlcheck.cc:56
static bool ignore_errors
Definition: mysqlcheck.cc:60
static uint verbose
Definition: mysqlcheck.cc:64
static bool opt_all_in_1
Definition: mysqlcheck.cc:59
static bool opt_alldbs
Definition: mysqlcheck.cc:56
static bool opt_fix_table_names
Definition: mysqlcheck.cc:61
static bool opt_quick
Definition: mysqlcheck.cc:58
int what_to_do
Definition: mysqlcheck_core.cc:56
static bool ignore
Definition: mysqlimport.cc:65
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))
Definition: mysqlcheck_core.cc:358
operations
Definition: mysqlcheck.h:38
@ DO_ANALYZE
Definition: mysqlcheck.h:41
@ DO_OPTIMIZE
Definition: mysqlcheck.h:42
@ DO_CHECK
Definition: mysqlcheck.h:39
@ DO_REPAIR
Definition: mysqlcheck.h:40
@ DO_UPGRADE
Definition: mysqlcheck.h:43
Definition: abstract_connection_program.h:37
Functor to validate the flush list.
Definition: buf0flu.cc:3663
Definition: mysql.h:298