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