1 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_COMMANDS_H
2 #define INCLUDES_MYSQL_INSTANCE_MANAGER_COMMANDS_H
3 /* Copyright (c) 2004-2006 MySQL AB
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
18 #include <my_global.h>
27 #if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
33 Print all instances of this instance manager.
34 Grammar: SHOW INSTANCES
37 class Show_instances
: public Command
44 int execute(st_net
*net
, ulong connection_id
);
47 int write_header(st_net
*net
);
48 int write_data(st_net
*net
);
53 Reread configuration file and refresh internal cache.
54 Grammar: FLUSH INSTANCES
57 class Flush_instances
: public Command
64 int execute(st_net
*net
, ulong connection_id
);
69 Base class for Instance-specific commands
70 (commands that operate on one instance).
72 Instance_cmd extends Command class by:
73 - an attribute for storing instance name;
74 - code to initialize instance name in constructor;
75 - an accessor to get instance name.
78 class Instance_cmd
: public Command
81 Instance_cmd(const LEX_STRING
*instance_name_arg
);
84 inline const LEX_STRING
*get_instance_name() const
86 return instance_name
.get_str();
90 Instance_name instance_name
;
95 Abstract class for Instance-specific commands.
97 Abstract_instance_cmd extends Instance_cmd by providing a common
98 framework for writing command-implementations. Basically, the class
99 implements Command::execute() pure virtual function in the following
102 - Get an instance by name. Return an error, if there is no such
105 - Unlock Instance_map;
106 - Call execute_impl(), which should be implemented in derived class;
107 - Unlock the instance;
108 - Send response to the client and return error status.
111 class Abstract_instance_cmd
: public Instance_cmd
114 Abstract_instance_cmd(const LEX_STRING
*instance_name_arg
);
117 virtual int execute(st_net
*net
, ulong connection_id
);
121 This operation is intended to contain command-specific implementation.
123 MT-NOTE: this operation is called under acquired Instance's lock.
125 virtual int execute_impl(st_net
*net
, Instance
*instance
) = 0;
128 This operation is invoked on successful return of execute_impl() and is
129 intended to send closing data.
131 MT-NOTE: this operation is called under released Instance's lock.
133 virtual int send_ok_response(st_net
*net
, ulong connection_id
) = 0;
138 Print status of an instance.
139 Grammar: SHOW INSTANCE STATUS <instance_name>
142 class Show_instance_status
: public Abstract_instance_cmd
145 Show_instance_status(const LEX_STRING
*instance_name_arg
);
148 virtual int execute_impl(st_net
*net
, Instance
*instance
);
149 virtual int send_ok_response(st_net
*net
, ulong connection_id
);
152 int write_header(st_net
*net
);
153 int write_data(st_net
*net
, Instance
*instance
);
158 Print options of chosen instance.
159 Grammar: SHOW INSTANCE OPTIONS <instance_name>
162 class Show_instance_options
: public Abstract_instance_cmd
165 Show_instance_options(const LEX_STRING
*instance_name_arg
);
168 virtual int execute_impl(st_net
*net
, Instance
*instance
);
169 virtual int send_ok_response(st_net
*net
, ulong connection_id
);
172 int write_header(st_net
*net
);
173 int write_data(st_net
*net
, Instance
*instance
);
179 Grammar: START INSTANCE <instance_name>
182 class Start_instance
: public Abstract_instance_cmd
185 Start_instance(const LEX_STRING
*instance_name_arg
);
188 virtual int execute_impl(st_net
*net
, Instance
*instance
);
189 virtual int send_ok_response(st_net
*net
, ulong connection_id
);
195 Grammar: STOP INSTANCE <instance_name>
198 class Stop_instance
: public Abstract_instance_cmd
201 Stop_instance(const LEX_STRING
*instance_name_arg
);
204 virtual int execute_impl(st_net
*net
, Instance
*instance
);
205 virtual int send_ok_response(st_net
*net
, ulong connection_id
);
211 Grammar: CREATE INSTANCE <instance_name> [<options>]
214 class Create_instance
: public Instance_cmd
217 Create_instance(const LEX_STRING
*instance_name_arg
);
220 bool init(const char **text
);
223 virtual int execute(st_net
*net
, ulong connection_id
);
226 bool parse_args(const char **text
);
229 Named_value_arr options
;
235 Grammar: DROP INSTANCE <instance_name>
237 Operation is permitted only if the instance is stopped. On successful
238 completion the instance section is removed from config file and the instance
239 is removed from the instance map.
242 class Drop_instance
: public Instance_cmd
245 Drop_instance(const LEX_STRING
*instance_name_arg
);
248 virtual int execute(st_net
*net
, ulong connection_id
);
253 Print requested part of the log.
255 SHOW <instance_name> LOG {ERROR | SLOW | GENERAL} size[, offset_from_end]
258 class Show_instance_log
: public Abstract_instance_cmd
261 Show_instance_log(const LEX_STRING
*instance_name_arg
,
262 Log_type log_type_arg
, uint size_arg
, uint offset_arg
);
265 virtual int execute_impl(st_net
*net
, Instance
*instance
);
266 virtual int send_ok_response(st_net
*net
, ulong connection_id
);
269 int check_params(Instance
*instance
);
270 int write_header(st_net
*net
);
271 int write_data(st_net
*net
, Instance
*instance
);
281 Shows the list of the log files, used by an instance.
282 Grammar: SHOW <instance_name> LOG FILES
285 class Show_instance_log_files
: public Abstract_instance_cmd
288 Show_instance_log_files(const LEX_STRING
*instance_name_arg
);
291 virtual int execute_impl(st_net
*net
, Instance
*instance
);
292 virtual int send_ok_response(st_net
*net
, ulong connection_id
);
295 int write_header(st_net
*net
);
296 int write_data(st_net
*net
, Instance
*instance
);
301 Abstract class for option-management commands.
304 class Instance_options_list
;
306 class Abstract_option_cmd
: public Command
309 ~Abstract_option_cmd();
312 bool add_option(const LEX_STRING
*instance_name
, Named_value
*option
);
315 bool init(const char **text
);
317 virtual int execute(st_net
*net
, ulong connection_id
);
320 Abstract_option_cmd();
322 int correct_file(Instance
*instance
, Named_value
*option
, bool skip
);
325 virtual bool parse_args(const char **text
) = 0;
326 virtual int process_option(Instance
*instance
, Named_value
*option
) = 0;
329 Instance_options_list
*
330 get_instance_options_list(const LEX_STRING
*instance_name
);
332 int execute_impl(st_net
*net
, ulong connection_id
);
335 HASH instance_options_map
;
341 Set an option for the instance.
342 Grammar: SET instance_name.option[=option_value][, ...]
345 class Set_option
: public Abstract_option_cmd
352 virtual bool parse_args(const char **text
);
353 virtual int process_option(Instance
*instance
, Named_value
*option
);
358 Remove option of the instance.
359 Grammar: UNSET instance_name.option[, ...]
362 class Unset_option
: public Abstract_option_cmd
369 virtual bool parse_args(const char **text
);
370 virtual int process_option(Instance
*instance
, Named_value
*option
);
375 Syntax error command.
377 This command is issued if parser reported a syntax error. We need it to
378 distinguish between syntax error and internal parser error. E.g. parsing
379 failed because we hadn't had enought memory. In the latter case the parser
383 class Syntax_error
: public Command
390 int execute(st_net
*net
, ulong connection_id
);
393 #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_COMMANDS_H */