MySQL 8.4.3
Source Code Documentation
terminology_use_previous.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 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 _TERMINOLOGY_USE_PREVIOUS_H_
25#define _TERMINOLOGY_USE_PREVIOUS_H_
26
27#include "storage/perfschema/pfs_instr_class.h" // PFS_class_type
28
30
31/**
32 Encapsulates a <name, version> pair, holding an instrumentation
33 name, and the version before which it was in use by the server.
34*/
36 /**
37 The old name, for an instrumentation name that was changed in some
38 server release.
39 */
40 const char *old_name;
41 /**
42 The version where the name was changed.
43 */
45};
46
47/**
48 For a given PFS_class_type, and a name within that class, return the
49 version-dependent alias for that name.
50
51 This is used when registering performance_schema names, to check if
52 there are any alternative names. If there are, those are stored in
53 the PFS_instr_class object. Later, when the name is required
54 (e.g. during the execution of SELECT * FROM
55 performance_schema.threads statement), it decides which name to use
56 based on the value of @@session.terminology_use_previous
57 and the fields that were stored in PFS_instr_class.
58
59 This framework is extensible, so in future versions we can rename
60 more names, and user will be able to choose exactly which version's
61 names will be used. However, note that the framework currently does
62 not support successive changes of *the same* identifier. This
63 limitation allows us to return just a singleton compatible_name_t
64 from this function. If, in the future, we need to make successive
65 changes to the same identifier, this function needs to be changed so
66 that it returns something like a std::map<ulong, char*>, for a given
67 instrumented object mapping versions to alternative names.
68
69 @param class_type The PFS_class_type of 'str', indicating whether it
70 is a mutex/rwlock/condition variable/memory allocation/thread
71 name/thread stage/thread command/etc.
72
73 @param str The object name to check.
74
75 @param use_prefix If true, 'str' is expected to begin with the
76 prefix for 'class_type', and the return value will include the
77 prefix. If false, 'str' is not expected to begin with the prefix
78 and the return value will not include the prefix.
79
80 @retval A compatible_name_t object. If there is an alternative name,
81 'old_name' points to a static buffer containing that name, and
82 'version' represents the enum_compatibility_version where that name
83 was introduced. If there is no alternative name, 'old_name' is
84 nullptr and version is 0.
85*/
86compatible_name_t lookup(PFS_class_type class_type, std::string str,
87 bool use_prefix = true);
88
89/**
90 Checks the session variable
91 @@session.terminology_use_previous, to determine whether
92 an instrumented object that was renamed in the given version should
93 use the old name.
94
95 @param version The version where the instrumentation name was
96 renamed.
97
98 @retval true The old instrumentation name should be used.
99
100 @retval false The new instrumentation name should be used.
101*/
103
104} // namespace terminology_use_previous
105
106#endif // ifndef _TERMINOLOGY_USE_PREVIOUS_H_
PFS_class_type
Definition: pfs_instr_class.h:113
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
In respect to the organization of modules, this really belongs in terminology_use_previous....
Definition: terminology_use_previous.cc:200
bool is_older_required(enum_compatibility_version version)
Checks the session variable @session.terminology_use_previous, to determine whether an instrumented o...
Definition: terminology_use_previous.cc:233
enum_compatibility_version
Enumeration holding the possible values for @terminology_use_previous.
Definition: terminology_use_previous_enum.h:48
compatible_name_t lookup(PFS_class_type class_type, const std::string str, bool use_prefix)
For a given PFS_class_type, and a name within that class, return the version-dependent alias for that...
Definition: terminology_use_previous.cc:202
Performance schema instruments metadata (declarations).
required uint64 version
Definition: replication_group_member_actions.proto:41
Encapsulates a <name, version> pair, holding an instrumentation name, and the version before which it...
Definition: terminology_use_previous.h:35
const char * old_name
The old name, for an instrumentation name that was changed in some server release.
Definition: terminology_use_previous.h:40
enum_compatibility_version version
The version where the name was changed.
Definition: terminology_use_previous.h:44