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