MySQL 9.1.0
Source Code Documentation
sql_system_table_check.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2024, Oracle and/or its affiliates.
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, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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#ifndef SQL_SYSTEM_TABLE_CHECK_INCLUDED
25#define SQL_SYSTEM_TABLE_CHECK_INCLUDED
26
27#include "mysql/components/services/log_builtins.h" // LogErr, LogEvent
28#include "mysql/my_loglevel.h" // enum loglevel
29#include "mysqld_error.h" // ER_*
30#include "sql/table.h" // Table_check_intact
31
32class THD;
33
34/**
35 Class to check if system table is intact.
36*/
38 public:
41 has_keys = true;
42 }
43
44 THD *thd() { return m_thd; }
45
46 protected:
47 void report_error(uint code, const char *fmt, ...) override
48 MY_ATTRIBUTE((format(printf, 3, 4))) {
49 va_list args;
50 va_start(args, fmt);
51
52 if (code == 0)
53 LogEvent()
55 .errcode(ER_SERVER_TABLE_CHECK_FAILED)
58 .messagev(fmt, args);
59 else if (code == ER_CANNOT_LOAD_FROM_TABLE_V2) {
60 char *db_name, *table_name;
61 db_name = va_arg(args, char *);
62 table_name = va_arg(args, char *);
63 my_error(code, MYF(0), db_name, table_name);
64 LogErr(m_log_level, ER_SERVER_CANNOT_LOAD_FROM_TABLE_V2, db_name,
66 } else {
67 my_printv_error(code, ER_THD_NONCONST(m_thd, code), MYF(0), args);
68 va_end(args);
69
70 if (code == ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2)
71 code = ER_SERVER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2;
72 else if (code == ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2)
73 code = ER_SERVER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2;
74 else
75 code = ER_SERVER_ACL_TABLE_ERROR;
76
77 va_start(args, fmt);
78 LogEvent()
80 .errcode(code)
83 .messagev(fmt, args);
84 }
85
86 va_end(args);
87 }
88
89 private:
92};
93#endif // SQL_SYSTEM_TABLE_CHECK_INCLUDED
Modular logger: fluid API.
Definition: log_builtins.h:894
LogEvent & prio(longlong val)
Set error message priority.
Definition: log_builtins.h:1286
LogEvent & subsys(const char *val)
Which subsystem in the source was the problem detected in? ("Repl"/"InnoDB"/"Server")
Definition: log_builtins.h:1161
LogEvent & errcode(longlong val)
Append a numeric error code.
Definition: log_builtins.h:1063
LogEvent & source_file(const char *val)
Which source file was the problem detected in?
Definition: log_builtins.h:1124
LogEvent & messagev(const char *fmt, va_list ap)
Fill in a format string by substituting the % with the given arguments, then add the result as the ev...
Definition: log_builtins.h:1346
Class to check if system table is intact.
Definition: sql_system_table_check.h:37
enum loglevel m_log_level
Definition: sql_system_table_check.h:91
THD * thd()
Definition: sql_system_table_check.h:44
THD * m_thd
Definition: sql_system_table_check.h:90
System_table_intact(THD *thd, enum loglevel log_level=ERROR_LEVEL)
Definition: sql_system_table_check.h:39
void report_error(uint code, const char *fmt,...) override
Definition: sql_system_table_check.h:47
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:609
bool has_keys
Definition: table.h:611
const char * ER_THD_NONCONST(const THD *thd, int mysql_errno)
Definition: derror.cc:112
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
void my_printv_error(uint error, const char *format, myf MyFlags, va_list ap)
Print an error message.
Definition: my_error.cc:290
#define LogErr(severity, ecode,...)
Definition: log_builtins.h:856
#define LOG_SUBSYSTEM_TAG
Definition: log_sink_test.cc:27
#define MY_BASENAME
Definition: my_basename.h:40
#define MYF(v)
Definition: my_inttypes.h:97
Definition of the global "loglevel" enumeration.
loglevel
Definition: my_loglevel.h:41
@ WARNING_LEVEL
Definition: my_loglevel.h:44
@ ERROR_LEVEL
Definition: my_loglevel.h:43
static loglevel log_level(const Sql_condition *condition)
Definition: histogram.cc:1644
const char * table_name
Definition: rules_table_service.cc:56
const char * db_name
Definition: rules_table_service.cc:55