MySQL 8.3.0
Source Code Documentation
mysql_thd_store_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2023, 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 SQL_SERVER_COMPONENT_MYSQL_THD_STORE_IMP_H
24#define SQL_SERVER_COMPONENT_MYSQL_THD_STORE_IMP_H
25
26#include <unordered_map>
27
30
34 std::unordered_map<unsigned int, void *> &data);
35
37 public:
38 /**
39 Register a slot to store data specific to a component
40
41 The free_resource callback is used to free the stored pointer
42 before thd is destroyed
43
44 @param [in] name Implementation name
45 @param [in] free_fn Callback to free resource stored in the slot
46 @param [out] slot Key used to identify the object handle
47
48 @returns status of registration
49 @retval false Success
50 @retval true Error. This typically means all slots are full
51 */
53 (const char *name, free_resource_fn free_fn,
55
56 /**
57 Unregister a slot
58
59 @param [in, out] slot Key allocated to component
60
61 @returns status of operation
62 @retval false Success
63 @retval true Error
64 */
66
67 /**
68 Adds an opaque pointer to the session object
69
70 @param [in] thd Session handle. If NULL, current session will be used.
71 @param [in] slot Key used to identify the object handle
72 @param [in] object Handle of the object being stored. If NULL, it will be
73 considered removal.
74
75 @returns Status of the operation
76 @retval false Success
77 @retval true Error
78 */
80 void *object));
81
82 /**
83 Get handle to an already stored object without removing it
84
85 @param [in] thd Session handle. If NULL, current session will be used.
86 @param [in] slot Key used to identify the object handle
87
88 @returns handle to the object if found, nullptr otherwise
89 */
90 static DEFINE_METHOD(void *, get, (MYSQL_THD thd, mysql_thd_store_slot slot));
91};
92
93#endif // !SQL_SERVER_COMPONENT_MYSQL_THD_STORE_IMP_H
#define MYSQL_THD
Definition: backup_page_tracker.h:37
Definition: mysql_thd_store_imp.h:36
static mysql_service_status_t set(MYSQL_THD thd, mysql_thd_store_slot slot, void *object) noexcept
Adds an opaque pointer to the session object.
Definition: mysql_thd_store_imp.cc:154
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:125
static mysql_service_status_t unregister_slot(mysql_thd_store_slot slot) noexcept
Unregister a slot.
Definition: mysql_thd_store_imp.cc:141
static void * get(MYSQL_THD thd, mysql_thd_store_slot slot) noexcept
Get handle to an already stored object without removing it.
Definition: mysql_thd_store_imp.cc:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
void deinit_thd_store_service()
Definition: mysql_thd_store_imp.cc:111
void init_thd_store_service()
Definition: mysql_thd_store_imp.cc:106
bool free_thd_store_resource(THD *thd, std::unordered_map< unsigned int, void * > &data)
Definition: mysql_thd_store_imp.cc:117
Connection event tracking.
int(* free_resource_fn)(void *)
Callback to free resource stored in THD.
Definition: mysql_thd_store_service.h:36
struct mysql_thd_store_slot_imp * mysql_thd_store_slot
Definition: mysql_thd_store_service.h:29
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:87
#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:78
case opt name
Definition: sslopt-case.h:32