MySQL 9.1.0
Source Code Documentation
table_processlist.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 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_PROCESSLIST_H
25#define TABLE_PROCESSLIST_H
26
27/**
28 @file storage/perfschema/table_processlist.h
29 TABLE THREADS.
30*/
31
32#include <sys/types.h>
33#include <time.h>
34#include <algorithm>
35
36#include "my_hostname.h"
37#include "my_inttypes.h"
41
42struct PFS_thread;
43
44/**
45 @addtogroup performance_schema_tables
46 @{
47*/
48
49/**
50 A row of PERFORMANCE_SCHEMA.PROCESSLIST.
51*/
53 /** Column ID. */
55 /** Column USER. */
57 /** Column HOST (and PORT). */
59 /** Length in bytes of @c m_hostname. */
61 /** Column DB. */
63 /** Column COMMAND. */
64 int m_command{0};
65 /** Column TIME. */
66 time_t m_start_time{0};
67 /** Column STATE. */
68 const char *m_processlist_state_ptr{nullptr};
69 /** Length in bytes of @c m_processlist_state_ptr. */
71 /** Column INFO. */
72 const char *m_processlist_info_ptr{nullptr};
73 /** Length in bytes of @c m_processlist_info_ptr. */
75 /** Column EXECUTION_ENGINE. */
76 bool m_secondary{false};
77};
78
80 public:
82 : PFS_index_threads(&m_key), m_key("ID") {}
83
85
86 bool match(PFS_thread *pfs) override;
87
88 private:
90};
91
93 /** User is not allowed to see any data. */
95 /** User does not have the PROCESS_ACL privilege. */
97 /** User has the PROCESS_ACL privilege. */
99};
100
105};
106
107/** Table PERFORMANCE_SCHEMA.PROCESSLIST. */
109 public:
110 /** Table share */
112 /** Table builder */
114
115 protected:
117
118 int rnd_init(bool scan [[maybe_unused]]) override;
119
120 int index_init(uint idx, bool sorted) override;
121 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
122 bool read_all) override;
123 int set_access();
124
125 public:
126 ~table_processlist() override = default;
127
128 private:
129 int make_row(PFS_thread *pfs) override;
130 /** Table share lock. */
132 /** Table definition. */
134 /** Current row. */
136 /** Row privileges. */
138};
139
140/** @} */
141#endif
Definition: field.h:577
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_processlist.h:79
PFS_index_processlist_by_processlist_id()
Definition: table_processlist.h:81
bool match(PFS_thread *pfs) override
Definition: table_processlist.cc:134
PFS_key_processlist_id m_key
Definition: table_processlist.h:89
~PFS_index_processlist_by_processlist_id() override=default
Definition: cursor_by_thread.h:42
Definition: table_helper.h:1309
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Cursor CURSOR_BY_THREAD.
Definition: cursor_by_thread.h:55
Table PERFORMANCE_SCHEMA.PROCESSLIST.
Definition: table_processlist.h:108
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_processlist.cc:129
row_processlist m_row
Current row.
Definition: table_processlist.h:135
table_processlist()
Definition: table_processlist.cc:95
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_processlist.cc:319
static PFS_engine_table_share m_share
Table share.
Definition: table_processlist.h:111
row_priv_processlist m_row_priv
Row privileges.
Definition: table_processlist.h:137
~table_processlist() override=default
int index_init(uint idx, bool sorted) override
Definition: table_processlist.cc:143
int set_access()
Definition: table_processlist.cc:99
static Plugin_table m_table_def
Table definition.
Definition: table_processlist.h:133
static THR_LOCK m_table_lock
Table share lock.
Definition: table_processlist.h:131
static PFS_engine_table * create(PFS_engine_table_share *)
Table builder.
Definition: table_processlist.cc:91
int make_row(PFS_thread *pfs) override
Definition: table_processlist.cc:158
Cursor CURSOR_BY_THREAD (declarations).
enum_priv_processlist
Definition: table_processlist.h:92
@ PROCESSLIST_USER_ONLY
User does not have the PROCESS_ACL privilege.
Definition: table_processlist.h:96
@ PROCESSLIST_DENIED
User is not allowed to see any data.
Definition: table_processlist.h:94
@ PROCESSLIST_ALL
User has the PROCESS_ACL privilege.
Definition: table_processlist.h:98
Common definition used by mysys, performance schema and server & client.
static constexpr int HOST_AND_PORT_LENGTH
Length of "hostname:portnumber".
Definition: my_hostname.h:55
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
#define USERNAME_LENGTH
Definition: mysql_com.h:69
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)
Object names (declarations).
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:359
Definition: pfs_name.h:194
Instrumented thread implementation.
Definition: pfs_instr.h:375
Definition: pfs_name.h:478
Definition: table.h:1421
Definition: thr_lock.h:139
Definition: table_processlist.h:101
char m_priv_user[USERNAME_LENGTH]
Definition: table_processlist.h:103
size_t m_priv_user_length
Definition: table_processlist.h:104
enum enum_priv_processlist m_auth
Definition: table_processlist.h:102
A row of PERFORMANCE_SCHEMA.PROCESSLIST.
Definition: table_processlist.h:52
uint m_hostname_length
Length in bytes of m_hostname.
Definition: table_processlist.h:60
PFS_schema_name m_db_name
Column DB.
Definition: table_processlist.h:62
PFS_user_name m_user_name
Column USER.
Definition: table_processlist.h:56
uint m_processlist_state_length
Length in bytes of m_processlist_state_ptr.
Definition: table_processlist.h:70
int m_command
Column COMMAND.
Definition: table_processlist.h:64
time_t m_start_time
Column TIME.
Definition: table_processlist.h:66
const char * m_processlist_info_ptr
Column INFO.
Definition: table_processlist.h:72
char m_hostname[HOST_AND_PORT_LENGTH]
Column HOST (and PORT).
Definition: table_processlist.h:58
ulonglong m_processlist_id
Column ID.
Definition: table_processlist.h:54
const char * m_processlist_state_ptr
Column STATE.
Definition: table_processlist.h:68
bool m_secondary
Column EXECUTION_ENGINE.
Definition: table_processlist.h:76
uint m_processlist_info_length
Length in bytes of m_processlist_info_ptr.
Definition: table_processlist.h:74
Include file for Sun RPC to compile out of the box.