Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c7581758
Commit
c7581758
authored
Jun 01, 2005
by
petr@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix IM to display version string in "show instance status" (Bug #10229)
parent
329d974d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
35 deletions
+129
-35
server-tools/instance-manager/buffer.h
server-tools/instance-manager/buffer.h
+1
-1
server-tools/instance-manager/commands.cc
server-tools/instance-manager/commands.cc
+4
-5
server-tools/instance-manager/instance_options.cc
server-tools/instance-manager/instance_options.cc
+95
-20
server-tools/instance-manager/instance_options.h
server-tools/instance-manager/instance_options.h
+8
-1
server-tools/instance-manager/options.cc
server-tools/instance-manager/options.cc
+1
-1
server-tools/instance-manager/parse_output.cc
server-tools/instance-manager/parse_output.cc
+18
-6
server-tools/instance-manager/parse_output.h
server-tools/instance-manager/parse_output.h
+2
-1
No files found.
server-tools/instance-manager/buffer.h
View file @
c7581758
...
@@ -52,7 +52,7 @@ class Buffer
...
@@ -52,7 +52,7 @@ class Buffer
~
Buffer
()
~
Buffer
()
{
{
free
(
buffer
);
my_free
(
buffer
,
MYF
(
0
)
);
}
}
public:
public:
...
...
server-tools/instance-manager/commands.cc
View file @
c7581758
...
@@ -203,15 +203,14 @@ int Show_instance_status::execute(struct st_net *net,
...
@@ -203,15 +203,14 @@ int Show_instance_status::execute(struct st_net *net,
if
(
!
(
instance
=
instance_map
->
find
(
instance_name
,
strlen
(
instance_name
))))
if
(
!
(
instance
=
instance_map
->
find
(
instance_name
,
strlen
(
instance_name
))))
goto
err
;
goto
err
;
if
(
instance
->
is_running
())
if
(
instance
->
is_running
())
{
store_to_string
(
&
send_buff
,
(
char
*
)
"online"
,
&
position
);
store_to_string
(
&
send_buff
,
(
char
*
)
"online"
,
&
position
);
store_to_string
(
&
send_buff
,
"unknown"
,
&
position
);
}
else
else
{
store_to_string
(
&
send_buff
,
(
char
*
)
"offline"
,
&
position
);
store_to_string
(
&
send_buff
,
(
char
*
)
"offline"
,
&
position
);
if
(
instance
->
options
.
mysqld_version
)
store_to_string
(
&
send_buff
,
instance
->
options
.
mysqld_version
,
&
position
);
else
store_to_string
(
&
send_buff
,
(
char
*
)
"unknown"
,
&
position
);
store_to_string
(
&
send_buff
,
(
char
*
)
"unknown"
,
&
position
);
}
if
(
send_buff
.
is_error
()
||
if
(
send_buff
.
is_error
()
||
...
...
server-tools/instance-manager/instance_options.cc
View file @
c7581758
...
@@ -27,6 +27,39 @@
...
@@ -27,6 +27,39 @@
#include <signal.h>
#include <signal.h>
#include <m_string.h>
#include <m_string.h>
#ifdef __WIN__
#define NEWLINE_LEN 2
#else
#define NEWLINE_LEN 1
#endif
/* Create "mysqld ..." command in the buffer */
static
inline
int
create_mysqld_command
(
Buffer
*
buf
,
const
char
*
mysqld_path_str
,
uint
mysqld_path_len
,
const
char
*
option
,
uint
option_len
)
{
int
position
=
0
;
if
(
buf
->
get_size
())
/* malloc succeeded */
{
buf
->
append
(
position
,
mysqld_path_str
,
mysqld_path_len
);
position
+=
mysqld_path_len
;
/* here the '\0' character is copied from the option string */
buf
->
append
(
position
,
option
,
option_len
);
if
(
buf
->
is_error
())
return
1
;
}
else
return
1
;
return
0
;
}
/*
/*
Get compiled-in value of default_option
Get compiled-in value of default_option
...
@@ -50,44 +83,83 @@
...
@@ -50,44 +83,83 @@
int
Instance_options
::
get_default_option
(
char
*
result
,
size_t
result_len
,
int
Instance_options
::
get_default_option
(
char
*
result
,
size_t
result_len
,
const
char
*
option_name
)
const
char
*
option_name
)
{
{
int
position
=
0
;
int
rc
=
1
;
int
rc
=
1
;
char
verbose_option
[]
=
" --no-defaults --verbose --help"
;
char
verbose_option
[]
=
" --no-defaults --verbose --help"
;
Buffer
cmd
(
strlen
(
mysqld_path
)
+
sizeof
(
verbose_option
)
+
1
);
/* reserve space fot the path + option + final '\0' */
if
(
cmd
.
get_size
())
/* malloc succeeded */
Buffer
cmd
(
mysqld_path_len
+
sizeof
(
verbose_option
));
{
cmd
.
append
(
position
,
mysqld_path
,
strlen
(
mysqld_path
));
position
+=
strlen
(
mysqld_path
);
cmd
.
append
(
position
,
verbose_option
,
sizeof
(
verbose_option
)
-
1
);
position
+=
sizeof
(
verbose_option
)
-
1
;
cmd
.
append
(
position
,
"
\0
"
,
1
);
if
(
cmd
.
is_error
())
if
(
create_mysqld_command
(
&
cmd
,
mysqld_path
,
mysqld_path_len
,
goto
err
;
verbose_option
,
sizeof
(
verbose_option
)))
/* get the value from "mysqld --help --verbose" */
goto
err
;
rc
=
parse_output_and_get_value
(
cmd
.
buffer
,
option_name
+
2
,
/* +2 eats first "--" from the option string (E.g. "--datadir") */
rc
=
parse_output_and_get_value
(
cmd
.
buffer
,
option_name
+
2
,
result
,
result_len
);
result
,
result_len
);
return
rc
;
err:
return
1
;
}
/*
Fill mysqld_version option (used at initialization stage)
SYNOPSYS
fill_instance_version()
DESCRIPTION
Get mysqld version string from "mysqld --version" output.
RETURN
0 - ok
1 - error occured
*/
int
Instance_options
::
fill_instance_version
()
{
enum
{
MAX_VERSION_STRING_LENGTH
=
160
};
enum
{
RETURN_LINE
=
1
};
char
result
[
MAX_VERSION_STRING_LENGTH
];
char
version_option
[]
=
" --version"
;
int
rc
=
1
;
Buffer
cmd
(
mysqld_path_len
+
sizeof
(
version_option
));
if
(
create_mysqld_command
(
&
cmd
,
mysqld_path
,
mysqld_path_len
,
version_option
,
sizeof
(
version_option
)))
goto
err
;
rc
=
parse_output_and_get_value
(
cmd
.
buffer
,
mysqld_path
,
result
,
MAX_VERSION_STRING_LENGTH
,
RETURN_LINE
);
if
(
*
result
!=
'\0'
)
{
/* chop the newline from the end of the version string */
result
[
strlen
(
result
)
-
NEWLINE_LEN
]
=
'\0'
;
mysqld_version
=
strdup_root
(
&
alloc
,
result
);
}
}
return
rc
;
return
rc
;
err:
err:
return
1
;
return
1
;
}
}
/*
/*
Get compiled-in value of default_option
Fill various log options
SYNOPSYS
SYNOPSYS
get_default_option()
fill_log_options()
result buffer to put found value
result_len buffer size
option_name the name of the option, prefixed with "--"
DESCRIPTION
DESCRIPTION
Get compile-in value of requested option from server
Compute paths to enabled log files. If the path is not specified in the
instance explicitly (I.e. log=/home/user/mysql.log), we try to guess the
file name and placement.
RETURN
RETURN
0 - ok
0 - ok
...
@@ -276,6 +348,8 @@ int Instance_options::complete_initialization(const char *default_path,
...
@@ -276,6 +348,8 @@ int Instance_options::complete_initialization(const char *default_path,
goto
err
;
goto
err
;
}
}
mysqld_path_len
=
strlen
(
mysqld_path
);
if
(
mysqld_port
)
if
(
mysqld_port
)
mysqld_port_val
=
atoi
(
strchr
(
mysqld_port
,
'='
)
+
1
);
mysqld_port_val
=
atoi
(
strchr
(
mysqld_port
,
'='
)
+
1
);
...
@@ -330,7 +404,8 @@ int Instance_options::complete_initialization(const char *default_path,
...
@@ -330,7 +404,8 @@ int Instance_options::complete_initialization(const char *default_path,
options_array
.
elements
*
sizeof
(
char
*
));
options_array
.
elements
*
sizeof
(
char
*
));
argv
[
filled_default_options
+
options_array
.
elements
]
=
0
;
argv
[
filled_default_options
+
options_array
.
elements
]
=
0
;
fill_log_options
();
if
(
fill_log_options
()
||
fill_instance_version
())
goto
err
;
return
0
;
return
0
;
...
...
server-tools/instance-manager/instance_options.h
View file @
c7581758
...
@@ -38,7 +38,7 @@ class Instance_options
...
@@ -38,7 +38,7 @@ class Instance_options
{
{
public:
public:
Instance_options
()
:
Instance_options
()
:
mysqld_socket
(
0
),
mysqld_datadir
(
0
),
mysqld_
version
(
0
),
mysqld_
socket
(
0
),
mysqld_datadir
(
0
),
mysqld_bind_address
(
0
),
mysqld_pid_file
(
0
),
mysqld_port
(
0
),
mysqld_bind_address
(
0
),
mysqld_pid_file
(
0
),
mysqld_port
(
0
),
mysqld_port_val
(
0
),
mysqld_path
(
0
),
nonguarded
(
0
),
shutdown_delay
(
0
),
mysqld_port_val
(
0
),
mysqld_path
(
0
),
nonguarded
(
0
),
shutdown_delay
(
0
),
shutdown_delay_val
(
0
),
filled_default_options
(
0
)
shutdown_delay_val
(
0
),
filled_default_options
(
0
)
...
@@ -64,6 +64,11 @@ class Instance_options
...
@@ -64,6 +64,11 @@ class Instance_options
enum
{
MEM_ROOT_BLOCK_SIZE
=
512
};
enum
{
MEM_ROOT_BLOCK_SIZE
=
512
};
char
pid_file_with_path
[
MAX_PATH_LEN
];
char
pid_file_with_path
[
MAX_PATH_LEN
];
char
**
argv
;
char
**
argv
;
/*
Here we cache the version string, obtained from mysqld --version.
In the case when mysqld binary is not found we get "unknown" here.
*/
const
char
*
mysqld_version
;
/* We need the some options, so we store them as a separate pointers */
/* We need the some options, so we store them as a separate pointers */
const
char
*
mysqld_socket
;
const
char
*
mysqld_socket
;
const
char
*
mysqld_datadir
;
const
char
*
mysqld_datadir
;
...
@@ -74,6 +79,7 @@ class Instance_options
...
@@ -74,6 +79,7 @@ class Instance_options
const
char
*
instance_name
;
const
char
*
instance_name
;
uint
instance_name_len
;
uint
instance_name_len
;
const
char
*
mysqld_path
;
const
char
*
mysqld_path
;
uint
mysqld_path_len
;
const
char
*
nonguarded
;
const
char
*
nonguarded
;
const
char
*
shutdown_delay
;
const
char
*
shutdown_delay
;
uint
shutdown_delay_val
;
uint
shutdown_delay_val
;
...
@@ -84,6 +90,7 @@ class Instance_options
...
@@ -84,6 +90,7 @@ class Instance_options
DYNAMIC_ARRAY
options_array
;
DYNAMIC_ARRAY
options_array
;
private:
private:
int
fill_log_options
();
int
fill_log_options
();
int
fill_instance_version
();
int
add_to_argv
(
const
char
*
option
);
int
add_to_argv
(
const
char
*
option
);
int
get_default_option
(
char
*
result
,
size_t
result_len
,
int
get_default_option
(
char
*
result
,
size_t
result_len
,
const
char
*
option_name
);
const
char
*
option_name
);
...
...
server-tools/instance-manager/options.cc
View file @
c7581758
...
@@ -224,10 +224,10 @@ int Options::load(int argc, char **argv)
...
@@ -224,10 +224,10 @@ int Options::load(int argc, char **argv)
/* config-file options are prepended to command-line ones */
/* config-file options are prepended to command-line ones */
load_defaults
(
"my"
,
default_groups
,
&
argc
,
&
argv
);
load_defaults
(
"my"
,
default_groups
,
&
argc
,
&
argv
);
Options
::
saved_argv
=
argv
;
if
((
rc
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
))
!=
0
)
if
((
rc
=
handle_options
(
&
argc
,
&
argv
,
my_long_options
,
get_one_option
))
!=
0
)
return
rc
;
return
rc
;
Options
::
saved_argv
=
argv
;
return
0
;
return
0
;
}
}
...
...
server-tools/instance-manager/parse_output.cc
View file @
c7581758
...
@@ -32,10 +32,13 @@
...
@@ -32,10 +32,13 @@
word the word to look for (usually an option name)
word the word to look for (usually an option name)
result the buffer to store the next word (option value)
result the buffer to store the next word (option value)
result_len self-explanatory
result_len self-explanatory
get_all_line flag, which is set if we want to get all the line after
the matched word.
DESCRIPTION
DESCRIPTION
Parse output of the "command". Find the "word" and return the next one
Parse output of the "command". Find the "word" and return the next one
if get_all_line is 0. Return the rest of the parsed string otherwise.
RETURN
RETURN
0 - ok
0 - ok
...
@@ -43,7 +46,8 @@
...
@@ -43,7 +46,8 @@
*/
*/
int
parse_output_and_get_value
(
const
char
*
command
,
const
char
*
word
,
int
parse_output_and_get_value
(
const
char
*
command
,
const
char
*
word
,
char
*
result
,
size_t
result_len
)
char
*
result
,
size_t
result_len
,
int
get_all_line
)
{
{
FILE
*
output
;
FILE
*
output
;
uint
wordlen
;
uint
wordlen
;
...
@@ -81,11 +85,19 @@ int parse_output_and_get_value(const char *command, const char *word,
...
@@ -81,11 +85,19 @@ int parse_output_and_get_value(const char *command, const char *word,
an option value.
an option value.
*/
*/
linep
+=
lineword_len
;
/* swallow the previous one */
linep
+=
lineword_len
;
/* swallow the previous one */
get_word
((
const
char
**
)
&
linep
,
&
lineword_len
,
NONSPACE
);
if
(
!
get_all_line
)
if
(
result_len
<=
lineword_len
)
{
goto
err
;
get_word
((
const
char
**
)
&
linep
,
&
lineword_len
,
NONSPACE
);
strncpy
(
result
,
linep
,
lineword_len
);
if
(
result_len
<=
lineword_len
)
result
[
lineword_len
]
=
'\0'
;
goto
err
;
strncpy
(
result
,
linep
,
lineword_len
);
result
[
lineword_len
]
=
'\0'
;
}
else
{
strncpy
(
result
,
linep
,
result_len
);
result
[
result_len
]
=
'\0'
;
/* safety */
}
goto
pclose
;
goto
pclose
;
}
}
}
}
...
...
server-tools/instance-manager/parse_output.h
View file @
c7581758
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
int
parse_output_and_get_value
(
const
char
*
command
,
const
char
*
word
,
int
parse_output_and_get_value
(
const
char
*
command
,
const
char
*
word
,
char
*
result
,
size_t
result_len
);
char
*
result
,
size_t
result_len
,
int
get_all_line
=
0
);
#endif
/* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
#endif
/* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment