MySQL  8.0.18
Source Code Documentation
dynamic_loader_scheme_file.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_SERVER_DYNAMIC_LOADER_SCHEMA_FILE_H
24 #define MYSQL_SERVER_DYNAMIC_LOADER_SCHEMA_FILE_H
25 
29 #include <mysql/psi/mysql_rwlock.h>
30 #include <map>
31 #include <unordered_set>
32 #include "server_component.h"
33 
35  typedef std::map<std::string, void *> my_registry;
36  typedef mysql_component_t *(*list_components_func)();
37 
39  static std::unordered_set<list_components_func> library_entry_set;
41 
42  public:
43  /**
44  Initializes file:// scheme for dynamic loader for usage. Initializes
45  RW lock, all other structures should be empty. Shouldn't be called multiple
46  times.
47  */
48  static void init();
49  /**
50  De-initializes RW lock, all other structures doesn't require any action.
51  */
52  static void deinit();
53 
54  public:
55  /**
56  Loads components that are located in executable file specified by URN.
57  We assume that URN starts with file://, but accept any. Will not success
58  when called multiple times on the same file.
59 
60  @param urn URN to file to load components from.
61  @param [out] out_data Pointer to pointer to MySQL component data structures
62  to set result components data retrieved from specified file.
63  @return Status of performed operation
64  @retval false success
65  @retval true Failure, may be caused when name does not contain ://, cannot
66  be located, is not proper executable file or does not contain proper
67  initialization function.
68  */
69  static DEFINE_BOOL_METHOD(load,
70  (const char *urn, mysql_component_t **out_data));
71 
72  /**
73  Unloads file that was previously loaded. The URN string must be exactly
74  the same as one used during call to load. Although you can call load() on
75  specified URN multiple times, subsequent calls unload() will always fail,
76  and all components from specified file will be invalid after first call to
77  unload().
78 
79  @param urn URN to file to unload all components from.
80  @return Status of performed operation
81  @retval false success
82  @retval true failure
83  */
84  static DEFINE_BOOL_METHOD(unload, (const char *urn));
85 };
86 
87 #endif /* MYSQL_SERVER_DYNAMIC_LOADER_SCHEMA_FILE_H */
static mysql_service_status_t unload(const char *urn) noexcept
Unloads file that was previously loaded.
Definition: dynamic_loader_scheme_file.cc:172
static mysql_service_status_t load(const char *urn, mysql_component_t **out_data) noexcept
Loads components that are located in executable file specified by URN.
Definition: dynamic_loader_scheme_file.cc:82
#define DEFINE_BOOL_METHOD(name, args)
static void init()
Initializes file:// scheme for dynamic loader for usage.
Definition: dynamic_loader_scheme_file.cc:54
static std::unordered_set< list_components_func > library_entry_set
Definition: dynamic_loader_scheme_file.h:39
static void deinit()
De-initializes RW lock, all other structures doesn&#39;t require any action.
Definition: dynamic_loader_scheme_file.cc:62
Carries information on the specific Component, all Service Implementations it provides, all its requirements and metadata.
Definition: dynamic_loader.h:259
Instrumentation helpers for rwlock.
static my_registry object_files_list
Definition: dynamic_loader_scheme_file.h:38
Definition: dynamic_loader_scheme_file.h:34
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:50
static mysql_rwlock_t LOCK_dynamic_loader_scheme_file
Definition: dynamic_loader_scheme_file.h:40
std::map< std::string, void * > my_registry
Definition: dynamic_loader_scheme_file.h:35
Defines MySQL Server Component.
Specifies macros to define Service Implementations.