MySQL 8.4.0
Source Code Documentation
rpl_tblmap.h
Go to the documentation of this file.
1/* Copyright (c) 2005, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef TABLE_MAPPING_H
25#define TABLE_MAPPING_H
26
27#include <sys/types.h>
28
29#include "map_helpers.h"
30#include "my_alloc.h"
31#include "my_inttypes.h"
32
33/* Forward declarations */
34#ifdef MYSQL_SERVER
35struct TABLE;
36
38#else
40
42#endif
43
44/**
45 Maps table id's (integers) to table pointers.
46
47 In mysqlbinlog, "table pointer" means Table_map_log_event*.
48
49 In the server, "table pointer" means TABLE*.
50*/
52 private:
54
55 public:
60 };
61
64
66
67 int set_table(ulonglong table_id, Mapped_table *table);
68 int remove_table(ulonglong table_id);
69 void clear_tables();
70 ulong count() const { return static_cast<ulong>(m_table_ids.size()); }
71
72 private:
73 struct entry {
75 union {
78 };
79 };
80
81 int expand();
82
83 /*
84 Head of the list of free entries; "free" in the sense that it's an
85 allocated entry free for use, NOT in the sense that it's freed
86 memory.
87 */
89
90 /*
91 Map from table ids (numbers) to Mapped_table objects.
92
93 No destructor for entries passed here, as the entries are allocated in a
94 MEM_ROOT (freed as a whole in the destructor), they cannot be freed one by
95 one.
96 */
98};
99
100#endif
Table_map_log_event which maps a table definition to a number.
Definition: log_event.h:2429
std::unordered_map, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:157
Maps table id's (integers) to table pointers.
Definition: rpl_tblmap.h:51
void clear_tables()
Definition: rpl_tblmap.cc:143
entry * m_free
Definition: rpl_tblmap.h:88
table_mapping()
Definition: rpl_tblmap.cc:57
ulong count() const
Definition: rpl_tblmap.h:70
~table_mapping()
Definition: rpl_tblmap.cc:62
enum_error
Definition: rpl_tblmap.h:56
@ ERR_NO_ERROR
Definition: rpl_tblmap.h:57
@ ERR_MEMORY_ALLOCATION
Definition: rpl_tblmap.h:59
@ ERR_LIMIT_EXCEEDED
Definition: rpl_tblmap.h:58
int remove_table(ulonglong table_id)
Definition: rpl_tblmap.cc:127
int set_table(ulonglong table_id, Mapped_table *table)
Definition: rpl_tblmap.cc:100
malloc_unordered_map< ulonglong, entry * > m_table_ids
Definition: rpl_tblmap.h:97
int expand()
Definition: rpl_tblmap.cc:88
MEM_ROOT m_mem_root
Definition: rpl_tblmap.h:53
Mapped_table * get_table(ulonglong table_id)
Definition: rpl_tblmap.cc:68
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
TABLE Mapped_table
Definition: rpl_tblmap.h:35
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: table.h:1405
Definition: rpl_tblmap.h:73
Mapped_table * table
Definition: rpl_tblmap.h:76
entry * next
Definition: rpl_tblmap.h:77
ulonglong table_id
Definition: rpl_tblmap.h:74