MySQL 9.0.0
Source Code Documentation
mysql_thd_store_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 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 SQL_SERVER_COMPONENT_MYSQL_THD_STORE_IMP_H
25#define SQL_SERVER_COMPONENT_MYSQL_THD_STORE_IMP_H
26
27#include <unordered_map>
28
31
35 std::unordered_map<unsigned int, void *> &data);
36
38 public:
39 /**
40 Register a slot to store data specific to a component
41
42 The free_resource callback is used to free the stored pointer
43 before thd is destroyed
44
45 @param [in] name Implementation name
46 @param [in] free_fn Callback to free resource stored in the slot
47 @param [out] slot Key used to identify the object handle
48
49 @returns status of registration
50 @retval false Success
51 @retval true Error. This typically means all slots are full
52 */
54 (const char *name, free_resource_fn free_fn,
56
57 /**
58 Unregister a slot
59
60 @param [in, out] slot Key allocated to component
61
62 @returns status of operation
63 @retval false Success
64 @retval true Error
65 */
67
68 /**
69 Adds an opaque pointer to the session object
70
71 @param [in] thd Session handle. If NULL, current session will be used.
72 @param [in] slot Key used to identify the object handle
73 @param [in] object Handle of the object being stored. If NULL, it will be
74 considered removal.
75
76 @returns Status of the operation
77 @retval false Success
78 @retval true Error
79 */
81 void *object));
82
83 /**
84 Get handle to an already stored object without removing it
85
86 @param [in] thd Session handle. If NULL, current session will be used.
87 @param [in] slot Key used to identify the object handle
88
89 @returns handle to the object if found, nullptr otherwise
90 */
91 static DEFINE_METHOD(void *, get, (MYSQL_THD thd, mysql_thd_store_slot slot));
92};
93
94#endif // !SQL_SERVER_COMPONENT_MYSQL_THD_STORE_IMP_H
#define MYSQL_THD
Definition: backup_page_tracker.h:38
Definition: mysql_thd_store_imp.h:37
static mysql_service_status_t set(THD *thd, mysql_thd_store_slot slot, void *object) noexcept
Adds an opaque pointer to the session object.
Definition: mysql_thd_store_imp.cc:155
static mysql_service_status_t register_slot(const char *name, free_resource_fn free_fn, mysql_thd_store_slot *slot) noexcept
Register a slot to store data specific to a component.
Definition: mysql_thd_store_imp.cc:126
static mysql_service_status_t unregister_slot(mysql_thd_store_slot slot) noexcept
Unregister a slot.
Definition: mysql_thd_store_imp.cc:142
static void * get(THD *thd, mysql_thd_store_slot slot) noexcept
Get handle to an already stored object without removing it.
Definition: mysql_thd_store_imp.cc:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
void deinit_thd_store_service()
Definition: mysql_thd_store_imp.cc:112
void init_thd_store_service()
Definition: mysql_thd_store_imp.cc:107
bool free_thd_store_resource(THD *thd, std::unordered_map< unsigned int, void * > &data)
Definition: mysql_thd_store_imp.cc:118
Connection event tracking.
int(* free_resource_fn)(void *)
Callback to free resource stored in THD.
Definition: mysql_thd_store_service.h:37
struct mysql_thd_store_slot_imp * mysql_thd_store_slot
Definition: mysql_thd_store_service.h:30
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88
#define DEFINE_METHOD(retval, name, args)
A macro to ensure method implementation has required properties, that is it does not throw exceptions...
Definition: service_implementation.h:79
case opt name
Definition: sslopt-case.h:29