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