~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to server-tools/instance-manager/instance_options.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H
 
2
#define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H
 
3
/* Copyright (C) 2004 MySQL AB
 
4
 
 
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.
 
8
 
 
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.
 
13
 
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
17
 
 
18
#include <my_global.h>
 
19
#include <my_sys.h>
 
20
 
 
21
#include "parse.h"
 
22
#include "portability.h" /* for pid_t on Win32 */
 
23
 
 
24
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
 
25
#pragma interface
 
26
#endif
 
27
 
 
28
 
 
29
/*
 
30
  This class contains options of an instance and methods to operate them.
 
31
 
 
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.
 
36
*/
 
37
 
 
38
class Instance_options
 
39
{
 
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);
 
43
 
 
44
public:
 
45
  Instance_options();
 
46
  ~Instance_options();
 
47
 
 
48
  bool complete_initialization();
 
49
 
 
50
  bool set_option(Named_value *option);
 
51
  void unset_option(const char *option_name);
 
52
 
 
53
  inline int get_num_options() const;
 
54
  inline Named_value get_option(int idx) const;
 
55
 
 
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();
 
62
 
 
63
  uint get_shutdown_delay() const;
 
64
  int get_mysqld_port() const;
 
65
 
 
66
public:
 
67
  /*
 
68
    We need this value to be greater or equal then FN_REFLEN found in
 
69
    my_global.h to use my_load_path()
 
70
  */
 
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;
 
75
  /*
 
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.
 
78
  */
 
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];
 
90
 
 
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);
 
98
 
 
99
  void update_var(const char *option_name, const char *option_value);
 
100
  int find_option(const char *option_name);
 
101
 
 
102
private:
 
103
  const char *mysqld_port;
 
104
  uint mysqld_port_val;
 
105
  const char *shutdown_delay;
 
106
  uint shutdown_delay_val;
 
107
 
 
108
  uint filled_default_options;
 
109
  MEM_ROOT alloc;
 
110
 
 
111
  Named_value_arr options;
 
112
};
 
113
 
 
114
 
 
115
inline int Instance_options::get_num_options() const
 
116
{
 
117
  return options.get_size();
 
118
}
 
119
 
 
120
 
 
121
inline Named_value Instance_options::get_option(int idx) const
 
122
{
 
123
  return options.get_element(idx);
 
124
}
 
125
 
 
126
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_OPTIONS_H */