1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2011 Andrew Hutchings
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "client_priv.h"
24
#include <client/server_detect.h>
26
ServerDetect::ServerDetect(drizzle_con_st *connection) :
27
type(SERVER_UNKNOWN_FOUND),
30
boost::match_flag_type flags = boost::match_default;
32
boost::regex mysql_regex("^([3-9]\\.[0-9]+\\.[0-9]+)");
33
boost::regex drizzle_regex("^(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
35
version= drizzle_con_server_version(connection);
37
if (regex_search(version, drizzle_regex, flags))
39
type= SERVER_DRIZZLE_FOUND;
41
else if (regex_search(version, mysql_regex, flags))
43
type= SERVER_MYSQL_FOUND;
47
std::cerr << "Server version not detectable. Assuming MySQL." << std::endl;
48
type= SERVER_MYSQL_FOUND;