MXS-2315: Tokenized CS version extraction
The STL regex implementations have proven to be unreliable on older systems and replacing the regex with hand-written code for version extraction is less prone to break.
This commit is contained in:
parent
fb785d1afc
commit
a4c6f3542a
@ -56,17 +56,22 @@ static std::string do_query(MXS_MONITORED_SERVER* srv, const char* query)
|
||||
// Returns a numeric version similar to mysql_get_server_version
|
||||
int get_cs_version(MXS_MONITORED_SERVER* srv)
|
||||
{
|
||||
// GCC 4.8 appears to have a broken std::regex_constants::ECMAScript that doesn't support brackets
|
||||
std::regex re("Columnstore \\([0-9]*\\)[.]\\([0-9]*\\)[.]\\([0-9]*\\)-[0-9]*",
|
||||
std::regex_constants::basic);
|
||||
std::string result = do_query(srv, "SELECT @@version_comment");
|
||||
std::smatch match;
|
||||
int rval = 0;
|
||||
std::string prefix = "Columnstore ";
|
||||
std::string result = do_query(srv, "SELECT @@version_comment");
|
||||
auto pos = result.find(prefix);
|
||||
|
||||
if (std::regex_match(result, match, re) && match.size() == 4)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
rval = atoi(match[1].str().c_str()) * 10000 + atoi(match[2].str().c_str()) * 100
|
||||
+ atoi(match[3].str().c_str());
|
||||
std::istringstream os(result.substr(pos + prefix.length()));
|
||||
int major = 0, minor = 0, patch = 0;
|
||||
char dot;
|
||||
os >> major;
|
||||
os >> dot;
|
||||
os >> minor;
|
||||
os >> dot;
|
||||
os >> patch;
|
||||
rval = major * 10000 + minor * 100 + patch;
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
Loading…
x
Reference in New Issue
Block a user