Client ServerDetect() guesses server type (Drizzle, MySQL) based on version number.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Drizzle |
Fix Released
|
Medium
|
Ajaya Agrawal |
Bug Description
drizzle/
*******
ServerDetect:
type(
version("")
{
boost:
// FIXME: Detecting capabilities from a version number is a recipe for
// disaster, like we've seen with 15 years of JavaScript :-)
// Anyway, as there is no MySQL 7.x yet, this will do for tonight.
// I will get back to detect something tangible after the release (like
// presence of some table or its record in DATA_DICTIONARY.
boost::regex mysql_regex(
boost::regex drizzle_
boost::regex drizzle_
version= drizzle_
if (regex_
{
type= SERVER_
}
else if (regex_
{
type= SERVER_
}
else if (regex_
{
type= SERVER_MYSQL_FOUND;
}
else
{
std::cerr << "Server version not detectable. Assuming MySQL." << std::endl;
type= SERVER_MYSQL_FOUND;
}
}
*******
This is used by at least drizzledump to determine whether it is connected to a MySQL server or a Drizzle server. It will use different SQL syntax depending on server type. (MySQL syntax will fail on Drizzle and Drizzle syntax will garble character sets on MySQL.)
In addition to drizzledump, it seems the "DESCRIBE tablename" command in a drizzle client is different depending on the return value of this function: true/false vs 1/0. I don't know if that is significant. (But it made a few tests fail.)
The above check will obviously fail once MySQL releases a 7.1 version. Making conclusions based on a version number is a common anti-pattern in javascript, it always fails (already did). The fix is something where we know for real the server type and not just deduce it from version number.
If the only client that really needs this information is drizzledump, then my suggestion is to simply deprecate this function and build some check into drizzledump instead. For instance drizzledump can just do "SET NAMES UTF8" and if it works it is a MySQL server and if it is an error it is a Drizzle server. (Set names is what drizzledump wants to do in the first place.)
Related branches
- Andrew Hutchings: Approve
- Stewart Smith: Pending requested
-
Diff: 77 lines (+22/-27)1 file modifiedclient/server_detect.cc (+22/-27)
Changed in drizzle: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
tags: | added: client |
Changed in drizzle: | |
assignee: | nobody → Ajaya Agrawal (aj--) |
Changed in drizzle: | |
status: | Confirmed → Fix Committed |
Changed in drizzle: | |
status: | Fix Committed → Fix Released |
Note: It is worth emphasizing that testing whether "SET NAMES UTF8" works is an ok solution for drizzledump, however, if the intent is to replace this function with another implementation, then such a check of course isn't good because it alters state in the case of a MySQL server. If we want to implement a generic check, it needs to be readonly. One idea that comes to mind is "SELECT * FROM mysql.user LIMIT 1". A drizzled server shouldn't have a mysql schema or a mysql.user table, but of course it could have if someone created one just to make trouble. So this isn't foolproof either. Just illustrates that the whole idea of providing this kind of function is a bit shaky...