MySQL 9.1.0
Source Code Documentation
mysql_option_tracker.h
Go to the documentation of this file.
1/* Copyright (c) 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_OPTION_TRACKER_H
25#define MYSQL_OPTION_TRACKER_H
26
28
29/**
30 @ingroup group_components_services_inventory
31
32 Option tracker registration and deregistration services
33
34 This is a service that will allow registering an option.
35 Each option has a name. The name is UTF8mb4 and is unique in
36 the list.
37 Manipulating the option list is an "expesive" operation since there
38 is a global lock involved.
39
40 Each code container (a component or a plugin) should register its
41 options during its initialization and should unregister them during
42 its deinitialization.
43*/
44BEGIN_SERVICE_DEFINITION(mysql_option_tracker_option)
45
46/**
47 Define an option. Adds an option definition.
48
49 If another option of the same name exists, the definition fails
50
51 @param option The name of the option, UTF8mb4. Must be unique.
52 @param container The container name. UTF8mb4
53 Please prefix with "plugin_" for plugins.
54 @param is_enabled non-0 if the option is marked as enabled, 0 otherwise
55 @retval false success
56 @retval true failure
57*/
58DECLARE_BOOL_METHOD(define, (const char *option, const char *container,
60/**
61 Undefine an option.
62
63 Fails if no option is defined with the same name
64
65 @param option The name of the option, US ASCII
66 @retval false success
67 @retval true failure
68*/
69DECLARE_BOOL_METHOD(undefine, (const char *option));
70
71/**
72 Set enabled for an existing element
73
74 if the option is not defined it fails
75
76 @param option The name of the option, US ASCII
77 @param is_enabled non-0 if the option is marked as enabled, 0 otherwise
78 @retval false success
79 @retval true failure
80*/
81DECLARE_BOOL_METHOD(set_enabled, (const char *option, int is_enabled));
82
83END_SERVICE_DEFINITION(mysql_option_tracker_option)
84
85/**
86 @ingroup group_components_services_inventory
87
88 Option tracker usage marker
89
90 Sets usage data for a given option.
91 Internally stores into the system table.
92
93 Cluster ID is set to empty.
94
95 It gets the value for server_id from the system variable
96 server_uuid.
97*/
98BEGIN_SERVICE_DEFINITION(mysql_option_tracker_usage)
99/**
100 Set usage data. Sets the persisted state
101
102 @param option The name of the option, US ASCII
103 @param usage_data_json Usage data, JSON, zero terminated UTF-8
104 @retval false success
105 @retval true failure
106*/
107DECLARE_BOOL_METHOD(set, (const char *option, const char *usage_data_json));
108/**
109 Get usage data. Reads the persisted state.
110 Stores a 0-terminated UTF-8 data into the supplied buffer. If the data to
111 be stored are too long for the buffer the function fails.
112
113 Reading is done in a separate auto-commit transaction.
114
115 @param option The name of the option, US ASCII
116 @param [out] usage_data A buffer to return the UTF-8 data in.
117 @param sizeof_usage_data The size of the usage_data_buffer in bytes.
118 otherwise.
119 @retval false success
120 @retval true failure
121*/
122DECLARE_BOOL_METHOD(get, (const char *option, char *usage_data,
123 size_t sizeof_usage_data));
124END_SERVICE_DEFINITION(mysql_option_tracker_usage)
125
126#endif /* MYSQL_OPTION_TRACKER_H */
Definition: atomics_array.h:39
bool is_enabled()
Check if doublewrite is enabled.
Definition: buf0dblwr.h:390
static mysql_service_status_t get(THD **thd) noexcept
Definition: mysql_current_thread_reader_all_empty.cc:31
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112