MySQL 9.1.0
Source Code Documentation
my_version.cc File Reference

Functions to compare server version strings and and determine if clone should be allowed. More...

#include <algorithm>
#include <array>
#include <cassert>
#include <string>

Typedefs

typedef std::array< std::string, CLONE_PARSE_ARRAY_SIZEParseArray
 Parsed version strings array type. More...
 

Functions

static bool is_valid_version (const std::string &version)
 Helper function to determine if version string is made up of digits only. More...
 
static ParseArray parse_version_string (std::string version, bool &is_valid)
 Parse a version string into an array of strings corresponding to the MAJOR, MINOR, PATCH and BUILD versions. More...
 
bool are_versions_clone_compatible (std::string ver1, std::string ver2)
 Compares versions and determine if clone is allowed. More...
 

Variables

constexpr unsigned int CLONE_PARSE_ARRAY_SIZE = 4
 Size of the parsed version strings array. More...
 
constexpr unsigned int MAJOR = 0
 Index of the array correpsonding to parts of version. More...
 
constexpr unsigned int MINOR = 1
 
constexpr unsigned int PATCH = 2
 
constexpr unsigned int BUILD = 3
 
constexpr unsigned long CLONE_BACKPORT_VERSION = 37
 

Detailed Description

Functions to compare server version strings and and determine if clone should be allowed.

Typedef Documentation

◆ ParseArray

typedef std::array<std::string, CLONE_PARSE_ARRAY_SIZE> ParseArray

Parsed version strings array type.

Function Documentation

◆ is_valid_version()

static bool is_valid_version ( const std::string &  version)
inlinestatic

Helper function to determine if version string is made up of digits only.

Parameters
[in]versionversion string being validated
Returns
true if the non-empty string only contains digits

◆ parse_version_string()

static ParseArray parse_version_string ( std::string  version,
bool &  is_valid 
)
static

Parse a version string into an array of strings corresponding to the MAJOR, MINOR, PATCH and BUILD versions.

A string of length 0 is filled in case a particular version string could not be parsed. For example, "Major.Minor.Patch-Build" yields ["Major", "Minor", "Patch", "Build"], "8.0.23-SR1" yields ["8", "0", "23", "SR1"],

Parameters
[in]versioninput version string
[in,out]is_validtrue if version string is valid
Returns
an array of strings containing the parsed components of the version string.

Variable Documentation

◆ BUILD

constexpr unsigned int BUILD = 3
constexpr

◆ CLONE_BACKPORT_VERSION

constexpr unsigned long CLONE_BACKPORT_VERSION = 37
constexpr

◆ CLONE_PARSE_ARRAY_SIZE

constexpr unsigned int CLONE_PARSE_ARRAY_SIZE = 4
constexpr

Size of the parsed version strings array.

◆ MAJOR

constexpr unsigned int MAJOR = 0
constexpr

Index of the array correpsonding to parts of version.

◆ MINOR

constexpr unsigned int MINOR = 1
constexpr

◆ PATCH

constexpr unsigned int PATCH = 2
constexpr