mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / server-tools / instance-manager / instance_options.h
blob53b2351012531376b1eb71586bf43dabf7d05441
1 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H
2 #define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_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>
19 #include <my_sys.h>
21 #include "parse.h"
22 #include "portability.h" /* for pid_t on Win32 */
24 #if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
25 #pragma interface
26 #endif
30 This class contains options of an instance and methods to operate them.
32 We do not provide this class with the means of synchronization as it is
33 supposed that options for instances are all loaded at once during the
34 instance_map initilization and we do not change them later. This way we
35 don't have to synchronize between threads.
38 class Instance_options
40 public:
41 /* The operation is used to check if the option is IM-specific or not. */
42 static bool is_option_im_specific(const char *option_name);
44 public:
45 Instance_options();
46 ~Instance_options();
48 bool complete_initialization();
50 bool set_option(Named_value *option);
51 void unset_option(const char *option_name);
53 inline int get_num_options() const;
54 inline Named_value get_option(int idx) const;
56 public:
57 bool init(const LEX_STRING *instance_name_arg);
58 pid_t load_pid();
59 int get_pid_filename(char *result);
60 int unlink_pidfile();
61 void print_argv();
63 uint get_shutdown_delay() const;
64 int get_mysqld_port() const;
66 public:
68 We need this value to be greater or equal then FN_REFLEN found in
69 my_global.h to use my_load_path()
71 enum { MAX_PATH_LEN= 512 };
72 enum { MAX_NUMBER_OF_DEFAULT_OPTIONS= 2 };
73 char pid_file_with_path[MAX_PATH_LEN];
74 char **argv;
76 Here we cache the version string, obtained from mysqld --version.
77 In the case when mysqld binary is not found we get NULL here.
79 const char *mysqld_version;
80 /* We need the some options, so we store them as a separate pointers */
81 const char *mysqld_socket;
82 const char *mysqld_datadir;
83 const char *mysqld_pid_file;
84 LEX_STRING instance_name;
85 LEX_STRING mysqld_path;
86 LEX_STRING mysqld_real_path;
87 const char *nonguarded;
88 /* log enums are defined in parse.h */
89 char *logs[3];
91 private:
92 bool fill_log_options();
93 bool fill_instance_version();
94 bool fill_mysqld_real_path();
95 int add_to_argv(const char *option);
96 int get_default_option(char *result, size_t result_len,
97 const char *option_name);
99 void update_var(const char *option_name, const char *option_value);
100 int find_option(const char *option_name);
102 private:
103 const char *mysqld_port;
104 uint mysqld_port_val;
105 const char *shutdown_delay;
106 uint shutdown_delay_val;
108 uint filled_default_options;
109 MEM_ROOT alloc;
111 Named_value_arr options;
115 inline int Instance_options::get_num_options() const
117 return options.get_size();
121 inline Named_value Instance_options::get_option(int idx) const
123 return options.get_element(idx);
126 #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H */