MySQL  8.0.17
Source Code Documentation
dynamic_loader.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
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 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 */
40 BEGIN_SERVICE_DEFINITION(dynamic_loader)
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 */
57 DECLARE_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 */
75 DECLARE_BOOL_METHOD(unload, (const char *urns[], int component_count));
76 END_SERVICE_DEFINITION(dynamic_loader)
77 
78 /**
79  Service for listing all Components by iterator.
80 */
81 BEGIN_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 */
92 DECLARE_BOOL_METHOD(create, (my_h_component_iterator * out_iterator));
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 */
106 DECLARE_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 */
138 END_SERVICE_DEFINITION(dynamic_loader_query)
139 
140 /**
141  Service for listing all metadata for a Component specified by the iterator.
142 */
143 BEGIN_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 */
203 END_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 */
209 BEGIN_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 */
225 DECLARE_BOOL_METHOD(get_value, (my_h_component_iterator iterator,
226  const char *name, const char **value));
227 END_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 */
260  const char *name;
266 };
267 
268 /**
269  Service for providing Components from a specified scheme of URN.
270 
271  All scheme loading Services are the same although they have separate names
272  (aliased to the main type) to allow a single component implement several
273  scheme loaders, to not break the recommendation to keep implementation names
274  the same as the component name, and to be able to create wrappers and other
275  solutions that require to have multiple implementations of a single type.
276 */
277 BEGIN_SERVICE_DEFINITION(dynamic_loader_scheme)
278 /**
279  Loads all Components that are located under the URN specified.
280 
281  @param urn URN to location of the component to load from.
282  @param [out] out_data Pointer to pointer to MySQL component data structures
283  to set result components data retrieved from specified file.
284  @return Status of performed operation
285  @retval false success
286  @retval true failure
287 */
288 DECLARE_BOOL_METHOD(load, (const char *urn, mysql_component_t **out_data));
289 /**
290  Unloads all Components that were previously loaded.
291 
292  @param urn URN to location to unload all components from.
293  @return Status of performed operation
294  @retval false success
295  @retval true failure
296 */
297 DECLARE_BOOL_METHOD(unload, (const char *urn));
298 END_SERVICE_DEFINITION(dynamic_loader_scheme)
299 
300 #endif /* MYSQL_DYNAMIC_LOADER_H */
void ** implementation
Definition: dynamic_loader.h:244
mysql_service_status_t(* deinit)()
Definition: dynamic_loader.h:265
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:306
const string name("\ame\)
struct mysql_service_ref_t * provides
Definition: dynamic_loader.h:261
Carries information on specific Service Implementation.
Definition: dynamic_loader.h:232
#define DEFINE_SERVICE_HANDLE(name)
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
struct mysql_metadata_ref_t * metadata
Definition: dynamic_loader.h:263
mysql_service_status_t(* init)()
Definition: dynamic_loader.h:264
struct mysql_service_placeholder_ref_t * requires
Definition: dynamic_loader.h:262
Carries information on the specific Component, all Service Implementations it provides, all its requirements and metadata.
Definition: dynamic_loader.h:259
#define DECLARE_METHOD(retval, name, args)
void * implementation
Definition: dynamic_loader.h:234
const char * name
Definition: dynamic_loader.h:243
Carries information on the specific Service requirement for some Component and a pointer to member wh...
Definition: dynamic_loader.h:242
const char * key
Definition: dynamic_loader.h:251
Specifies a key and value pair of the single Component metadata.
Definition: dynamic_loader.h:250
#define DECLARE_BOOL_METHOD(name, args)
#define BEGIN_SERVICE_DEFINITION(name)
int mysql_service_status_t
Specific type for the service status return values.
Definition: service.h:33
const char * name
Definition: dynamic_loader.h:260
Definition: dynamic_loader.cc:293
const char * name
Definition: dynamic_loader.h:233
Type get(const Shards &shards, size_t id)
Get the counter value for a shard.
Definition: ut0counter.h:267
const string value("\alue\)
#define END_SERVICE_DEFINITION(name)
const char * value
Definition: dynamic_loader.h:252
Definition: dynamic_loader.cc:288