← Back to team overview

linux-traipu team mailing list archive

[Bug 951788] Re: Client ServerDetect() guesses server type (Drizzle, MySQL) based on version number.

 

** Changed in: drizzle
     Assignee: (unassigned) => Ajaya Agrawal (aj--)

-- 
You received this bug notification because you are a member of UBUNTU -
AL - BR, which is subscribed to Drizzle.
https://bugs.launchpad.net/bugs/951788

Title:
  Client ServerDetect() guesses server type (Drizzle, MySQL) based on
  version number.

Status in A Lightweight SQL Database for Cloud Infrastructure and Web Applications:
  Confirmed

Bug description:
  drizzle/client/server_detect.cc has the following function:

  **************************************************************
  ServerDetect::ServerDetect(drizzle_con_st *connection) :
    type(SERVER_UNKNOWN_FOUND),
    version("")
  {
    boost::match_flag_type flags = boost::match_default;

    // 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("^([3-6]\\.[0-9]+\\.[0-9]+)");
    boost::regex drizzle_regex7("^(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
    boost::regex drizzle_regex71("^([7-9]\\.[0-9]+\\.[0-9]+)");

    version= drizzle_con_server_version(connection);

    if (regex_search(version, drizzle_regex7, flags))
    {
      type= SERVER_DRIZZLE_FOUND;
    }
    else if (regex_search(version, drizzle_regex71, flags))
    {
      type= SERVER_DRIZZLE_FOUND;
    }
    else if (regex_search(version, mysql_regex, flags))
    {
      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.)

To manage notifications about this bug go to:
https://bugs.launchpad.net/drizzle/+bug/951788/+subscriptions


References