17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
#include <drizzled/gettext.h>
22
22
#include <drizzled/error.h>
23
23
#include <drizzled/query_id.h>
24
#include <drizzled/error/sql_state.h>
24
#include <drizzled/sql_state.h>
25
25
#include <drizzled/session.h>
26
#include <drizzled/internal/m_string.h>
26
#include "drizzled/internal/m_string.h"
27
27
#include <algorithm>
28
28
#include <boost/program_options.hpp>
29
29
#include <drizzled/module/option_map.h>
30
#include <drizzled/util/tokenize.h>
30
#include "drizzled/util/tokenize.h"
31
31
#include "errmsg.h"
32
32
#include "mysql_protocol.h"
33
33
#include "mysql_password.h"
34
34
#include "options.h"
36
#include <drizzled/identifier.h>
38
#include <libdrizzle/constants.h>
35
#include "table_function.h"
37
#include "drizzled/identifier.h"
40
39
#define PROTOCOL_VERSION 10
440
int2store(buff, static_cast<uint16_t>(sql_errno));
432
int2store(buff,sql_errno);
443
435
/* The first # is to make the client backward compatible */
445
pos= (unsigned char*) strcpy((char*) buff+3, error::convert_to_sqlstate(sql_errno));
446
pos+= strlen(error::convert_to_sqlstate(sql_errno));
437
pos= (unsigned char*) strcpy((char*) buff+3, drizzle_errno_to_sqlstate(sql_errno));
438
pos+= strlen(drizzle_errno_to_sqlstate(sql_errno));
448
440
char *tmp= strncpy((char*)pos, err, DRIZZLE_ERRMSG_SIZE-1);
449
441
tmp+= strlen((char*)pos);
1024
1008
context("port",
1025
1009
po::value<port_constraint>(&port)->default_value(3306),
1026
_("Port number to use for connection or 0 for default to with MySQL "
1010
N_("Port number to use for connection or 0 for default to with MySQL "
1028
1012
context("connect-timeout",
1029
1013
po::value<timeout_constraint>(&connect_timeout)->default_value(10),
1030
_("Connect Timeout."));
1014
N_("Connect Timeout."));
1031
1015
context("read-timeout",
1032
1016
po::value<timeout_constraint>(&read_timeout)->default_value(30),
1033
_("Read Timeout."));
1017
N_("Read Timeout."));
1034
1018
context("write-timeout",
1035
1019
po::value<timeout_constraint>(&write_timeout)->default_value(60),
1036
_("Write Timeout."));
1020
N_("Write Timeout."));
1037
1021
context("retry-count",
1038
1022
po::value<retry_constraint>(&retry_count)->default_value(10),
1023
N_("Retry Count."));
1040
1024
context("buffer-length",
1041
1025
po::value<buffer_constraint>(&buffer_length)->default_value(16384),
1042
_("Buffer length."));
1026
N_("Buffer length."));
1043
1027
context("bind-address",
1044
1028
po::value<string>()->default_value(""),
1045
_("Address to bind to."));
1029
N_("Address to bind to."));
1046
1030
context("max-connections",
1047
1031
po::value<uint32_t>(&ListenMySQLProtocol::mysql_counters->max_connections)->default_value(1000),
1048
_("Maximum simultaneous connections."));
1032
N_("Maximum simultaneous connections."));
1049
1033
context("admin-ip-addresses",
1050
1034
po::value<vector<string> >()->composing()->notifier(&ClientMySQLProtocol::mysql_compose_ip_addresses),
1051
_("A restrictive IP address list for incoming admin connections."));
1035
N_("A restrictive IP address list for incoming admin connections."));
1038
static int mysql_protocol_connection_count_func(drizzle_show_var *var, char *buff)
1040
var->type= SHOW_LONGLONG;
1042
*((uint64_t *)buff)= ListenMySQLProtocol::mysql_counters->connectionCount;
1046
static int mysql_protocol_connected_count_func(drizzle_show_var *var, char *buff)
1048
var->type= SHOW_LONGLONG;
1050
*((uint64_t *)buff)= ListenMySQLProtocol::mysql_counters->connected;
1054
static int mysql_protocol_failed_count_func(drizzle_show_var *var, char *buff)
1056
var->type= SHOW_LONGLONG;
1058
*((uint64_t *)buff)= ListenMySQLProtocol::mysql_counters->failedConnections;
1062
static st_show_var_func_container mysql_protocol_connection_count=
1063
{ &mysql_protocol_connection_count_func };
1065
static st_show_var_func_container mysql_protocol_connected_count=
1066
{ &mysql_protocol_connected_count_func };
1068
static st_show_var_func_container mysql_protocol_failed_count=
1069
{ &mysql_protocol_failed_count_func };
1071
static drizzle_show_var mysql_protocol_status_variables[]= {
1073
(char*) &mysql_protocol_connection_count, SHOW_FUNC},
1075
(char*) &mysql_protocol_connected_count, SHOW_FUNC},
1076
{"Failed_connections",
1077
(char*) &mysql_protocol_failed_count, SHOW_FUNC},
1078
{NULL, NULL, SHOW_LONGLONG}
1081
MysqlProtocolStatus::Generator::Generator(drizzled::Field **fields) :
1082
plugin::TableFunction::Generator(fields)
1084
status_var_ptr= mysql_protocol_status_variables;
1087
bool MysqlProtocolStatus::Generator::populate()
1089
MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
1090
char * const buff= (char *) &buff_data;
1091
drizzle_show_var tmp;
1093
if (status_var_ptr->name)
1095
std::ostringstream oss;
1096
string return_value;
1100
push(status_var_ptr->name);
1102
if (status_var_ptr->type == SHOW_FUNC)
1104
((drizzle_show_var_func)((st_show_var_func_container *)status_var_ptr->value)->func)(&tmp, buff);
1110
value= status_var_ptr->value;
1111
type= status_var_ptr->type;
1117
oss << *(uint64_t*) value;
1118
return_value= oss.str();
1123
if (return_value.length())
1054
1135
} /* namespace drizzle_plugin */