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