~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/mysql_protocol.cc

  • Committer: kalebral at gmail
  • Date: 2010-12-04 04:58:08 UTC
  • mto: (1971.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1972.
  • Revision ID: kalebral@gmail.com-20101204045808-acto22oxfg43m02e
a few more updates of files that did not have license or had incorrect license structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
31
30
#include "errmsg.h"
32
31
#include "mysql_protocol.h"
33
32
#include "mysql_password.h"
34
33
#include "options.h"
35
34
#include "table_function.h"
36
35
 
37
 
#include "drizzled/identifier.h"
38
 
 
39
 
#define PROTOCOL_VERSION 10
40
 
 
41
36
namespace po= boost::program_options;
42
37
using namespace std;
43
38
using namespace drizzled;
44
39
 
45
 
namespace drizzle_plugin
46
 
{
 
40
#define PROTOCOL_VERSION 10
47
41
 
48
 
std::vector<std::string> ClientMySQLProtocol::mysql_admin_ip_addresses;
49
42
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
50
 
 
51
 
static port_constraint port;
52
 
static timeout_constraint connect_timeout;
53
 
static timeout_constraint read_timeout;
54
 
static timeout_constraint write_timeout;
55
 
static retry_constraint retry_count;
56
 
static buffer_constraint buffer_length;
57
 
 
 
43
static uint32_t port;
 
44
static uint32_t connect_timeout;
 
45
static uint32_t read_timeout;
 
46
static uint32_t write_timeout;
 
47
static uint32_t retry_count;
 
48
static uint32_t buffer_length;
 
49
static char* bind_address;
58
50
static uint32_t random_seed1;
59
51
static uint32_t random_seed2;
60
52
static const uint32_t random_max= 0x3FFFFFFF;
61
53
static const double random_max_double= (double)0x3FFFFFFF;
62
54
 
63
 
 
64
 
ProtocolCounters *ListenMySQLProtocol::mysql_counters= new ProtocolCounters();
 
55
static plugin::TableFunction* mysql_status_table_function_ptr= NULL;
65
56
 
66
57
ListenMySQLProtocol::~ListenMySQLProtocol()
67
 
{ }
 
58
{
 
59
  /* This is strdup'd from the options */
 
60
  free(bind_address);
 
61
}
68
62
 
69
 
const std::string ListenMySQLProtocol::getHost(void) const
 
63
const char* ListenMySQLProtocol::getHost(void) const
70
64
{
71
 
  return _hostname;
 
65
  return bind_address;
72
66
}
73
67
 
74
68
in_port_t ListenMySQLProtocol::getPort(void) const
75
69
{
76
 
  return port.get();
 
70
  return (in_port_t) port;
77
71
}
78
72
 
79
73
plugin::Client *ListenMySQLProtocol::getClient(int fd)
83
77
  if (new_fd == -1)
84
78
    return NULL;
85
79
 
86
 
  return new ClientMySQLProtocol(new_fd, _using_mysql41_protocol, getCounters());
 
80
  return new (nothrow) ClientMySQLProtocol(new_fd, using_mysql41_protocol);
87
81
}
88
82
 
89
 
ClientMySQLProtocol::ClientMySQLProtocol(int fd, bool using_mysql41_protocol, ProtocolCounters *set_counters):
90
 
  is_admin_connection(false),
91
 
  _using_mysql41_protocol(using_mysql41_protocol),
92
 
  counters(set_counters)
 
83
drizzled::atomic<uint64_t> ClientMySQLProtocol::connectionCount;
 
84
drizzled::atomic<uint64_t> ClientMySQLProtocol::failedConnections;
 
85
drizzled::atomic<uint64_t> ClientMySQLProtocol::connected;
 
86
 
 
87
ClientMySQLProtocol::ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg):
 
88
  using_mysql41_protocol(using_mysql41_protocol_arg)
93
89
{
94
 
  
95
90
  net.vio= 0;
96
91
 
97
92
  if (fd == -1)
98
93
    return;
99
94
 
100
 
  if (drizzleclient_net_init_sock(&net, fd, buffer_length.get()))
 
95
  if (drizzleclient_net_init_sock(&net, fd, buffer_length))
101
96
    throw bad_alloc();
102
97
 
103
 
  drizzleclient_net_set_read_timeout(&net, read_timeout.get());
104
 
  drizzleclient_net_set_write_timeout(&net, write_timeout.get());
105
 
  net.retry_count=retry_count.get();
 
98
  drizzleclient_net_set_read_timeout(&net, read_timeout);
 
99
  drizzleclient_net_set_write_timeout(&net, write_timeout);
 
100
  net.retry_count=retry_count;
106
101
}
107
102
 
108
103
ClientMySQLProtocol::~ClientMySQLProtocol()
147
142
  { 
148
143
    drizzleclient_net_close(&net);
149
144
    drizzleclient_net_end(&net);
150
 
    if (is_admin_connection)
151
 
      counters->adminConnected.decrement();
152
 
    else
153
 
      counters->connected.decrement();
 
145
    connected.decrement();
154
146
  }
155
147
}
156
148
 
157
149
bool ClientMySQLProtocol::authenticate()
158
150
{
159
151
  bool connection_is_valid;
160
 
  if (is_admin_connection)
161
 
  {
162
 
    counters->adminConnectionCount.increment();
163
 
    counters->adminConnected.increment();
164
 
  }
165
 
  else
166
 
  {
167
 
    counters->connectionCount.increment();
168
 
    counters->connected.increment();
169
 
  }
 
152
 
 
153
  connectionCount.increment();
 
154
  connected.increment();
170
155
 
171
156
  /* Use "connect_timeout" value during connection phase */
172
 
  drizzleclient_net_set_read_timeout(&net, connect_timeout.get());
173
 
  drizzleclient_net_set_write_timeout(&net, connect_timeout.get());
 
157
  drizzleclient_net_set_read_timeout(&net, connect_timeout);
 
158
  drizzleclient_net_set_write_timeout(&net, connect_timeout);
174
159
 
175
160
  connection_is_valid= checkConnection();
176
161
 
177
162
  if (connection_is_valid)
178
 
  {
179
 
    if (not is_admin_connection and (counters->connected > counters->max_connections))
180
 
    {
181
 
      std::string errmsg(ER(ER_CON_COUNT_ERROR));
182
 
      sendError(ER_CON_COUNT_ERROR, errmsg.c_str());
183
 
      counters->failedConnections.increment();
184
 
    }
185
 
    else
186
 
    {
187
 
      sendOK();
188
 
    }
189
 
  }
 
163
    sendOK();
190
164
  else
191
165
  {
192
166
    sendError(session->main_da.sql_errno(), session->main_da.message());
193
 
    counters->failedConnections.increment();
 
167
    failedConnections.increment();
194
168
    return false;
195
169
  }
196
 
 
197
170
  /* Connect completed, set read/write timeouts back to default */
198
 
  drizzleclient_net_set_read_timeout(&net, read_timeout.get());
199
 
  drizzleclient_net_set_write_timeout(&net, write_timeout.get());
 
171
  drizzleclient_net_set_read_timeout(&net, read_timeout);
 
172
  drizzleclient_net_set_write_timeout(&net, write_timeout);
200
173
  return true;
201
174
}
202
175
 
252
225
    (*l_packet)[0]= (unsigned char) COM_SLEEP;
253
226
    *packet_length= 1;
254
227
  }
255
 
  else if (_using_mysql41_protocol)
 
228
  else if (using_mysql41_protocol)
256
229
  {
257
230
    /* Map from MySQL commands to Drizzle commands. */
258
231
    switch ((int)(*l_packet)[0])
392
365
    drizzleclient_net_flush(&net);
393
366
    session->main_da.can_overwrite_status= false;
394
367
  }
395
 
  packet.shrink(buffer_length.get());
 
368
  packet.shrink(buffer_length);
396
369
}
397
370
 
398
371
 
502
475
    int2store(pos, field.charsetnr);
503
476
    int4store(pos+2, field.length);
504
477
 
505
 
    if (_using_mysql41_protocol)
 
478
    if (using_mysql41_protocol)
506
479
    {
507
480
      /* Switch to MySQL field numbering. */
508
481
      switch (field.type)
539
512
        pos[6]= 15;
540
513
        break;
541
514
 
542
 
      case DRIZZLE_TYPE_UUID:
543
 
        pos[6]= 15;
544
 
        break;
545
 
 
546
515
      case DRIZZLE_TYPE_DECIMAL:
547
516
        pos[6]= (char)246;
548
517
        break;
594
563
  char buff[MAX_FIELD_WIDTH];
595
564
  String str(buff,sizeof(buff), &my_charset_bin);
596
565
 
597
 
  from->val_str_internal(&str);
 
566
  from->val_str(&str);
598
567
 
599
568
  return netStoreData((const unsigned char *)str.ptr(), str.length());
600
569
}
665
634
  uint32_t pkt_len= 0;
666
635
  char *end;
667
636
  char scramble[SCRAMBLE_LENGTH];
668
 
  identifier::User::shared_ptr user_identifier= identifier::User::make_shared();
669
637
 
670
638
  makeScramble(scramble);
671
639
 
676
644
 
677
645
    if (drizzleclient_net_peer_addr(&net, ip, &peer_port, NI_MAXHOST))
678
646
    {
679
 
      my_error(ER_BAD_HOST_ERROR, MYF(0), ip);
 
647
      my_error(ER_BAD_HOST_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
680
648
      return false;
681
649
    }
682
650
 
683
 
    user_identifier->setAddress(ip);
 
651
    session->getSecurityContext().setIp(ip);
684
652
  }
685
653
  drizzleclient_net_keepalive(&net, true);
686
654
 
691
659
 
692
660
    server_capabilites= CLIENT_BASIC_FLAGS;
693
661
 
694
 
    if (_using_mysql41_protocol)
 
662
    if (using_mysql41_protocol)
695
663
      server_capabilites|= CLIENT_PROTOCOL_MYSQL41;
696
664
 
697
665
#ifdef HAVE_COMPRESS
735
703
        ||    (pkt_len= drizzleclient_net_read(&net)) == packet_error 
736
704
        || pkt_len < MIN_HANDSHAKE_SIZE)
737
705
    {
738
 
      my_error(ER_HANDSHAKE_ERROR, MYF(0), user_identifier->address().c_str());
 
706
      my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
739
707
      return false;
740
708
    }
741
709
  }
742
 
  if (packet.alloc(buffer_length.get()))
 
710
  if (packet.alloc(buffer_length))
743
711
    return false; /* The error is set by alloc(). */
744
712
 
745
713
  client_capabilities= uint2korr(net.read_pos);
746
714
  if (!(client_capabilities & CLIENT_PROTOCOL_MYSQL41))
747
715
  {
748
 
    my_error(ER_HANDSHAKE_ERROR, MYF(0), user_identifier->address().c_str());
 
716
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
749
717
    return false;
750
718
  }
751
719
 
761
729
 
762
730
  if (end >= (char*) net.read_pos + pkt_len + 2)
763
731
  {
764
 
    my_error(ER_HANDSHAKE_ERROR, MYF(0), user_identifier->address().c_str());
 
732
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
765
733
    return false;
766
734
  }
767
735
 
785
753
    passwd_len= (unsigned char)(*passwd++);
786
754
    if (passwd_len > 0)
787
755
    {
788
 
      user_identifier->setPasswordType(identifier::User::MYSQL_HASH);
789
 
      user_identifier->setPasswordContext(scramble, SCRAMBLE_LENGTH);
 
756
      session->getSecurityContext().setPasswordType(SecurityContext::MYSQL_HASH);
 
757
      session->getSecurityContext().setPasswordContext(scramble, SCRAMBLE_LENGTH);
790
758
    }
791
759
  }
792
760
  else
793
 
  {
794
761
    passwd_len= 0;
795
 
  }
796
762
 
797
763
  if (client_capabilities & CLIENT_CONNECT_WITH_DB &&
798
764
      passwd < (char *) net.read_pos + pkt_len)
800
766
    l_db= l_db + passwd_len + 1;
801
767
  }
802
768
  else
803
 
  {
804
769
    l_db= NULL;
805
 
  }
806
770
 
807
771
  /* strlen() can't be easily deleted without changing client */
808
772
  uint32_t db_len= l_db ? strlen(l_db) : 0;
809
773
 
810
774
  if (passwd + passwd_len + db_len > (char *) net.read_pos + pkt_len)
811
775
  {
812
 
    my_error(ER_HANDSHAKE_ERROR, MYF(0), user_identifier->address().c_str());
 
776
    my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
813
777
    return false;
814
778
  }
815
779
 
821
785
    user_len-= 2;
822
786
  }
823
787
 
824
 
  if (client_capabilities & CLIENT_ADMIN)
825
 
  {
826
 
    if ((strncmp(user, "root", 4) == 0) and isAdminAllowed())
827
 
    {
828
 
      is_admin_connection= true;
829
 
    }
830
 
    else
831
 
    {
832
 
      my_error(ER_ADMIN_ACCESS, MYF(0));
833
 
      return false;
834
 
    }
835
 
  }
836
 
 
837
 
  user_identifier->setUser(user);
838
 
  session->setUser(user_identifier);
 
788
  session->getSecurityContext().setUser(user);
839
789
 
840
790
  return session->checkUser(string(passwd, passwd_len),
841
791
                            string(l_db ? l_db : ""));
842
792
 
843
793
}
844
794
 
845
 
bool ClientMySQLProtocol::isAdminAllowed(void)
846
 
{
847
 
  if (std::find(mysql_admin_ip_addresses.begin(), mysql_admin_ip_addresses.end(), session->user()->address()) != mysql_admin_ip_addresses.end())
848
 
    return true;
849
 
 
850
 
  return false;
851
 
}
852
 
 
853
795
bool ClientMySQLProtocol::netStoreData(const unsigned char *from, size_t length)
854
796
{
855
797
  size_t packet_length= packet.length();
952
894
  }
953
895
}
954
896
 
955
 
void ClientMySQLProtocol::mysql_compose_ip_addresses(vector<string> options)
956
 
{
957
 
  for (vector<string>::iterator it= options.begin();
958
 
       it != options.end();
959
 
       ++it)
960
 
  {
961
 
    tokenize(*it, mysql_admin_ip_addresses, ",", true);
962
 
  }
963
 
}
964
 
 
965
897
static ListenMySQLProtocol *listen_obj= NULL;
966
898
plugin::Create_function<MySQLPassword> *mysql_password= NULL;
967
899
 
968
900
static int init(drizzled::module::Context &context)
969
901
{  
970
 
  context.add(new MysqlProtocolStatus);
 
902
  mysql_status_table_function_ptr= new MysqlProtocolStatus;
971
903
 
 
904
  context.add(mysql_status_table_function_ptr);
972
905
  /* Initialize random seeds for the MySQL algorithm with minimal changes. */
973
906
  time_t seed_time= time(NULL);
974
907
  random_seed1= seed_time % random_max;
975
908
  random_seed2= (seed_time / 2) % random_max;
976
909
 
977
910
  const module::option_map &vm= context.getOptions();
 
911
  if (vm.count("port"))
 
912
  { 
 
913
    if (port > 65535)
 
914
    {
 
915
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of port\n"));
 
916
      exit(-1);
 
917
    }
 
918
  }
 
919
 
 
920
  if (vm.count("connect-timeout"))
 
921
  {
 
922
    if (connect_timeout < 1 || connect_timeout > 300)
 
923
    {
 
924
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for connect_timeout\n"));
 
925
      exit(-1);
 
926
    }
 
927
  }
 
928
 
 
929
  if (vm.count("read-timeout"))
 
930
  {
 
931
    if (read_timeout < 1 || read_timeout > 300)
 
932
    {
 
933
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read_timeout\n"));
 
934
      exit(-1);
 
935
    }
 
936
  }
 
937
 
 
938
  if (vm.count("write-timeout"))
 
939
  {
 
940
    if (write_timeout < 1 || write_timeout > 300)
 
941
    {
 
942
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write_timeout\n"));
 
943
      exit(-1);
 
944
    }
 
945
  }
 
946
 
 
947
  if (vm.count("retry-count"))
 
948
  {
 
949
    if (retry_count < 1 || retry_count > 100)
 
950
    {
 
951
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for retry_count"));
 
952
      exit(-1);
 
953
    }
 
954
  }
 
955
 
 
956
  if (vm.count("buffer-length"))
 
957
  {
 
958
    if (buffer_length < 1024 || buffer_length > 1024*1024)
 
959
    {
 
960
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer_length\n"));
 
961
      exit(-1);
 
962
    }
 
963
  }
 
964
 
 
965
  if (vm.count("bind-address"))
 
966
  {
 
967
    bind_address= strdup(vm["bind-address"].as<string>().c_str());
 
968
  }
 
969
 
 
970
  else
 
971
  {
 
972
    bind_address= NULL;
 
973
  }
978
974
 
979
975
  mysql_password= new plugin::Create_function<MySQLPassword>(MySQLPasswordName);
980
976
  context.add(mysql_password);
981
977
 
982
 
  listen_obj= new ListenMySQLProtocol("mysql_protocol", vm["bind-address"].as<std::string>(), true);
 
978
  listen_obj= new ListenMySQLProtocol("mysql_protocol", true);
983
979
  context.add(listen_obj); 
984
 
  context.registerVariable(new sys_var_constrained_value_readonly<in_port_t>("port", port));
985
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("connect_timeout", connect_timeout));
986
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("read_timeout", read_timeout));
987
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("write_timeout", write_timeout));
988
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("retry_count", retry_count));
989
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("buffer_length", buffer_length));
990
 
  context.registerVariable(new sys_var_const_string_val("bind_address",
991
 
                                                        vm["bind-address"].as<std::string>()));
992
 
 
993
 
  context.registerVariable(new sys_var_uint32_t_ptr("max-connections", &ListenMySQLProtocol::mysql_counters->max_connections));
994
980
 
995
981
  return 0;
996
982
}
997
983
 
 
984
static DRIZZLE_SYSVAR_UINT(port, port, PLUGIN_VAR_RQCMDARG,
 
985
                           N_("Port number to use for connection or 0 for default to with MySQL "
 
986
                              "protocol."),
 
987
                           NULL, NULL, 3306, 0, 65535, 0);
 
988
static DRIZZLE_SYSVAR_UINT(connect_timeout, connect_timeout,
 
989
                           PLUGIN_VAR_RQCMDARG, N_("Connect Timeout."),
 
990
                           NULL, NULL, 10, 1, 300, 0);
 
991
static DRIZZLE_SYSVAR_UINT(read_timeout, read_timeout, PLUGIN_VAR_RQCMDARG,
 
992
                           N_("Read Timeout."), NULL, NULL, 30, 1, 300, 0);
 
993
static DRIZZLE_SYSVAR_UINT(write_timeout, write_timeout, PLUGIN_VAR_RQCMDARG,
 
994
                           N_("Write Timeout."), NULL, NULL, 60, 1, 300, 0);
 
995
static DRIZZLE_SYSVAR_UINT(retry_count, retry_count, PLUGIN_VAR_RQCMDARG,
 
996
                           N_("Retry Count."), NULL, NULL, 10, 1, 100, 0);
 
997
static DRIZZLE_SYSVAR_UINT(buffer_length, buffer_length, PLUGIN_VAR_RQCMDARG,
 
998
                           N_("Buffer length."), NULL, NULL, 16384, 1024,
 
999
                           1024*1024, 0);
 
1000
static DRIZZLE_SYSVAR_STR(bind_address, bind_address, PLUGIN_VAR_READONLY,
 
1001
                          N_("Address to bind to."), NULL, NULL, NULL);
 
1002
 
998
1003
static void init_options(drizzled::module::option_context &context)
999
1004
{
1000
1005
  context("port",
1001
 
          po::value<port_constraint>(&port)->default_value(3306),
 
1006
          po::value<uint32_t>(&port)->default_value(3306),
1002
1007
          N_("Port number to use for connection or 0 for default to with MySQL "
1003
1008
                              "protocol."));
1004
1009
  context("connect-timeout",
1005
 
          po::value<timeout_constraint>(&connect_timeout)->default_value(10),
 
1010
          po::value<uint32_t>(&connect_timeout)->default_value(10),
1006
1011
          N_("Connect Timeout."));
1007
1012
  context("read-timeout",
1008
 
          po::value<timeout_constraint>(&read_timeout)->default_value(30),
 
1013
          po::value<uint32_t>(&read_timeout)->default_value(30),
1009
1014
          N_("Read Timeout."));
1010
1015
  context("write-timeout",
1011
 
          po::value<timeout_constraint>(&write_timeout)->default_value(60),
 
1016
          po::value<uint32_t>(&write_timeout)->default_value(60),
1012
1017
          N_("Write Timeout."));
1013
1018
  context("retry-count",
1014
 
          po::value<retry_constraint>(&retry_count)->default_value(10),
 
1019
          po::value<uint32_t>(&retry_count)->default_value(10),
1015
1020
          N_("Retry Count."));
1016
1021
  context("buffer-length",
1017
 
          po::value<buffer_constraint>(&buffer_length)->default_value(16384),
 
1022
          po::value<uint32_t>(&buffer_length)->default_value(16384),
1018
1023
          N_("Buffer length."));
1019
1024
  context("bind-address",
1020
 
          po::value<string>()->default_value(""),
 
1025
          po::value<string>(),
1021
1026
          N_("Address to bind to."));
1022
 
  context("max-connections",
1023
 
          po::value<uint32_t>(&ListenMySQLProtocol::mysql_counters->max_connections)->default_value(1000),
1024
 
          N_("Maximum simultaneous connections."));
1025
 
  context("admin-ip-addresses",
1026
 
          po::value<vector<string> >()->composing()->notifier(&ClientMySQLProtocol::mysql_compose_ip_addresses),
1027
 
          N_("A restrictive IP address list for incoming admin connections."));
1028
1027
}
1029
1028
 
 
1029
static drizzle_sys_var* sys_variables[]= {
 
1030
  DRIZZLE_SYSVAR(port),
 
1031
  DRIZZLE_SYSVAR(connect_timeout),
 
1032
  DRIZZLE_SYSVAR(read_timeout),
 
1033
  DRIZZLE_SYSVAR(write_timeout),
 
1034
  DRIZZLE_SYSVAR(retry_count),
 
1035
  DRIZZLE_SYSVAR(buffer_length),
 
1036
  DRIZZLE_SYSVAR(bind_address),
 
1037
  NULL
 
1038
};
 
1039
 
1030
1040
static int mysql_protocol_connection_count_func(drizzle_show_var *var, char *buff)
1031
1041
{
1032
1042
  var->type= SHOW_LONGLONG;
1033
1043
  var->value= buff;
1034
 
  *((uint64_t *)buff)= ListenMySQLProtocol::mysql_counters->connectionCount;
 
1044
  *((uint64_t *)buff)= ClientMySQLProtocol::connectionCount;
1035
1045
  return 0;
1036
1046
}
1037
1047
 
1039
1049
{
1040
1050
  var->type= SHOW_LONGLONG;
1041
1051
  var->value= buff;
1042
 
  *((uint64_t *)buff)= ListenMySQLProtocol::mysql_counters->connected;
 
1052
  *((uint64_t *)buff)= ClientMySQLProtocol::connected;
1043
1053
  return 0;
1044
1054
}
1045
1055
 
1047
1057
{
1048
1058
  var->type= SHOW_LONGLONG;
1049
1059
  var->value= buff;
1050
 
  *((uint64_t *)buff)= ListenMySQLProtocol::mysql_counters->failedConnections;
 
1060
  *((uint64_t *)buff)= ClientMySQLProtocol::failedConnections;
1051
1061
  return 0;
1052
1062
}
1053
1063
 
1124
1134
  return false;
1125
1135
}
1126
1136
 
1127
 
} /* namespace drizzle_plugin */
1128
 
 
1129
1137
DRIZZLE_DECLARE_PLUGIN
1130
1138
{
1131
1139
  DRIZZLE_VERSION_ID,
1134
1142
  "Eric Day",
1135
1143
  "MySQL Protocol Module",
1136
1144
  PLUGIN_LICENSE_GPL,
1137
 
  drizzle_plugin::init,             /* Plugin Init */
1138
 
  NULL, /* system variables */
1139
 
  drizzle_plugin::init_options    /* config options */
 
1145
  init,             /* Plugin Init */
 
1146
  sys_variables, /* system variables */
 
1147
  init_options    /* config options */
1140
1148
}
1141
1149
DRIZZLE_DECLARE_PLUGIN_END;