Merge lp:~linuxjedi/drizzle/drizzle-bug-621603 into lp:~drizzle-trunk/drizzle/development

Proposed by Andrew Hutchings
Status: Merged
Merged at revision: 1751
Proposed branch: lp:~linuxjedi/drizzle/drizzle-bug-621603
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 851 lines (+391/-15)
18 files modified
drizzled/session.cc (+2/-0)
drizzled/statistics_variables.h (+1/-0)
drizzled/status_helper.cc (+1/-1)
plugin/drizzle_protocol/drizzle_protocol.cc (+113/-0)
plugin/drizzle_protocol/drizzle_protocol.h (+6/-0)
plugin/drizzle_protocol/plugin.ini (+1/-1)
plugin/drizzle_protocol/table_function.h (+57/-0)
plugin/information_schema_dictionary/tests/r/tables.result (+8/-0)
plugin/mysql_protocol/mysql_protocol.cc (+111/-1)
plugin/mysql_protocol/mysql_protocol.h (+7/-0)
plugin/mysql_protocol/plugin.ini (+1/-1)
plugin/mysql_protocol/table_function.h (+52/-0)
plugin/schema_dictionary/tests/r/data_dictionary.result (+17/-1)
plugin/session_dictionary/processlist.cc (+2/-2)
plugin/session_dictionary/tests/r/data_dictionary.result (+2/-2)
tests/r/create.result (+4/-4)
tests/r/data_dictionary_like_info.result (+1/-1)
tests/r/information_schema.result (+5/-1)
To merge this branch: bzr merge lp:~linuxjedi/drizzle/drizzle-bug-621603
Reviewer Review Type Date Requested Status
Andrew Hutchings Needs Fixing
Drizzle Merge Team Pending
Review via email: mp+33308@code.launchpad.net

Description of the change

Fixes for:

Bug#621603: Connections status variable very wrong
Bug#621947: show processlist filldown

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

How can we make "connections" be protocol specific?

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Interesting question. Well, I guess the obvious thing to do would be to have each protocol plugin have a sysvar. Unfortunately to me it looks like plugin specific sysvars are broken. So...

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

(sorry, I meant status variables)

Revision history for this message
Monty Taylor (mordred) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/23/2010 12:12 AM, Andrew Hutchings wrote:
> Interesting question. Well, I guess the obvious thing to do would be
> to have each protocol plugin have a sysvar. Unfortunately to me it
> looks like plugin specific sysvars are broken. So...

Aroo???
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxyIRcACgkQ2Jv7/VK1RgGC5QCg3w+39GE/EsuzddOxf9jPBq/2
yx8AnAh3suPZN8aFGDcBFgmFj9Rjt12f
=FnG8
-----END PGP SIGNATURE-----

Revision history for this message
Monty Taylor (mordred) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/23/2010 12:12 AM, Andrew Hutchings wrote:
> (sorry, I meant status variables)

Aroo???
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxyISYACgkQ2Jv7/VK1RgGuNQCgrEMeaFcb1OWed/U9zCn1FTOQ
xL4An3kZPwtsIShwy6f91pjlc2mQj07m
=kj+G
-----END PGP SIGNATURE-----

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Monty: see bug#622576

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

ok, so I like Brian's plan. I will put this merge request on hold and put the new bug as a blocker to the connections counter.

review: Needs Fixing
Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

OK, so, in this branch to be reviewed:

1. Bug#621947: show processlist filldown
  * The processlist table now accepts null values so when null is provided it doesn't use the previous value.

2. Bug#628284: --mysql option broken
  * drizzle client can now use the drizzle protocol (when using --mysql=0)

3. Bug#621603: Connections status variable off by one
  * the global status counter is now fixed
  * the mysql protocol now has data_dictionary.mysql_protocol for its own counters
  * the drizzle protocol now has data_dictionary.drizzle_protocol for its own counters

1733. By Andrew Hutchings

Merge trunk into branch

1734. By Andrew Hutchings

Fix tests

Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

Latest branch is failing to build on many platforms:

../plugin/drizzle_protocol/table_function.h:21: #ifndef header guard has wrong style, please use: PLUGIN_DRIZZLE_PROTOCOL_TABLE_FUNCTION_H [build/header_guard] [5]
../plugin/drizzle_protocol/table_function.h:57: #endif line should be "#endif /* PLUGIN_DRIZZLE_PROTOCOL_TABLE_FUNCTION_H */" [build/header_guard] [5]
python ../extra/cpplint.py --filter=-whitespace,-runtime,-readability,+legal,-build,+build/header_guard,+build/include_config,+build/namespaces --deps plugin/drizzle_protocol/vio.h.linted ../plugin/drizzle_protocol/vio.h
Done processing ../plugin/drizzle_protocol/pack.h

1735. By LinuxJedi <linuxjedi@linuxjedi-laptop>

Fix table function header (I hate that my compiler didn't cry about this)

1736. By LinuxJedi <linuxjedi@linuxjedi-laptop>

Fix another wrong header, grr...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/session.cc'
2--- drizzled/session.cc 2010-08-24 16:45:09 +0000
3+++ drizzled/session.cc 2010-09-09 06:18:43 +0000
4@@ -538,6 +538,7 @@
5 current_global_counters.max_used_connections= connection_count;
6 }
7
8+ current_global_counters.connections++;
9 thread_id= variables.pseudo_thread_id= global_thread_id++;
10
11 LOCK_thread_count.lock();
12@@ -1730,6 +1731,7 @@
13
14 flush_status_time= time((time_t*) 0);
15 current_global_counters.max_used_connections= 1; /* We set it to one, because we know we exist */
16+ current_global_counters.connections= 0;
17 }
18
19 user_var_entry *Session::getVariable(LEX_STRING &name, bool create_if_not_exists)
20
21=== modified file 'drizzled/statistics_variables.h'
22--- drizzled/statistics_variables.h 2010-08-09 18:29:06 +0000
23+++ drizzled/statistics_variables.h 2010-09-09 06:18:43 +0000
24@@ -33,6 +33,7 @@
25 typedef struct global_counters
26 {
27 uint64_t max_used_connections;
28+ uint64_t connections;
29 uint64_t locks_immediate;
30 uint64_t locks_waited;
31 } global_counters;
32
33=== modified file 'drizzled/status_helper.cc'
34--- drizzled/status_helper.cc 2010-08-09 18:29:06 +0000
35+++ drizzled/status_helper.cc 2010-09-09 06:18:43 +0000
36@@ -134,7 +134,7 @@
37 {"Aborted_connects", (char*) offsetof(system_status_var, aborted_connects), SHOW_LONGLONG_STATUS},
38 {"Bytes_received", (char*) offsetof(system_status_var, bytes_received), SHOW_LONGLONG_STATUS},
39 {"Bytes_sent", (char*) offsetof(system_status_var, bytes_sent), SHOW_LONGLONG_STATUS},
40- {"Connections", (char*) &global_thread_id, SHOW_INT_NOFLUSH},
41+ {"Connections", (char*) &current_global_counters.connections, SHOW_LONGLONG},
42 {"Created_tmp_disk_tables", (char*) offsetof(system_status_var, created_tmp_disk_tables), SHOW_LONGLONG_STATUS},
43 {"Created_tmp_tables", (char*) offsetof(system_status_var, created_tmp_tables), SHOW_LONGLONG_STATUS},
44 {"Flush_commands", (char*) &refresh_version, SHOW_INT_NOFLUSH},
45
46=== modified file 'plugin/drizzle_protocol/drizzle_protocol.cc'
47--- plugin/drizzle_protocol/drizzle_protocol.cc 2010-08-21 07:08:08 +0000
48+++ plugin/drizzle_protocol/drizzle_protocol.cc 2010-09-09 06:18:43 +0000
49@@ -33,6 +33,7 @@
50 #include "errmsg.h"
51 #include "drizzle_protocol.h"
52 #include "options.h"
53+#include "table_function.h"
54
55 #define PROTOCOL_VERSION 10
56
57@@ -54,6 +55,8 @@
58 static uint32_t buffer_length;
59 static char* bind_address= NULL;
60
61+static plugin::TableFunction* drizzle_status_table_function_ptr= NULL;
62+
63 ListenDrizzleProtocol::~ListenDrizzleProtocol()
64 {
65 /* This is strdup'd from the options */
66@@ -92,6 +95,10 @@
67 return new (nothrow) ClientDrizzleProtocol(new_fd, using_mysql41_protocol);
68 }
69
70+drizzled::atomic<uint64_t> ClientDrizzleProtocol::connectionCount;
71+drizzled::atomic<uint64_t> ClientDrizzleProtocol::failedConnections;
72+drizzled::atomic<uint64_t> ClientDrizzleProtocol::connected;
73+
74 ClientDrizzleProtocol::ClientDrizzleProtocol(int fd, bool using_mysql41_protocol_arg):
75 using_mysql41_protocol(using_mysql41_protocol_arg)
76 {
77@@ -150,6 +157,7 @@
78 {
79 drizzleclient_net_close(&net);
80 drizzleclient_net_end(&net);
81+ connected.decrement();
82 }
83 }
84
85@@ -157,6 +165,9 @@
86 {
87 bool connection_is_valid;
88
89+ connectionCount.increment();
90+ connected.increment();
91+
92 /* Use "connect_timeout" value during connection phase */
93 drizzleclient_net_set_read_timeout(&net, connect_timeout);
94 drizzleclient_net_set_write_timeout(&net, connect_timeout);
95@@ -168,6 +179,7 @@
96 else
97 {
98 sendError(session->main_da.sql_errno(), session->main_da.message());
99+ failedConnections.increment();
100 return false;
101 }
102
103@@ -818,6 +830,10 @@
104
105 static int init(module::Context &context)
106 {
107+ drizzle_status_table_function_ptr= new DrizzleProtocolStatus;
108+
109+ context.add(drizzle_status_table_function_ptr);
110+
111 const module::option_map &vm= context.getOptions();
112 if (vm.count("port"))
113 {
114@@ -947,6 +963,103 @@
115 NULL
116 };
117
118+static int drizzle_protocol_connection_count_func(drizzle_show_var *var, char *buff)
119+{
120+ var->type= SHOW_LONGLONG;
121+ var->value= buff;
122+ *((uint64_t *)buff)= ClientDrizzleProtocol::connectionCount;
123+ return 0;
124+}
125+
126+static int drizzle_protocol_connected_count_func(drizzle_show_var *var, char *buff)
127+{
128+ var->type= SHOW_LONGLONG;
129+ var->value= buff;
130+ *((uint64_t *)buff)= ClientDrizzleProtocol::connected;
131+ return 0;
132+}
133+
134+static int drizzle_protocol_failed_count_func(drizzle_show_var *var, char *buff)
135+{
136+ var->type= SHOW_LONGLONG;
137+ var->value= buff;
138+ *((uint64_t *)buff)= ClientDrizzleProtocol::failedConnections;
139+ return 0;
140+}
141+
142+static st_show_var_func_container drizzle_protocol_connection_count=
143+ { &drizzle_protocol_connection_count_func };
144+
145+static st_show_var_func_container drizzle_protocol_connected_count=
146+ { &drizzle_protocol_connected_count_func };
147+
148+static st_show_var_func_container drizzle_protocol_failed_count=
149+ { &drizzle_protocol_failed_count_func };
150+
151+static drizzle_show_var drizzle_protocol_status_variables[]= {
152+ {"Connections",
153+ (char*) &drizzle_protocol_connection_count, SHOW_FUNC},
154+ {"Connected",
155+ (char*) &drizzle_protocol_connected_count, SHOW_FUNC},
156+ {"Failed_connections",
157+ (char*) &drizzle_protocol_failed_count, SHOW_FUNC},
158+ {NULL, NULL, SHOW_LONGLONG}
159+};
160+
161+DrizzleProtocolStatus::Generator::Generator(drizzled::Field **fields) :
162+ plugin::TableFunction::Generator(fields)
163+{
164+ status_var_ptr= drizzle_protocol_status_variables;
165+}
166+
167+bool DrizzleProtocolStatus::Generator::populate()
168+{
169+ MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
170+ char * const buff= (char *) &buff_data;
171+ drizzle_show_var tmp;
172+
173+ if (status_var_ptr->name)
174+ {
175+ std::ostringstream oss;
176+ string return_value;
177+ const char *value;
178+ int type;
179+
180+ push(status_var_ptr->name);
181+
182+ if (status_var_ptr->type == SHOW_FUNC)
183+ {
184+ ((mysql_show_var_func)((st_show_var_func_container *)status_var_ptr->value)->func)(&tmp, buff);
185+ value= buff;
186+ type= tmp.type;
187+ }
188+ else
189+ {
190+ value= status_var_ptr->value;
191+ type= status_var_ptr->type;
192+ }
193+
194+ switch(type)
195+ {
196+ case SHOW_LONGLONG:
197+ oss << *(uint64_t*) value;
198+ return_value= oss.str();
199+ break;
200+ default:
201+ assert(0);
202+ }
203+ if (return_value.length())
204+ push(return_value);
205+ else
206+ push(" ");
207+
208+ status_var_ptr++;
209+
210+ return true;
211+ }
212+ return false;
213+}
214+
215 } /* namespace drizzle_protocol */
216
217 DRIZZLE_PLUGIN(drizzle_protocol::init, drizzle_protocol::sys_variables, drizzle_protocol::init_options);
218
219=== modified file 'plugin/drizzle_protocol/drizzle_protocol.h'
220--- plugin/drizzle_protocol/drizzle_protocol.h 2010-08-12 06:10:25 +0000
221+++ plugin/drizzle_protocol/drizzle_protocol.h 2010-09-09 06:18:43 +0000
222@@ -22,6 +22,8 @@
223
224 #include <drizzled/plugin/listen_tcp.h>
225 #include <drizzled/plugin/client.h>
226+#include <drizzled/atomics.h>
227+#include "drizzled/plugin/table_function.h"
228
229 #include "net_serv.h"
230
231@@ -60,6 +62,10 @@
232 ClientDrizzleProtocol(int fd, bool using_mysql41_protocol_arg);
233 virtual ~ClientDrizzleProtocol();
234
235+ static drizzled::atomic<uint64_t> connectionCount;
236+ static drizzled::atomic<uint64_t> failedConnections;
237+ static drizzled::atomic<uint64_t> connected;
238+
239 virtual int getFileDescriptor(void);
240 virtual bool isConnected();
241 virtual bool isReading(void);
242
243=== modified file 'plugin/drizzle_protocol/plugin.ini'
244--- plugin/drizzle_protocol/plugin.ini 2010-04-27 21:03:13 +0000
245+++ plugin/drizzle_protocol/plugin.ini 2010-09-09 06:18:43 +0000
246@@ -7,6 +7,6 @@
247 libs=drizzled/algorithm/libhash.la
248 load_by_default=yes
249 ldlfags=$(LIBZ)
250-headers=drizzle_protocol.h errmsg.h net_serv.h options.h pack.h vio.h
251+headers=drizzle_protocol.h errmsg.h net_serv.h options.h pack.h vio.h table_function.h
252 sources=drizzle_protocol.cc errmsg.cc net_serv.cc pack.cc vio.cc viosocket.cc
253 static=yes
254
255=== added file 'plugin/drizzle_protocol/table_function.h'
256--- plugin/drizzle_protocol/table_function.h 1970-01-01 00:00:00 +0000
257+++ plugin/drizzle_protocol/table_function.h 2010-09-09 06:18:43 +0000
258@@ -0,0 +1,57 @@
259+/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
260+ * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
261+ *
262+ * Copyright (C) 2010 Andrew Hutchings
263+ *
264+ * This program is free software; you can redistribute it and/or modify
265+ * it under the terms of the GNU General Public License as published by
266+ * the Free Software Foundation; either version 2 of the License, or
267+ * (at your option) any later version.
268+ *
269+ * This program is distributed in the hope that it will be useful,
270+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
271+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
272+ * GNU General Public License for more details.
273+ *
274+ * You should have received a copy of the GNU General Public License
275+ * along with this program; if not, write to the Free Software
276+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
277+ */
278+
279+#ifndef PLUGIN_DRIZZLE_PROTOCOL_TABLE_FUNCTION_H
280+#define PLUGIN_DRIZZLE_PROTOCOL_TABLE_FUNCTION_H
281+
282+#include "drizzled/plugin/table_function.h"
283+namespace drizzle_protocol
284+{
285+
286+
287+class DrizzleProtocolStatus : public drizzled::plugin::TableFunction
288+{
289+public:
290+ DrizzleProtocolStatus() :
291+ drizzled::plugin::TableFunction("DATA_DICTIONARY","DRIZZLE_PROTOCOL_STATUS")
292+ {
293+ add_field("VARIABLE_NAME");
294+ add_field("VARIABLE_VALUE");
295+ }
296+
297+ class Generator : public drizzled::plugin::TableFunction::Generator
298+ {
299+ drizzled::drizzle_show_var *status_var_ptr;
300+
301+ public:
302+ Generator(drizzled::Field **fields);
303+
304+ bool populate();
305+ };
306+
307+ Generator *generator(drizzled::Field **arg)
308+ {
309+ return new Generator(arg);
310+ }
311+};
312+
313+}
314+
315+#endif /* PLUGIN_DRIZZLE_PROTOCOL_TABLE_FUNCTION_H */
316
317=== modified file 'plugin/information_schema_dictionary/tests/r/tables.result'
318--- plugin/information_schema_dictionary/tests/r/tables.result 2010-08-19 00:32:20 +0000
319+++ plugin/information_schema_dictionary/tests/r/tables.result 2010-09-09 06:18:43 +0000
320@@ -12,6 +12,7 @@
321 DATA_DICTIONARY CUMULATIVE_SQL_COMMANDS VIEW
322 DATA_DICTIONARY CUMULATIVE_USER_STATS VIEW
323 DATA_DICTIONARY CURRENT_SQL_COMMANDS VIEW
324+ DATA_DICTIONARY DRIZZLE_PROTOCOL_STATUS VIEW
325 DATA_DICTIONARY GLOBAL_STATEMENTS VIEW
326 DATA_DICTIONARY GLOBAL_STATUS VIEW
327 DATA_DICTIONARY GLOBAL_VARIABLES VIEW
328@@ -27,6 +28,7 @@
329 DATA_DICTIONARY INNODB_STATUS VIEW
330 DATA_DICTIONARY INNODB_TRX VIEW
331 DATA_DICTIONARY MODULES VIEW
332+ DATA_DICTIONARY MYSQL_PROTOCOL_STATUS VIEW
333 DATA_DICTIONARY PLUGINS VIEW
334 DATA_DICTIONARY PROCESSLIST VIEW
335 DATA_DICTIONARY REFERENTIAL_CONSTRAINTS VIEW
336@@ -81,6 +83,7 @@
337 DATA_DICTIONARY CUMULATIVE_SQL_COMMANDS VIEW
338 DATA_DICTIONARY CUMULATIVE_USER_STATS VIEW
339 DATA_DICTIONARY CURRENT_SQL_COMMANDS VIEW
340+ DATA_DICTIONARY DRIZZLE_PROTOCOL_STATUS VIEW
341 DATA_DICTIONARY GLOBAL_STATEMENTS VIEW
342 DATA_DICTIONARY GLOBAL_STATUS VIEW
343 DATA_DICTIONARY GLOBAL_VARIABLES VIEW
344@@ -96,6 +99,7 @@
345 DATA_DICTIONARY INNODB_STATUS VIEW
346 DATA_DICTIONARY INNODB_TRX VIEW
347 DATA_DICTIONARY MODULES VIEW
348+ DATA_DICTIONARY MYSQL_PROTOCOL_STATUS VIEW
349 DATA_DICTIONARY PLUGINS VIEW
350 DATA_DICTIONARY PROCESSLIST VIEW
351 DATA_DICTIONARY REFERENTIAL_CONSTRAINTS VIEW
352@@ -173,6 +177,7 @@
353 DATA_DICTIONARY CUMULATIVE_SQL_COMMANDS VIEW
354 DATA_DICTIONARY CUMULATIVE_USER_STATS VIEW
355 DATA_DICTIONARY CURRENT_SQL_COMMANDS VIEW
356+ DATA_DICTIONARY DRIZZLE_PROTOCOL_STATUS VIEW
357 DATA_DICTIONARY GLOBAL_STATEMENTS VIEW
358 DATA_DICTIONARY GLOBAL_STATUS VIEW
359 DATA_DICTIONARY GLOBAL_VARIABLES VIEW
360@@ -188,6 +193,7 @@
361 DATA_DICTIONARY INNODB_STATUS VIEW
362 DATA_DICTIONARY INNODB_TRX VIEW
363 DATA_DICTIONARY MODULES VIEW
364+ DATA_DICTIONARY MYSQL_PROTOCOL_STATUS VIEW
365 DATA_DICTIONARY PLUGINS VIEW
366 DATA_DICTIONARY PROCESSLIST VIEW
367 DATA_DICTIONARY REFERENTIAL_CONSTRAINTS VIEW
368@@ -265,6 +271,7 @@
369 DATA_DICTIONARY CUMULATIVE_SQL_COMMANDS VIEW
370 DATA_DICTIONARY CUMULATIVE_USER_STATS VIEW
371 DATA_DICTIONARY CURRENT_SQL_COMMANDS VIEW
372+ DATA_DICTIONARY DRIZZLE_PROTOCOL_STATUS VIEW
373 DATA_DICTIONARY GLOBAL_STATEMENTS VIEW
374 DATA_DICTIONARY GLOBAL_STATUS VIEW
375 DATA_DICTIONARY GLOBAL_VARIABLES VIEW
376@@ -275,6 +282,7 @@
377 DATA_DICTIONARY INNODB_LOCK_WAITS VIEW
378 DATA_DICTIONARY INNODB_STATUS VIEW
379 DATA_DICTIONARY MODULES VIEW
380+ DATA_DICTIONARY MYSQL_PROTOCOL_STATUS VIEW
381 DATA_DICTIONARY PLUGINS VIEW
382 DATA_DICTIONARY REFERENTIAL_CONSTRAINTS VIEW
383 DATA_DICTIONARY REPLICATION_STREAMS VIEW
384
385=== modified file 'plugin/mysql_protocol/mysql_protocol.cc'
386--- plugin/mysql_protocol/mysql_protocol.cc 2010-08-21 07:08:08 +0000
387+++ plugin/mysql_protocol/mysql_protocol.cc 2010-09-09 06:18:43 +0000
388@@ -31,6 +31,7 @@
389 #include "mysql_protocol.h"
390 #include "mysql_password.h"
391 #include "options.h"
392+#include "table_function.h"
393
394 namespace po= boost::program_options;
395 using namespace std;
396@@ -51,6 +52,8 @@
397 static const uint32_t random_max= 0x3FFFFFFF;
398 static const double random_max_double= (double)0x3FFFFFFF;
399
400+static plugin::TableFunction* mysql_status_table_function_ptr= NULL;
401+
402 ListenMySQLProtocol::~ListenMySQLProtocol()
403 {
404 /* This is strdup'd from the options */
405@@ -77,6 +80,10 @@
406 return new (nothrow) ClientMySQLProtocol(new_fd, using_mysql41_protocol);
407 }
408
409+drizzled::atomic<uint64_t> ClientMySQLProtocol::connectionCount;
410+drizzled::atomic<uint64_t> ClientMySQLProtocol::failedConnections;
411+drizzled::atomic<uint64_t> ClientMySQLProtocol::connected;
412+
413 ClientMySQLProtocol::ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg):
414 using_mysql41_protocol(using_mysql41_protocol_arg)
415 {
416@@ -135,6 +142,7 @@
417 {
418 drizzleclient_net_close(&net);
419 drizzleclient_net_end(&net);
420+ connected.decrement();
421 }
422 }
423
424@@ -142,6 +150,9 @@
425 {
426 bool connection_is_valid;
427
428+ connectionCount.increment();
429+ connected.increment();
430+
431 /* Use "connect_timeout" value during connection phase */
432 drizzleclient_net_set_read_timeout(&net, connect_timeout);
433 drizzleclient_net_set_write_timeout(&net, connect_timeout);
434@@ -153,9 +164,9 @@
435 else
436 {
437 sendError(session->main_da.sql_errno(), session->main_da.message());
438+ failedConnections.increment();
439 return false;
440 }
441-
442 /* Connect completed, set read/write timeouts back to default */
443 drizzleclient_net_set_read_timeout(&net, read_timeout);
444 drizzleclient_net_set_write_timeout(&net, write_timeout);
445@@ -886,7 +897,9 @@
446
447 static int init(drizzled::module::Context &context)
448 {
449+ mysql_status_table_function_ptr= new MysqlProtocolStatus;
450
451+ context.add(mysql_status_table_function_ptr);
452 /* Initialize random seeds for the MySQL algorithm with minimal changes. */
453 time_t seed_time= time(NULL);
454 random_seed1= seed_time % random_max;
455@@ -1022,6 +1035,103 @@
456 NULL
457 };
458
459+static int mysql_protocol_connection_count_func(drizzle_show_var *var, char *buff)
460+{
461+ var->type= SHOW_LONGLONG;
462+ var->value= buff;
463+ *((uint64_t *)buff)= ClientMySQLProtocol::connectionCount;
464+ return 0;
465+}
466+
467+static int mysql_protocol_connected_count_func(drizzle_show_var *var, char *buff)
468+{
469+ var->type= SHOW_LONGLONG;
470+ var->value= buff;
471+ *((uint64_t *)buff)= ClientMySQLProtocol::connected;
472+ return 0;
473+}
474+
475+static int mysql_protocol_failed_count_func(drizzle_show_var *var, char *buff)
476+{
477+ var->type= SHOW_LONGLONG;
478+ var->value= buff;
479+ *((uint64_t *)buff)= ClientMySQLProtocol::failedConnections;
480+ return 0;
481+}
482+
483+static st_show_var_func_container mysql_protocol_connection_count=
484+ { &mysql_protocol_connection_count_func };
485+
486+static st_show_var_func_container mysql_protocol_connected_count=
487+ { &mysql_protocol_connected_count_func };
488+
489+static st_show_var_func_container mysql_protocol_failed_count=
490+ { &mysql_protocol_failed_count_func };
491+
492+static drizzle_show_var mysql_protocol_status_variables[]= {
493+ {"Connections",
494+ (char*) &mysql_protocol_connection_count, SHOW_FUNC},
495+ {"Connected",
496+ (char*) &mysql_protocol_connected_count, SHOW_FUNC},
497+ {"Failed_connections",
498+ (char*) &mysql_protocol_failed_count, SHOW_FUNC},
499+ {NULL, NULL, SHOW_LONGLONG}
500+};
501+
502+MysqlProtocolStatus::Generator::Generator(drizzled::Field **fields) :
503+ plugin::TableFunction::Generator(fields)
504+{
505+ status_var_ptr= mysql_protocol_status_variables;
506+}
507+
508+bool MysqlProtocolStatus::Generator::populate()
509+{
510+ MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
511+ char * const buff= (char *) &buff_data;
512+ drizzle_show_var tmp;
513+
514+ if (status_var_ptr->name)
515+ {
516+ std::ostringstream oss;
517+ string return_value;
518+ const char *value;
519+ int type;
520+
521+ push(status_var_ptr->name);
522+
523+ if (status_var_ptr->type == SHOW_FUNC)
524+ {
525+ ((mysql_show_var_func)((st_show_var_func_container *)status_var_ptr->value)->func)(&tmp, buff);
526+ value= buff;
527+ type= tmp.type;
528+ }
529+ else
530+ {
531+ value= status_var_ptr->value;
532+ type= status_var_ptr->type;
533+ }
534+
535+ switch(type)
536+ {
537+ case SHOW_LONGLONG:
538+ oss << *(uint64_t*) value;
539+ return_value= oss.str();
540+ break;
541+ default:
542+ assert(0);
543+ }
544+ if (return_value.length())
545+ push(return_value);
546+ else
547+ push(" ");
548+
549+ status_var_ptr++;
550+
551+ return true;
552+ }
553+ return false;
554+}
555+
556 DRIZZLE_DECLARE_PLUGIN
557 {
558 DRIZZLE_VERSION_ID,
559
560=== modified file 'plugin/mysql_protocol/mysql_protocol.h'
561--- plugin/mysql_protocol/mysql_protocol.h 2010-08-12 06:10:25 +0000
562+++ plugin/mysql_protocol/mysql_protocol.h 2010-09-09 06:18:43 +0000
563@@ -22,6 +22,8 @@
564
565 #include <drizzled/plugin/listen_tcp.h>
566 #include <drizzled/plugin/client.h>
567+#include <drizzled/atomics.h>
568+#include "drizzled/plugin/table_function.h"
569
570 #include "net_serv.h"
571
572@@ -29,6 +31,7 @@
573 {
574 private:
575 bool using_mysql41_protocol;
576+ static drizzled::plugin::TableFunction* status_table_function_ptr;
577
578 public:
579 ListenMySQLProtocol(std::string name_arg, bool using_mysql41_protocol_arg):
580@@ -59,6 +62,10 @@
581 ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg);
582 virtual ~ClientMySQLProtocol();
583
584+ static drizzled::atomic<uint64_t> connectionCount;
585+ static drizzled::atomic<uint64_t> failedConnections;
586+ static drizzled::atomic<uint64_t> connected;
587+
588 virtual int getFileDescriptor(void);
589 virtual bool isConnected();
590 virtual bool isReading(void);
591
592=== modified file 'plugin/mysql_protocol/plugin.ini'
593--- plugin/mysql_protocol/plugin.ini 2010-04-27 21:03:13 +0000
594+++ plugin/mysql_protocol/plugin.ini 2010-09-09 06:18:43 +0000
595@@ -4,6 +4,6 @@
596 load_by_default=yes
597 ldlfags=$(LIBZ)
598 libs=drizzled/algorithm/libhash.la
599-headers=mysql_protocol.h errmsg.h net_serv.h options.h vio.h mysql_password.h
600+headers=mysql_protocol.h errmsg.h net_serv.h options.h vio.h mysql_password.h table_function.h
601 sources=mysql_protocol.cc net_serv.cc vio.cc mysql_password.cc
602 static=yes
603
604=== added file 'plugin/mysql_protocol/table_function.h'
605--- plugin/mysql_protocol/table_function.h 1970-01-01 00:00:00 +0000
606+++ plugin/mysql_protocol/table_function.h 2010-09-09 06:18:43 +0000
607@@ -0,0 +1,52 @@
608+/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
609+ * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
610+ *
611+ * Copyright (C) 2010 Andrew Hutchings
612+ *
613+ * This program is free software; you can redistribute it and/or modify
614+ * it under the terms of the GNU General Public License as published by
615+ * the Free Software Foundation; either version 2 of the License, or
616+ * (at your option) any later version.
617+ *
618+ * This program is distributed in the hope that it will be useful,
619+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
620+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
621+ * GNU General Public License for more details.
622+ *
623+ * You should have received a copy of the GNU General Public License
624+ * along with this program; if not, write to the Free Software
625+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
626+ */
627+
628+#ifndef PLUGIN_MYSQL_PROTOCOL_TABLE_FUNCTION_H
629+#define PLUGIN_MYSQL_PROTOCOL_TABLE_FUNCTION_H
630+
631+#include "drizzled/plugin/table_function.h"
632+
633+class MysqlProtocolStatus : public drizzled::plugin::TableFunction
634+{
635+public:
636+ MysqlProtocolStatus() :
637+ drizzled::plugin::TableFunction("DATA_DICTIONARY","MYSQL_PROTOCOL_STATUS")
638+ {
639+ add_field("VARIABLE_NAME");
640+ add_field("VARIABLE_VALUE");
641+ }
642+
643+ class Generator : public drizzled::plugin::TableFunction::Generator
644+ {
645+ drizzled::drizzle_show_var *status_var_ptr;
646+
647+ public:
648+ Generator(drizzled::Field **fields);
649+
650+ bool populate();
651+ };
652+
653+ Generator *generator(drizzled::Field **arg)
654+ {
655+ return new Generator(arg);
656+ }
657+};
658+
659+#endif /* PLUGIN_MYSQL_PROTOCOL_TABLE_FUNCTION_H */
660
661=== modified file 'plugin/schema_dictionary/tests/r/data_dictionary.result'
662--- plugin/schema_dictionary/tests/r/data_dictionary.result 2010-09-02 18:35:05 +0000
663+++ plugin/schema_dictionary/tests/r/data_dictionary.result 2010-09-09 06:18:43 +0000
664@@ -1,7 +1,7 @@
665 use data_dictionary;
666 SELECT count(*) FROM columns;
667 count(*)
668-490
669+494
670 SELECT count(*) FROM indexes;
671 count(*)
672 0
673@@ -489,6 +489,10 @@
674 VARIABLE_NAME
675 VARIABLE_NAME
676 VARIABLE_NAME
677+VARIABLE_NAME
678+VARIABLE_NAME
679+VARIABLE_VALUE
680+VARIABLE_VALUE
681 VARIABLE_VALUE
682 VARIABLE_VALUE
683 VARIABLE_VALUE
684@@ -687,6 +691,8 @@
685 DATA_DICTIONARY CURRENT_SQL_COMMANDS COUNT_UPDATE
686 DATA_DICTIONARY CURRENT_SQL_COMMANDS IP
687 DATA_DICTIONARY CURRENT_SQL_COMMANDS USER
688+DATA_DICTIONARY DRIZZLE_PROTOCOL_STATUS VARIABLE_NAME
689+DATA_DICTIONARY DRIZZLE_PROTOCOL_STATUS VARIABLE_VALUE
690 DATA_DICTIONARY GLOBAL_STATEMENTS VARIABLE_NAME
691 DATA_DICTIONARY GLOBAL_STATEMENTS VARIABLE_VALUE
692 DATA_DICTIONARY GLOBAL_STATUS VARIABLE_NAME
693@@ -767,6 +773,8 @@
694 DATA_DICTIONARY MODULES MODULE_LICENSE
695 DATA_DICTIONARY MODULES MODULE_NAME
696 DATA_DICTIONARY MODULES MODULE_VERSION
697+DATA_DICTIONARY MYSQL_PROTOCOL_STATUS VARIABLE_NAME
698+DATA_DICTIONARY MYSQL_PROTOCOL_STATUS VARIABLE_VALUE
699 DATA_DICTIONARY PLUGINS IS_ACTIVE
700 DATA_DICTIONARY PLUGINS MODULE_NAME
701 DATA_DICTIONARY PLUGINS PLUGIN_NAME
702@@ -1259,6 +1267,8 @@
703 DOMAIN_CONSTRAINTS INFORMATION_SCHEMA DOMAIN_SCHEMA
704 DOMAIN_CONSTRAINTS INFORMATION_SCHEMA INITIALLY_DEFERRED
705 DOMAIN_CONSTRAINTS INFORMATION_SCHEMA IS_DEFERRABLE
706+DRIZZLE_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_NAME
707+DRIZZLE_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_VALUE
708 GLOBAL_STATEMENTS DATA_DICTIONARY VARIABLE_NAME
709 GLOBAL_STATEMENTS DATA_DICTIONARY VARIABLE_VALUE
710 GLOBAL_STATUS DATA_DICTIONARY VARIABLE_NAME
711@@ -1347,6 +1357,8 @@
712 MODULES DATA_DICTIONARY MODULE_LICENSE
713 MODULES DATA_DICTIONARY MODULE_NAME
714 MODULES DATA_DICTIONARY MODULE_VERSION
715+MYSQL_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_NAME
716+MYSQL_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_VALUE
717 PARAMETERS INFORMATION_SCHEMA AS_LOCATOR
718 PARAMETERS INFORMATION_SCHEMA CHARACTER_MAXIMUM_LENGTH
719 PARAMETERS INFORMATION_SCHEMA CHARACTER_OCTET_LENGTH
720@@ -1752,6 +1764,8 @@
721 DOMAIN_CONSTRAINTS INFORMATION_SCHEMA DOMAIN_SCHEMA
722 DOMAIN_CONSTRAINTS INFORMATION_SCHEMA INITIALLY_DEFERRED
723 DOMAIN_CONSTRAINTS INFORMATION_SCHEMA IS_DEFERRABLE
724+DRIZZLE_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_NAME
725+DRIZZLE_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_VALUE
726 GLOBAL_STATEMENTS DATA_DICTIONARY VARIABLE_NAME
727 GLOBAL_STATEMENTS DATA_DICTIONARY VARIABLE_VALUE
728 GLOBAL_STATUS DATA_DICTIONARY VARIABLE_NAME
729@@ -1840,6 +1854,8 @@
730 MODULES DATA_DICTIONARY MODULE_LICENSE
731 MODULES DATA_DICTIONARY MODULE_NAME
732 MODULES DATA_DICTIONARY MODULE_VERSION
733+MYSQL_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_NAME
734+MYSQL_PROTOCOL_STATUS DATA_DICTIONARY VARIABLE_VALUE
735 PARAMETERS INFORMATION_SCHEMA AS_LOCATOR
736 PARAMETERS INFORMATION_SCHEMA CHARACTER_MAXIMUM_LENGTH
737 PARAMETERS INFORMATION_SCHEMA CHARACTER_OCTET_LENGTH
738
739=== modified file 'plugin/session_dictionary/processlist.cc'
740--- plugin/session_dictionary/processlist.cc 2010-08-13 23:46:13 +0000
741+++ plugin/session_dictionary/processlist.cc 2010-09-09 06:18:43 +0000
742@@ -44,8 +44,8 @@
743 add_field("DB");
744 add_field("COMMAND", 16);
745 add_field("TIME", plugin::TableFunction::NUMBER, 0, false);
746- add_field("STATE");
747- add_field("INFO", PROCESS_LIST_WIDTH);
748+ add_field("STATE", plugin::TableFunction::STRING, 256, true);
749+ add_field("INFO", plugin::TableFunction::STRING, PROCESS_LIST_WIDTH, true);
750 }
751
752 ProcesslistTool::Generator::Generator(Field **arg) :
753
754=== modified file 'plugin/session_dictionary/tests/r/data_dictionary.result'
755--- plugin/session_dictionary/tests/r/data_dictionary.result 2010-09-02 18:35:05 +0000
756+++ plugin/session_dictionary/tests/r/data_dictionary.result 2010-09-09 06:18:43 +0000
757@@ -8,8 +8,8 @@
758 `DB` VARCHAR(256) NOT NULL,
759 `COMMAND` VARCHAR(16) NOT NULL,
760 `TIME` BIGINT NOT NULL,
761- `STATE` VARCHAR(256) NOT NULL,
762- `INFO` VARCHAR(100) NOT NULL
763+ `STATE` VARCHAR(256) DEFAULT NULL,
764+ `INFO` VARCHAR(100) DEFAULT NULL
765 ) ENGINE=FunctionEngine COLLATE = utf8_general_ci
766 SELECT ID FROM processlist;
767 ID
768
769=== modified file 'tests/r/create.result'
770--- tests/r/create.result 2010-09-02 18:35:05 +0000
771+++ tests/r/create.result 2010-09-09 06:18:43 +0000
772@@ -1455,8 +1455,8 @@
773 `DB` VARCHAR(256) NOT NULL,
774 `COMMAND` VARCHAR(16) NOT NULL,
775 `TIME` BIGINT NOT NULL,
776- `STATE` VARCHAR(256) NOT NULL,
777- `INFO` VARCHAR(100) NOT NULL
778+ `STATE` VARCHAR(256) DEFAULT NULL,
779+ `INFO` VARCHAR(100) DEFAULT NULL
780 ) ENGINE=InnoDB COLLATE = utf8_general_ci
781 drop table t1;
782 create temporary table t1 like data_dictionary.processlist;
783@@ -1471,8 +1471,8 @@
784 `DB` VARCHAR(256) NOT NULL,
785 `COMMAND` VARCHAR(16) NOT NULL,
786 `TIME` BIGINT NOT NULL,
787- `STATE` VARCHAR(256) NOT NULL,
788- `INFO` VARCHAR(100) NOT NULL
789+ `STATE` VARCHAR(256) DEFAULT NULL,
790+ `INFO` VARCHAR(100) DEFAULT NULL
791 ) ENGINE=MyISAM COLLATE = utf8_general_ci
792 drop table t1;
793
794
795=== modified file 'tests/r/data_dictionary_like_info.result'
796--- tests/r/data_dictionary_like_info.result 2010-07-29 00:34:46 +0000
797+++ tests/r/data_dictionary_like_info.result 2010-09-09 06:18:43 +0000
798@@ -191,7 +191,7 @@
799 or DATA_TYPE = 'varchar')
800 group by DATA_TYPE order by DATA_TYPE, num;
801 DATA_TYPE a num
802-VARCHAR # 161
803+VARCHAR # 165
804 Warnings:
805 Warning # 1 line(s) were cut by GROUP_CONCAT()
806 create table t1(f1 char(1) not null, f2 char(9) not null);
807
808=== modified file 'tests/r/information_schema.result'
809--- tests/r/information_schema.result 2010-08-27 00:24:53 +0000
810+++ tests/r/information_schema.result 2010-09-09 06:18:43 +0000
811@@ -91,7 +91,7 @@
812 table_name NOT LIKE 'falcon%'
813 GROUP BY TABLE_SCHEMA ORDER BY table_schema;
814 table_schema count(*)
815-DATA_DICTIONARY 40
816+DATA_DICTIONARY 42
817 INFORMATION_SCHEMA 20
818 create table t1(f1 LONGBLOB, f2 LONGTEXT);
819 select column_name,data_type,CHARACTER_OCTET_LENGTH,
820@@ -193,6 +193,7 @@
821 CUMULATIVE_SQL_COMMANDS COUNT_SELECT
822 CUMULATIVE_USER_STATS BYTES_RECEIVED
823 CURRENT_SQL_COMMANDS IP
824+DRIZZLE_PROTOCOL_STATUS VARIABLE_VALUE
825 GLOBAL_STATEMENTS VARIABLE_VALUE
826 GLOBAL_STATUS VARIABLE_VALUE
827 GLOBAL_VARIABLES VARIABLE_VALUE
828@@ -207,6 +208,7 @@
829 INNODB_STATUS VARIABLE_VALUE
830 INNODB_TRX TRX_STATE
831 MODULES MODULE_VERSION
832+MYSQL_PROTOCOL_STATUS VARIABLE_VALUE
833 PLUGINS PLUGIN_TYPE
834 PROCESSLIST USER
835 REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
836@@ -248,6 +250,7 @@
837 CUMULATIVE_SQL_COMMANDS COUNT_SELECT
838 CUMULATIVE_USER_STATS BYTES_RECEIVED
839 CURRENT_SQL_COMMANDS IP
840+DRIZZLE_PROTOCOL_STATUS VARIABLE_VALUE
841 GLOBAL_STATEMENTS VARIABLE_VALUE
842 GLOBAL_STATUS VARIABLE_VALUE
843 GLOBAL_VARIABLES VARIABLE_VALUE
844@@ -262,6 +265,7 @@
845 INNODB_STATUS VARIABLE_VALUE
846 INNODB_TRX TRX_STATE
847 MODULES MODULE_VERSION
848+MYSQL_PROTOCOL_STATUS VARIABLE_VALUE
849 PLUGINS PLUGIN_TYPE
850 PROCESSLIST USER
851 REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA