MySQL 9.0.0
Source Code Documentation
service_plugin_registry.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_SERVICE_PLUGIN_REGISTRY_INCLUDED
25/**
26 @file
27 Declaration of the registry plugin service
28*/
29
31
32/**
33 @ingroup group_ext_plugin_services
34 A bridge service allowing plugins to work with the registry.
35
36 This allows traditional MySQL plugins to interact with the service
37 registry.
38 All this plugins service does is to return a reference to the
39 registry service.
40 Using that the plugins can access the rest of the registry and
41 dynamic loaders services, as well as other services present in the
42 registry.
43 Note that the plugins must release the service references they
44 acquire otherwise resources will be leaked and normal unload order
45 may be affected.
46*/
47extern "C" struct plugin_registry_service_st {
48 /**
49 Acquire a pointer to the registry service
50
51 The reference must be released by calling
52 plugin_registry_service_st::mysql_plugin_registry_release_func()
53 See @ref mysql_plugin_registry_acquire() for more details.
54
55 Once you receive the registry pointer you can use it to acquire
56 references to other services your plugin might be interested in.
57
58 @note
59 This is to be considered an "expensive" operation because it
60 requires access to the global structures of the
61 @ref PAGE_COMPONENTS_REGISTRY. Avoid using it in situations
62 where fast and scalable execution is required.
63 Since the registry service is very unlikely to change often
64 holding on to the reference to it for extended time periods
65 is a safe bet.
66
67 @note
68 Achieveing scalability through preserving references does not
69 come for free.
70 These are some of the effects on code that caches active
71 references:
72 - components implementing services to which active references
73 are held cannot be unloaded.
74 - code keeping an active reference to e.g. a default service
75 implementation will not switch to a possible new default
76 service implementation installed by a component loaded in
77 the meanwhile, as taking the updated default service implementation
78 would only happen at the time of acquiring a new reference.
79
80 @return the registry pointer
81
82 See also: @ref PAGE_COMPONENTS, @ref PAGE_COMPONENTS_REGISTRY,
83 @ref mysql_plugin_registry_acquire(), @ref mysql_plugin_registry_release()
84 */
85 SERVICE_TYPE(registry) * (*mysql_plugin_registry_acquire_func)();
86 /**
87 Release a pointer to the registry service
88
89 Releases the reference to the registry service, as returned by
90 @ref mysql_plugin_registry_acquire().
91 After this call the reigstry_ptr is undefined and
92 should not be used anymore.
93 See @ref mysql_plugin_registry_release() for more details.
94
95 @warning
96 Before releasing the reference to the registry service please
97 make sure you have released all the other service references
98 that you explicitly or implicitly acquired. These can't be
99 released without a valid reference to the registry service.
100
101 @note
102 This is also to be considered an "expensive" operation.
103 See @ref plugin_registry_service_st::mysql_plugin_registry_acquire_func
104 for more details on pros and cons of re-acquiring references vs caching
105 and reusing them.
106
107 @param registry_ptr the registry pointer
108 @return execution status
109 @retval 0 success
110 @retval non-zero failure
111
112 See also @ref PAGE_COMPONENTS, @ref PAGE_COMPONENTS_REGISTRY,
113 @ref mysql_plugin_registry_release(), @ref mysql_plugin_registry_acquire()
114 */
116 registry_ptr);
118
119#ifdef MYSQL_DYNAMIC_PLUGIN
120#define mysql_plugin_registry_acquire() \
121 plugin_registry_service->mysql_plugin_registry_acquire_func()
122#define mysql_plugin_registry_release(r) \
123 plugin_registry_service->mysql_plugin_registry_release_func(r)
124#else
127#endif
128
129#define MYSQL_SERVICE_PLUGIN_REGISTRY_INCLUDED
130#endif /* MYSQL_SERVICE_PLUGIN_REGISTRY_INCLUDED */
struct plugin_registry_service_st * plugin_registry_service
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
const mysql_service_registry_t * mysql_plugin_registry_acquire()
Returns a new reference to the "registry" service.
Definition: plugin_registry_service.cc:47
int mysql_plugin_registry_release(const mysql_service_registry_t *)
Releases a registry service reference.
Definition: plugin_registry_service.cc:75
A bridge service allowing plugins to work with the registry.
Definition: service_plugin_registry.h:47
int(* mysql_plugin_registry_release_func)(const mysql_service_registry_t *registry_ptr)
Release a pointer to the registry service.
Definition: service_plugin_registry.h:115