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