MySQL 8.0.33
Source Code Documentation
table_error_log.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef TABLE_ERROR_LOG_H
24#define TABLE_ERROR_LOG_H
25
26/**
27 @file storage/perfschema/table_error_log.h
28 TABLE ERROR_LOG (declarations for table,
29 indices, and keys).
30*/
31
32#include <sys/types.h>
33#include <time.h>
34
35#include "my_inttypes.h"
41
42/**
43 @addtogroup performance_schema_error_log
44 @{
45*/
46
47/*
48 These values have a fixed relationship with
49 (SYSTEM|ERROR|WARNING|INFORMATION)_LEVEL
50 from <my_loglevel.h> and must not be changed
51 except in response to changes in that header.
52*/
58};
59
60/**
61 Key for the LOGGED (timestamp/primary key) column.
62
63 We process these values as ulongongs, so inherit from PFS_key_ulonglong.
64 The keys are stored as TIMESTAMP(6) however, so we use a custom reader
65 that reads that format and returns a ulonglong.
66*/
68 public:
69 explicit PFS_key_error_log_logged(const char *name)
71
72 ~PFS_key_error_log_logged() override = default;
73
74 void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override {
75 m_find_flag = reader.read_timestamp(find_flag, m_is_null, &m_key_value, 6);
76 }
77
78 bool match(const log_sink_pfs_event *row);
79
80 private:
81 ulonglong m_key_value; // TIMESTAMP(6) (microsecond precision) as ulonglong
82};
83
84/// index on the LOGGED (timestamp/primary key) column
86 public:
88 : PFS_index_error_log(&m_key), m_key("LOGGED") {}
89
90 ~PFS_index_error_log_by_logged() override = default;
91
92 bool match(log_sink_pfs_event *row) override;
93
94 private:
96};
97
98/// key for the THREAD_ID column
100 public:
101 explicit PFS_key_error_log_thread_id(const char *name)
103
104 ~PFS_key_error_log_thread_id() override = default;
105
106 bool match(const log_sink_pfs_event *row);
107};
108
109/// index on the THREAD_ID column
111 public:
113 : PFS_index_error_log(&m_key), m_key("THREAD_ID") {}
114
116
117 bool match(log_sink_pfs_event *row) override;
118
119 private:
121};
122
123/// key for the PRIO column
125 public:
126 explicit PFS_key_error_log_prio(const char *name)
128
129 ~PFS_key_error_log_prio() override = default;
130
131 void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override;
132
133 bool match(const log_sink_pfs_event *row);
134
135 private:
137};
138
139/// index on the PRIO column
141 public:
143
144 ~PFS_index_error_log_by_prio() override = default;
145
146 bool match(log_sink_pfs_event *row) override;
147
148 private:
150};
151
152/// key for the ERROR_CODE column
154 public:
156 : PFS_index_error_log(&m_key), m_key("ERROR_CODE") {}
157
159
160 bool match(log_sink_pfs_event *row) override;
161
162 private:
164};
165
166/// index on the ERROR_CODE column
168 public:
170 : PFS_index_error_log(&m_key), m_key("SUBSYSTEM") {}
171
172 ~PFS_index_error_log_by_subsys() override = default;
173
174 bool match(log_sink_pfs_event *row) override;
175
176 private:
178};
179
180/** Table PERFORMANCE_SCHEMA.ERROR_LOG. */
182 public:
183 /** Table share */
185 /** Table builder */
187
188 protected:
189 /** Fill in a row's fields from this class's buffer. */
190 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
191 bool read_all) override;
192
193 protected:
195 /** Create an index for the column with the ordinal idx. */
196 int index_init(uint idx, bool sorted) override;
197
198 public:
199 ~table_error_log() override = default;
200
201 private:
202 /** Copy an event from the ring-buffer into this class's buffer. */
203 int make_row(log_sink_pfs_event *e) override;
204
205 /** Table share lock. */
207 /** Table definition. */
209
210 /** Current row. */
211 log_sink_pfs_event m_header; ///< event-header copied from ring-buffer
212 char m_message[LOG_BUFF_MAX]; ///< message (DATA column) from ring-buffer
213};
214
215/** @} */
216
217#endif
Definition: field.h:574
bool m_is_null
Definition: pfs_engine_table.h:280
enum ha_rkey_function m_find_flag
Definition: pfs_engine_table.h:279
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:69
key for the ERROR_CODE column
Definition: table_error_log.h:153
PFS_key_name m_key
Definition: table_error_log.h:163
bool match(log_sink_pfs_event *row) override
Match function for the index on the ERROR_CODE column.
Definition: table_error_log.cc:200
~PFS_index_error_log_by_error_code() override=default
PFS_index_error_log_by_error_code()
Definition: table_error_log.h:155
index on the LOGGED (timestamp/primary key) column
Definition: table_error_log.h:85
~PFS_index_error_log_by_logged() override=default
PFS_index_error_log_by_logged()
Definition: table_error_log.h:87
bool match(log_sink_pfs_event *row) override
Match function for the index on the LOGGED column.
Definition: table_error_log.cc:116
PFS_key_error_log_logged m_key
Definition: table_error_log.h:95
index on the PRIO column
Definition: table_error_log.h:140
PFS_index_error_log_by_prio()
Definition: table_error_log.h:142
bool match(log_sink_pfs_event *row) override
Match function for the index on the PRIO column.
Definition: table_error_log.cc:190
PFS_key_error_log_prio m_key
Definition: table_error_log.h:149
~PFS_index_error_log_by_prio() override=default
index on the ERROR_CODE column
Definition: table_error_log.h:167
bool match(log_sink_pfs_event *row) override
Match function for the index on the SUBSYSTEM column.
Definition: table_error_log.cc:210
PFS_index_error_log_by_subsys()
Definition: table_error_log.h:169
PFS_key_name m_key
Definition: table_error_log.h:177
~PFS_index_error_log_by_subsys() override=default
index on the THREAD_ID column
Definition: table_error_log.h:110
~PFS_index_error_log_by_thread_id() override=default
PFS_key_error_log_thread_id m_key
Definition: table_error_log.h:120
PFS_index_error_log_by_thread_id()
Definition: table_error_log.h:112
bool match(log_sink_pfs_event *row) override
Match function for the index on the THREAD_ID column.
Definition: table_error_log.cc:131
Generic index for error_log table.
Definition: cursor_by_error_log.h:241
Key for the LOGGED (timestamp/primary key) column.
Definition: table_error_log.h:67
ulonglong m_key_value
Definition: table_error_log.h:81
PFS_key_error_log_logged(const char *name)
Definition: table_error_log.h:69
void read(PFS_key_reader &reader, enum ha_rkey_function find_flag) override
Definition: table_error_log.h:74
~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:110
key for the PRIO column
Definition: table_error_log.h:124
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:176
enum enum_prio m_prio
Definition: table_error_log.h:136
PFS_key_error_log_prio(const char *name)
Definition: table_error_log.h:126
~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:141
key for the THREAD_ID column
Definition: table_error_log.h:99
~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:126
PFS_key_error_log_thread_id(const char *name)
Definition: table_error_log.h:101
Definition: table_helper.h:1507
Definition: table_helper.h:1653
Definition: table_helper.h:1228
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:39
Cursor CURSOR_BY_ERROR_LOG for error_log table.
Definition: cursor_by_error_log.h:251
Table PERFORMANCE_SCHEMA.ERROR_LOG.
Definition: table_error_log.h:181
static THR_LOCK m_table_lock
Table share lock.
Definition: table_error_log.h:206
static PFS_engine_table_share m_share
Table share.
Definition: table_error_log.h:184
table_error_log()
Definition: table_error_log.cc:107
static Plugin_table m_table_def
Table definition.
Definition: table_error_log.h:208
log_sink_pfs_event m_header
Current row.
Definition: table_error_log.h:211
static PFS_engine_table * create(PFS_engine_table_share *)
Table builder.
Definition: table_error_log.cc:102
int index_init(uint idx, bool sorted) override
Create an index for the column with the ordinal idx.
Definition: table_error_log.cc:227
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:287
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:266
char m_message[LOG_BUFF_MAX]
message (DATA column) from ring-buffer
Definition: table_error_log.h:212
~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:1334
enum_prio
Definition: table_error_log.h:53
@ PS_ERROR_LOG_PRIO_NOTE
Definition: table_error_log.h:57
@ PS_ERROR_LOG_PRIO_WARNING
Definition: table_error_log.h:56
@ PS_ERROR_LOG_PRIO_SYSTEM
Definition: table_error_log.h:54
@ PS_ERROR_LOG_PRIO_ERROR
Definition: table_error_log.h:55
#define LOG_BUFF_MAX
advisory.
Definition: log_shared.h:224
ha_rkey_function
Definition: my_base.h:77
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: buf0block_hint.cc:29
Data types for columns used in the performance schema tables (declarations)
This file contains.
case opt name
Definition: sslopt-case.h:32
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:357
PFS_key_reader: Convert key into internal format.
Definition: pfs_engine_table.h:195
Definition: table.h:1395
Definition: thr_lock.h:138
Definition: log_sink_perfschema.h:58
Helpers to implement a performance schema table.
Include file for Sun RPC to compile out of the box.
unsigned int uint
Definition: uca9-dump.cc:74