MySQL 8.0.31
Source Code Documentation
table_id.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 2022, 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 @file table_id.h
24
25 @brief Contains the class Table_id, mainly used for row based replication.
26*/
27
28#ifndef TABLE_ID_INCLUDED
29#define TABLE_ID_INCLUDED
30#include <stdint.h>
31#include "wrapper_functions.h"
32
33/**
34 @class Table_id
35
36 @brief Each table share has a table id, it is mainly used for row based
37 replication. Meanwhile it is used as table's version too.
38*/
39class Table_id {
40 private:
41 /* In table map event and rows events, table id is 6 bytes.*/
42 static const unsigned long long TABLE_ID_MAX = (~0ULL >> 16);
43 uint64_t m_id;
44
45 public:
46 Table_id() : m_id(0) {}
47 explicit Table_id(unsigned long long id) : m_id(id) {}
48
49 unsigned long long id() const { return m_id; }
50 bool is_valid() const { return m_id <= TABLE_ID_MAX; }
51
52 Table_id &operator=(unsigned long long id) {
53 m_id = id;
54 return *this;
55 }
56
57 bool operator==(const Table_id &tid) const { return m_id == tid.m_id; }
58 bool operator!=(const Table_id &tid) const { return m_id != tid.m_id; }
59
60 /* Support implicit type converting from Table_id to unsigned long long */
61 operator unsigned long long() const { return m_id; }
62
65
66 /* m_id is reset to 0, when it exceeds the max value. */
67 m_id = (m_id == TABLE_ID_MAX ? 0 : m_id + 1);
68
70 return id;
71 }
72};
73
74#endif
Each table share has a table id, it is mainly used for row based replication.
Definition: table_id.h:39
static const unsigned long long TABLE_ID_MAX
Definition: table_id.h:42
Table_id(unsigned long long id)
Definition: table_id.h:47
bool operator==(const Table_id &tid) const
Definition: table_id.h:57
uint64_t m_id
Definition: table_id.h:43
bool operator!=(const Table_id &tid) const
Definition: table_id.h:58
bool is_valid() const
Definition: table_id.h:50
unsigned long long id() const
Definition: table_id.h:49
Table_id & operator=(unsigned long long id)
Definition: table_id.h:52
Table_id operator++(int)
Definition: table_id.h:63
Table_id()
Definition: table_id.h:46
Contains wrapper functions for memory allocation and deallocation.
#define BAPI_ASSERT(x)
Definition: wrapper_functions.h:61