MySQL 8.4.2
Source Code Documentation
dynamic_loader.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 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_DYNAMIC_LOADER_H
25#define MYSQL_DYNAMIC_LOADER_H
26
28
29/**
30 A handle type for a iterator to a Component.
31*/
33/**
34 A handle type for a iterator to metadata of some Component.
35*/
37
38/**
39 Service for managing the list of loaded Components.
40*/
42/**
43 Loads specified group of components by URN, initializes them and
44 registers all Service Implementations present in these components.
45 Assures all dependencies will be met after loading specified components.
46 The dependencies may be circular, in such case it's necessary to specify
47 all components on cycle to load in one batch. From URNs specified the
48 scheme part of URN (part before "://") is extracted and used to acquire
49 Service Implementation of scheme component loader Service for specified
50 scheme.
51
52 @param urns List of URNs of components to load.
53 @param component_count Number of components on list to load.
54 @return Status of performed operation
55 @retval false success
56 @retval true failure
57*/
58DECLARE_BOOL_METHOD(load, (const char *urns[], int component_count));
59/**
60 Unloads specified group of components by URN, deinitializes them and
61 unregisters all Service Implementations present in these components.
62 Assumes, thous does not check it, all dependencies of not unloaded
63 components will still be met after unloading specified components.
64 The dependencies may be circular, in such case it's necessary to specify
65 all components on cycle to unload in one batch. From URNs specified the
66 scheme part of URN (part before "://") is extracted and used to acquire
67 Service Implementation of scheme component loader Service for specified
68 scheme.
69
70 @param urns List of URNs of components to unload.
71 @param component_count Number of components on list to unload.
72 @return Status of performed operation
73 @retval false success
74 @retval true failure
75*/
76DECLARE_BOOL_METHOD(unload, (const char *urns[], int component_count));
78
79/**
80 Service for listing all Components by iterator.
81*/
82BEGIN_SERVICE_DEFINITION(dynamic_loader_query)
83/**
84 Creates iterator that iterates through all loaded components.
85 If successful it leaves read lock on dynamic loader until iterator is
86 released.
87
88 @param [out] out_iterator Pointer to component iterator handle.
89 @return Status of performed operation
90 @retval false success
91 @retval true failure
92*/
94/**
95 Gets name and URN of Service pointed to by iterator.
96
97 @param iterator Component iterator handle.
98 @param [out] out_name Pointer to string with component name to set result
99 pointer to.
100 @param [out] out_urn Pointer to string with URN from which the component was
101 loaded from, to set result pointer to.
102 @return Status of performed operation
103 @retval false success
104 @retval true Failure, may be caused when called on iterator that went
105 through all values already.
106*/
107DECLARE_BOOL_METHOD(get, (my_h_component_iterator iter, const char **out_name,
108 const char **out_urn));
109/**
110 Advances specified iterator to next element. Will succeed but return true if
111 it reaches one-past-last element.
112
113 @param iterator Component iterator handle.
114 @return Status of performed operation and validity of iterator after
115 operation.
116 @retval false success
117 @retval true Failure or called on iterator that was on last element.
118*/
120/**
121 Checks if specified iterator is valid, i.e. have not reached one-past-last
122 element.
123
124 @param iterator Component iterator handle.
125 @return Validity of iterator
126 @retval false Valid
127 @retval true Invalid or reached one-past-last element.
128*/
130/**
131 Releases component iterator. Releases read lock on dynamic loader.
132
133 @param iterator Component iterator handle.
134 @return Status of performed operation
135 @retval false success
136 @retval true failure
137*/
139END_SERVICE_DEFINITION(dynamic_loader_query)
140
141/**
142 Service for listing all metadata for a Component specified by the iterator.
143*/
144BEGIN_SERVICE_DEFINITION(dynamic_loader_metadata_enumerate)
145/**
146 Creates iterator that iterates through all metadata for object pointed by
147 the specified iterator. If successful it leaves read lock on the registry
148 until the iterator is released.
149
150 @param iterator A iterator that points to object to get the metadata
151 iterator for.
152 @param [out] out_iterator Pointer to metadata iterator handle.
153 @return Status of performed operation
154 @retval false success
155 @retval true failure
156*/
159/**
160 Gets the key and value of the metadata pointed to by the specified iterator.
161
162 @param iterator Metadata iterator handle.
163 @param [out] out_name A pointer to the string with the key to set the result
164 pointer to.
165 @param [out] out_value A pointer to the string with the metadata value to
166 set the result pointer to.
167 @return Status of performed operation
168 @retval false success
169 @retval true Failure, may be caused when called on the iterator that went
170 through all values already.
171*/
173 const char **name, const char **value));
174/**
175 Advances specified iterator to next element. Will fail if it reaches
176 one-past-last element.
177
178 @param iterator Metadata iterator handle.
179 @return Status of performed operation
180 @retval false success
181 @retval true Failure, may be caused when called on iterator that was on the
182 last element.
183*/
185/**
186 Checks if specified iterator is valid, i.e. have not reached one-past-last
187 element.
188
189 @param iterator Metadata iterator handle.
190 @return Validity of iterator
191 @retval false Valid
192 @retval true Invalid or reached one-past-last element.
193*/
195/**
196 Releases the specified iterator. Releases read lock on the registry.
197
198 @param iterator Metadata iterator handle.
199 @return Status of performed operation
200 @retval false success
201 @retval true failure
202*/
204END_SERVICE_DEFINITION(dynamic_loader_metadata_enumerate)
205
206/**
207 Service to query specified metadata key directly for the specified Component
208 by iterator to it.
209*/
210BEGIN_SERVICE_DEFINITION(dynamic_loader_metadata_query)
211/**
212 Gets the key and value of the metadata pointed to by the specified object
213 iterator.
214
215 @param iterator A iterator that points to object to get the metadata
216 iterator for.
217 @param name A pointer to the string with the key to set the result
218 pointer to.
219 @param [out] out_value A pointer to the string with the metadata value to
220 set the result pointer to.
221 @return Status of performed operation
222 @retval false success
223 @retval true Failure, may be caused when called on the iterator that went
224 through all values already.
225*/
227 const char *name, const char **value));
228END_SERVICE_DEFINITION(dynamic_loader_metadata_query)
229
230/**
231 Carries information on specific Service Implementation.
232*/
234 const char *name;
236};
237
238/**
239 Carries information on the specific Service requirement for some Component and
240 a pointer to member where to store the acquired Service Implementation to
241 satisfy this requirement.
242*/
244 const char *name;
246};
247
248/**
249 Specifies a key and value pair of the single Component metadata.
250*/
252 const char *key;
253 const char *value;
254};
255
256/**
257 Carries information on the specific Component, all Service Implementations it
258 provides, all its requirements and metadata.
259*/
260#ifdef __clang__
261struct __attribute__((visibility("default"))) mysql_component_t {
262#else
264#endif
265 const char *name;
271};
272
273/**
274 Service for providing Components from a specified scheme of URN.
275
276 All scheme loading Services are the same although they have separate names
277 (aliased to the main type) to allow a single component implement several
278 scheme loaders, to not break the recommendation to keep implementation names
279 the same as the component name, and to be able to create wrappers and other
280 solutions that require to have multiple implementations of a single type.
281*/
282BEGIN_SERVICE_DEFINITION(dynamic_loader_scheme)
283/**
284 Loads all Components that are located under the URN specified.
285
286 @param urn URN to location of the component to load from.
287 @param [out] out_data Pointer to pointer to MySQL component data structures
288 to set result components data retrieved from specified file.
289 @return Status of performed operation
290 @retval false success
291 @retval true failure
292*/
293DECLARE_BOOL_METHOD(load, (const char *urn, mysql_component_t **out_data));
294/**
295 Unloads all Components that were previously loaded.
296
297 @param urn URN to location to unload all components from.
298 @return Status of performed operation
299 @retval false success
300 @retval true failure
301*/
302DECLARE_BOOL_METHOD(unload, (const char *urn));
303END_SERVICE_DEFINITION(dynamic_loader_scheme)
304
305#endif /* MYSQL_DYNAMIC_LOADER_H */
static mysql_service_status_t deinit()
Component deinitialization.
Definition: audit_api_message_emit.cc:580
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
bool is_valid(const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
Decides if a geometry is valid.
Definition: is_valid.cc:95
void get(PSI_field *, PSI_longlong *) noexcept
Definition: pfs_plugin_column_bigint_v1_all_empty.cc:32
static mysql_service_status_t create(const char *service_names[], reference_caching_channel *out_channel) noexcept
Definition: component.cc:45
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:103
int mysql_service_status_t
Specific type for the service status return values.
Definition: service.h:34
#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 DEFINE_SERVICE_HANDLE(name)
Defines an object type that is meant for carrying handles to the implementation-specific objects used...
Definition: service.h:129
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112
case opt name
Definition: sslopt-case.h:29
Definition: dynamic_loader.cc:300
Definition: dynamic_loader.cc:305
Carries information on the specific Component, all Service Implementations it provides,...
Definition: dynamic_loader.h:263
struct mysql_service_placeholder_ref_t * requires_service
Definition: dynamic_loader.h:267
struct mysql_service_ref_t * provides
Definition: dynamic_loader.h:266
const char * name
Definition: dynamic_loader.h:265
struct mysql_metadata_ref_t * metadata
Definition: dynamic_loader.h:268
Specifies a key and value pair of the single Component metadata.
Definition: dynamic_loader.h:251
const char * key
Definition: dynamic_loader.h:252
const char * value
Definition: dynamic_loader.h:253
Carries information on the specific Service requirement for some Component and a pointer to member wh...
Definition: dynamic_loader.h:243
const char * name
Definition: dynamic_loader.h:244
void ** implementation
Definition: dynamic_loader.h:245
Carries information on specific Service Implementation.
Definition: dynamic_loader.h:233
void * implementation
Definition: dynamic_loader.h:235
const char * name
Definition: dynamic_loader.h:234