MySQL 9.1.0
Source Code Documentation
sess0sess.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2013, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/sess0sess.h
29 InnoDB session state tracker.
30 Multi file, shared, system tablespace implementation.
31
32 Created 2014-04-30 by Krunal Bauskar
33 *******************************************************/
34
35#ifndef sess0sess_h
36#define sess0sess_h
37
39#include "dict0mem.h"
40#include "log0meb.h"
41#include "srv0tmp.h"
42#include "trx0trx.h"
43#include "univ.i"
44#include "ut0new.h"
45
46#include <map>
47
49 public:
50 /** Constructor
51 @param[in,out] handler table handler. */
53 /* Do nothing. */
54 }
55
56 /** Destructor */
58
59 public:
60 /* Table Handler holding other metadata information commonly needed
61 for any table. */
63};
64
65/** InnoDB private data that is cached in THD */
66typedef std::map<
67 std::string, dict_intrinsic_table_t *, std::less<std::string>,
70
72 public:
73 /** Constructor */
76 /* Do nothing. */
77 }
78
79 /** Destructor */
81 m_trx = nullptr;
82
83 for (table_cache_t::iterator it = m_open_tables.begin();
84 it != m_open_tables.end(); ++it) {
85 delete (it->second);
86 }
87
89
90 if (m_usr_temp_tblsp != nullptr) {
92 }
93
94 if (m_intrinsic_temp_tblsp != nullptr) {
96 }
97 }
98
99 /** Cache table handler.
100 @param[in] table_name name of the table
101 @param[in,out] table table handler to register */
106 }
107
108 /** Lookup for table handler given table_name.
109 @param[in] table_name name of the table to lookup */
111 table_cache_t::iterator it = m_open_tables.find(table_name);
112 return ((it == m_open_tables.end()) ? nullptr : it->second->m_handler);
113 }
114
115 /** Remove table handler entry.
116 @param[in] table_name name of the table to remove */
118 table_cache_t::iterator it = m_open_tables.find(table_name);
119 if (it == m_open_tables.end()) {
120 return;
121 }
122
123 delete (it->second);
125 }
126
127 /** Count of register table handler.
128 @return number of register table handlers */
130 return (static_cast<uint>(m_open_tables.size()));
131 }
132
134 if (m_usr_temp_tblsp == nullptr) {
137 }
138
139 return (m_usr_temp_tblsp);
140 }
141
143 if (m_intrinsic_temp_tblsp == nullptr) {
146 }
147
148 return (m_intrinsic_temp_tblsp);
149 }
150
151 public:
152 /** transaction handler. */
154
155 /** Handler of tables that are created or open but not added
156 to InnoDB dictionary as they are session specific.
157 Currently, limited to intrinsic temporary tables only. */
159
160 private:
161 /** Current session's user temp tablespace */
163
164 /** Current session's optimizer temp tablespace */
166};
167
168#endif /* sess0sess_h */
Definition: sess0sess.h:48
dict_table_t * m_handler
Definition: sess0sess.h:62
dict_intrinsic_table_t(dict_table_t *handler)
Constructor.
Definition: sess0sess.h:52
~dict_intrinsic_table_t()
Destructor.
Definition: sess0sess.h:57
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4583
Tablespace * get(my_thread_id id, enum tbsp_purpose purpose)
Return a session temporary tablespace.
Definition: srv0tmp.cc:199
Session Temporary tablespace.
Definition: srv0tmp.h:50
Definition: sess0sess.h:71
trx_t * m_trx
transaction handler.
Definition: sess0sess.h:153
ibt::Tablespace * get_instrinsic_temp_tblsp()
Definition: sess0sess.h:142
innodb_session_t()
Constructor.
Definition: sess0sess.h:74
ibt::Tablespace * m_intrinsic_temp_tblsp
Current session's optimizer temp tablespace.
Definition: sess0sess.h:165
dict_table_t * lookup_table_handler(const char *table_name)
Lookup for table handler given table_name.
Definition: sess0sess.h:110
uint count_register_table_handler() const
Count of register table handler.
Definition: sess0sess.h:129
ibt::Tablespace * m_usr_temp_tblsp
Current session's user temp tablespace.
Definition: sess0sess.h:162
ibt::Tablespace * get_usr_temp_tblsp()
Definition: sess0sess.h:133
void unregister_table_handler(const char *table_name)
Remove table handler entry.
Definition: sess0sess.h:117
void register_table_handler(const char *table_name, dict_table_t *table)
Cache table handler.
Definition: sess0sess.h:102
table_cache_t m_open_tables
Handler of tables that are created or open but not added to InnoDB dictionary as they are session spe...
Definition: sess0sess.h:158
~innodb_session_t()
Destructor.
Definition: sess0sess.h:80
Allocator that allows std::* containers to manage their memory through ut::malloc* and ut::free libra...
Definition: ut0new.h:2183
Data dictionary memory object creation.
uint32 my_thread_id
Definition: my_thread_local.h:34
uint16_t value_type
Definition: vt100.h:184
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
class Tablespace_pool * tbsp_pool
Pool of temporary tablespace.
Definition: srv0tmp.cc:62
void free_tmp(Tablespace *ts)
Release a tablespace back to the pool.
Definition: srv0tmp.cc:381
@ TBSP_INTRINSIC
Tablespace is used for intrinsic tables.
Definition: srv0tmp.h:39
@ TBSP_USER
Tablespace is used for user temporary tables.
Definition: srv0tmp.h:37
void redo_log_archive_session_end(innodb_session_t *session)
Security function to be called when the current session ends.
Definition: log0meb.cc:1739
const char * table_name
Definition: rules_table_service.cc:56
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2894
std::map< std::string, dict_intrinsic_table_t *, std::less< std::string >, ut::allocator< std::pair< const std::string, dict_intrinsic_table_t * > > > table_cache_t
InnoDB private data that is cached in THD.
Definition: sess0sess.h:69
my_thread_id thd_thread_id(const THD *thd)
Definition: sql_thd_internal_api.cc:386
Data structure for a database table.
Definition: dict0mem.h:1904
Definition: trx0trx.h:675
THD * mysql_thd
MySQL thread handle corresponding to this trx, or NULL.
Definition: trx0trx.h:932
The transaction.
Version control for database, common definitions, and include files.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...