MySQL 9.0.0
Source Code Documentation
table_error_log.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 TABLE_ERROR_LOG_H
25#define TABLE_ERROR_LOG_H
26
27/**
28 @file storage/perfschema/table_error_log.h
29 TABLE ERROR_LOG (declarations for table,
30 indices, and keys).
31*/
32
33#include <sys/types.h>
34#include <time.h>
35
36#include "my_inttypes.h"
42
43/**
44 @addtogroup performance_schema_error_log
45 @{
46*/
47
48/*
49 These values have a fixed relationship with
50 (SYSTEM|ERROR|WARNING|INFORMATION)_LEVEL
51 from <my_loglevel.h> and must not be changed
52 except in response to changes in that header.
53*/
59};
60
61/**
62 Key for the LOGGED (timestamp/primary key) column.
63
64 We process these values as ulongongs, so inherit from PFS_key_ulonglong.
65 The keys are stored as TIMESTAMP(6) however, so we use a custom reader
66 that reads that format and returns a ulonglong.
67*/
69 public:
70 explicit PFS_key_error_log_logged(const char *name)
72
73 ~PFS_key_error_log_logged() override = default;
74
75 void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override {
76 m_find_flag = reader.read_timestamp(find_flag, m_is_null, &m_key_value, 6);
77 }
78
79 bool match(const log_sink_pfs_event *row);
80
81 private:
83 0}; // TIMESTAMP(6) (microsecond precision) as ulonglong
84};
85
86/// index on the LOGGED (timestamp/primary key) column
88 public:
90 : PFS_index_error_log(&m_key), m_key("LOGGED") {}
91
92 ~PFS_index_error_log_by_logged() override = default;
93
94 bool match(log_sink_pfs_event *row) override;
95
96 private:
98};
99
100/// key for the THREAD_ID column
102 public:
103 explicit PFS_key_error_log_thread_id(const char *name)
105
106 ~PFS_key_error_log_thread_id() override = default;
107
108 bool match(const log_sink_pfs_event *row);
109};
110
111/// index on the THREAD_ID column
113 public:
115 : PFS_index_error_log(&m_key), m_key("THREAD_ID") {}
116
118
119 bool match(log_sink_pfs_event *row) override;
120
121 private:
123};
124
125/// key for the PRIO column
127 public:
128 explicit PFS_key_error_log_prio(const char *name)
130
131 ~PFS_key_error_log_prio() override = default;
132
133 void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override;
134
135 bool match(const log_sink_pfs_event *row);
136
137 private:
139};
140
141/// index on the PRIO column
143 public:
145
146 ~PFS_index_error_log_by_prio() override = default;
147
148 bool match(log_sink_pfs_event *row) override;
149
150 private:
152};
153
154/// key for the ERROR_CODE column
156 public:
158 : PFS_index_error_log(&m_key), m_key("ERROR_CODE") {}
159
161
162 bool match(log_sink_pfs_event *row) override;
163
164 private:
166};
167
168/// index on the ERROR_CODE column
170 public:
172 : PFS_index_error_log(&m_key), m_key("SUBSYSTEM") {}
173
174 ~PFS_index_error_log_by_subsys() override = default;
175
176 bool match(log_sink_pfs_event *row) override;
177
178 private:
180};
181
182/** Table PERFORMANCE_SCHEMA.ERROR_LOG. */
184 public:
185 /** Table share */
187 /** Table builder */
189
190 protected:
191 /** Fill in a row's fields from this class's buffer. */
192 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
193 bool read_all) override;
194
195 protected:
197 /** Create an index for the column with the ordinal idx. */
198 int index_init(uint idx, bool sorted) override;
199
200 public:
201 ~table_error_log() override = default;
202
203 private:
204 /** Copy an event from the ring-buffer into this class's buffer. */
205 int make_row(log_sink_pfs_event *e) override;
206
207 /** Table share lock. */
209 /** Table definition. */
211
212 /** Current row. */
213 log_sink_pfs_event m_header; ///< event-header copied from ring-buffer
214 char m_message[LOG_BUFF_MAX]; ///< message (DATA column) from ring-buffer
215};
216
217/** @} */
218
219#endif
Definition: field.h:577
bool m_is_null
Definition: pfs_engine_table.h:281
enum ha_rkey_function m_find_flag
Definition: pfs_engine_table.h:280
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
key for the ERROR_CODE column
Definition: table_error_log.h:155
PFS_key_name m_key
Definition: table_error_log.h:165
bool match(log_sink_pfs_event *row) override
Match function for the index on the ERROR_CODE column.
Definition: table_error_log.cc:201
~PFS_index_error_log_by_error_code() override=default
PFS_index_error_log_by_error_code()
Definition: table_error_log.h:157
index on the LOGGED (timestamp/primary key) column
Definition: table_error_log.h:87
~PFS_index_error_log_by_logged() override=default
PFS_index_error_log_by_logged()
Definition: table_error_log.h:89
bool match(log_sink_pfs_event *row) override
Match function for the index on the LOGGED column.
Definition: table_error_log.cc:119
PFS_key_error_log_logged m_key
Definition: table_error_log.h:97
index on the PRIO column
Definition: table_error_log.h:142
PFS_index_error_log_by_prio()
Definition: table_error_log.h:144
bool match(log_sink_pfs_event *row) override
Match function for the index on the PRIO column.
Definition: table_error_log.cc:191
PFS_key_error_log_prio m_key
Definition: table_error_log.h:151
~PFS_index_error_log_by_prio() override=default
index on the ERROR_CODE column
Definition: table_error_log.h:169
bool match(log_sink_pfs_event *row) override
Match function for the index on the SUBSYSTEM column.
Definition: table_error_log.cc:211
PFS_index_error_log_by_subsys()
Definition: table_error_log.h:171
PFS_key_name m_key
Definition: table_error_log.h:179
~PFS_index_error_log_by_subsys() override=default
index on the THREAD_ID column
Definition: table_error_log.h:112
~PFS_index_error_log_by_thread_id() override=default
PFS_key_error_log_thread_id m_key
Definition: table_error_log.h:122
PFS_index_error_log_by_thread_id()
Definition: table_error_log.h:114
bool match(log_sink_pfs_event *row) override
Match function for the index on the THREAD_ID column.
Definition: table_error_log.cc:134
Generic index for error_log table.
Definition: cursor_by_error_log.h:242
Key for the LOGGED (timestamp/primary key) column.
Definition: table_error_log.h:68
ulonglong m_key_value
Definition: table_error_log.h:82
PFS_key_error_log_logged(const char *name)
Definition: table_error_log.h:70
void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override
Definition: table_error_log.h:75
~PFS_key_error_log_logged() override=default
bool match(const log_sink_pfs_event *row)
Match function / comparator for the key on the LOGGED column.
Definition: table_error_log.cc:113
key for the PRIO column
Definition: table_error_log.h:126
void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override
Read function for the key on the PRIO column.
Definition: table_error_log.cc:177
enum enum_prio m_prio
Definition: table_error_log.h:138
PFS_key_error_log_prio(const char *name)
Definition: table_error_log.h:128
~PFS_key_error_log_prio() override=default
bool match(const log_sink_pfs_event *row)
Match function / comparator for the key on the PRIO column.
Definition: table_error_log.cc:144
key for the THREAD_ID column
Definition: table_error_log.h:101
~PFS_key_error_log_thread_id() override=default
bool match(const log_sink_pfs_event *row)
Match function / comparator for the key on the THREAD_ID column.
Definition: table_error_log.cc:129
PFS_key_error_log_thread_id(const char *name)
Definition: table_error_log.h:103
Definition: table_helper.h:1556
Definition: table_helper.h:1702
Definition: table_helper.h:1257
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Cursor CURSOR_BY_ERROR_LOG for error_log table.
Definition: cursor_by_error_log.h:252
Table PERFORMANCE_SCHEMA.ERROR_LOG.
Definition: table_error_log.h:183
static THR_LOCK m_table_lock
Table share lock.
Definition: table_error_log.h:208
static PFS_engine_table_share m_share
Table share.
Definition: table_error_log.h:186
table_error_log()
Definition: table_error_log.cc:108
static Plugin_table m_table_def
Table definition.
Definition: table_error_log.h:210
log_sink_pfs_event m_header
Current row.
Definition: table_error_log.h:213
static PFS_engine_table * create(PFS_engine_table_share *)
Table builder.
Definition: table_error_log.cc:103
int index_init(uint idx, bool sorted) override
Create an index for the column with the ordinal idx.
Definition: table_error_log.cc:228
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Fill in a row's fields from this class's buffer.
Definition: table_error_log.cc:288
int make_row(log_sink_pfs_event *e) override
Copy an event from the ring-buffer into this class's buffer.
Definition: table_error_log.cc:267
char m_message[LOG_BUFF_MAX]
message (DATA column) from ring-buffer
Definition: table_error_log.h:214
~table_error_log() override=default
Cursor CURSOR_BY_ERROR_LOG (declarations); PFS_ringbuffer_index, PFS_index_error_log.
enum ha_rkey_function read_timestamp(enum ha_rkey_function find_flag, bool &isnull, ulonglong *value, uint dec)
Definition: pfs_engine_table.cc:1348
enum_prio
Definition: table_error_log.h:54
@ PS_ERROR_LOG_PRIO_NOTE
Definition: table_error_log.h:58
@ PS_ERROR_LOG_PRIO_WARNING
Definition: table_error_log.h:57
@ PS_ERROR_LOG_PRIO_SYSTEM
Definition: table_error_log.h:55
@ PS_ERROR_LOG_PRIO_ERROR
Definition: table_error_log.h:56
#define LOG_BUFF_MAX
advisory.
Definition: log_shared.h:225
ha_rkey_function
Definition: my_base.h:78
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
Data types for columns used in the performance schema tables (declarations)
This file contains.
case opt name
Definition: sslopt-case.h:29
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:358
PFS_key_reader: Convert key into internal format.
Definition: pfs_engine_table.h:196
Definition: table.h:1407
Definition: thr_lock.h:139
Definition: log_sink_perfschema.h:59
Helpers to implement a performance schema table.
Include file for Sun RPC to compile out of the box.