MySQL 26.7.0
Source Code Documentation
my_server_version.h
Go to the documentation of this file.
1/* Copyright (c) 2026, 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 MY_SERVER_VERSION_INCLUDED
25#define MY_SERVER_VERSION_INCLUDED
26
27#include "my_inttypes.h" // uint
28
30 uint version{0};
31 bool is_lts{false};
32 uint previous_lts{0}; // MYSQL_PREVIOUS_LTS_VERSION_ID, or 0 if absent.
35
36 uint major() const { return version / 10000; }
37 uint minor() const { return (version / 100) % 100; }
38 uint patch() const { return version % 100; }
39 uint base() const { return version / 100; }
40 uint previous_lts_base() const { return previous_lts / 100; }
41
42 bool operator<(const My_server_version &other) const {
43 return version < other.version;
44 }
45
46 bool operator>=(const My_server_version &other) const {
47 return version >= other.version;
48 }
49
50 bool has_same_lts_lineage_as(const My_server_version &other) const {
51 return previous_lts_base() != 0 &&
53 }
54
56 return previous_lts_base() != 0 && previous_lts_base() == source.base();
57 }
58
59 bool is_calendar() const { return major() >= 26; }
60
61 static constexpr uint encode_version(uint major, uint minor, uint patch) {
62 return major * 10000 + minor * 100 + patch;
63 }
64
65 /**
66 Parse a version string to extract the major, minor and patch from the
67 version and encode into version ID. The version 0 is returned in case the
68 version string could not be parsed. For example, a version string like
69 "9.7.4" will be encoded as the integer 90704.
70
71 @param[in] version_string input version string
72 @return encoded version ID calculated as 10000 * Major + 100 * Minor + Patch
73 */
74 static uint version_string_to_id(const std::string &version_string);
75};
76
77#endif // MY_SERVER_VERSION_INCLUDED
Some integer typedefs for easier portability.
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
Definition: my_server_version.h:29
bool operator>=(const My_server_version &other) const
Definition: my_server_version.h:46
bool has_same_lts_lineage_as(const My_server_version &other) const
Definition: my_server_version.h:50
bool operator<(const My_server_version &other) const
Definition: my_server_version.h:42
uint minor() const
Definition: my_server_version.h:37
uint version
Definition: my_server_version.h:30
uint upgrade_threshold
Definition: my_server_version.h:33
static constexpr uint encode_version(uint major, uint minor, uint patch)
Definition: my_server_version.h:61
uint base() const
Definition: my_server_version.h:39
uint downgrade_threshold
Definition: my_server_version.h:34
bool is_calendar() const
Definition: my_server_version.h:59
uint previous_lts_base() const
Definition: my_server_version.h:40
uint patch() const
Definition: my_server_version.h:38
bool is_lts
Definition: my_server_version.h:31
bool starts_lts_lineage_after(const My_server_version &source) const
Definition: my_server_version.h:55
uint previous_lts
Definition: my_server_version.h:32
static uint version_string_to_id(const std::string &version_string)
Parse a version string to extract the major, minor and patch from the version and encode into version...
Definition: my_server_version.cc:78
uint major() const
Definition: my_server_version.h:36