mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / server-tools / instance-manager / mysql_connection.h
bloba76a7c8abdb05a8048c99e63beb3feada14c5b56
1 /* Copyright (C) 2004-2006 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_CONNECTION_H
17 #define INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_CONNECTION_H
19 #include "thread_registry.h"
20 #include <mysql_com.h>
22 #if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
23 #pragma interface
24 #endif
26 struct st_vio;
27 class User_map;
30 MySQL connection - handle one connection with mysql command line client
31 See also comments in mysqlmanager.cc to picture general Instance Manager
32 architecture.
33 We use conventional technique to work with classes without exceptions:
34 class acquires all vital resource in init(); Thus if init() succeed,
35 a user must call cleanup(). All other methods are valid only between
36 init() and cleanup().
39 class Mysql_connection: public Thread
41 public:
42 Mysql_connection(Thread_registry *thread_registry_arg,
43 User_map *user_map_arg,
44 struct st_vio *vio_arg,
45 ulong connection_id_arg);
46 virtual ~Mysql_connection();
48 protected:
49 virtual void run();
51 private:
52 struct st_vio *vio;
53 ulong connection_id;
54 Thread_info thread_info;
55 Thread_registry *thread_registry;
56 User_map *user_map;
57 NET net;
58 struct rand_struct rand_st;
59 char scramble[SCRAMBLE_LENGTH + 1];
60 uint status;
61 ulong client_capabilities;
62 private:
63 /* The main loop implementation triad */
64 bool init();
65 void main();
66 void cleanup();
68 /* Names are conventionally the same as in mysqld */
69 int check_connection();
70 int do_command();
71 int dispatch_command(enum enum_server_command command, const char *text);
74 #endif // INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_CONNECTION_H