Commit f3d73e8c authored by petr@mysql.com's avatar petr@mysql.com

Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  mysql.com:/home/cps/mysql/devel/5.1-im-fixes
parents 5bb07f7e 84884985
...@@ -3,22 +3,22 @@ instance_name status ...@@ -3,22 +3,22 @@ instance_name status
mysqld1 online mysqld1 online
mysqld2 offline mysqld2 offline
SHOW INSTANCE STATUS mysqld1; SHOW INSTANCE STATUS mysqld1;
instance_name status version instance_name status version_number version
mysqld1 online VERSION mysqld1 online VERSION_NUMBER VERSION
SHOW INSTANCE STATUS mysqld2; SHOW INSTANCE STATUS mysqld2;
instance_name status version instance_name status version_number version
mysqld2 offline VERSION mysqld2 offline VERSION_NUMBER VERSION
START INSTANCE mysqld2; START INSTANCE mysqld2;
SHOW INSTANCES; SHOW INSTANCES;
instance_name status instance_name status
mysqld1 online mysqld1 online
mysqld2 online mysqld2 online
SHOW INSTANCE STATUS mysqld1; SHOW INSTANCE STATUS mysqld1;
instance_name status version instance_name status version_number version
mysqld1 online VERSION mysqld1 online VERSION_NUMBER VERSION
SHOW INSTANCE STATUS mysqld2; SHOW INSTANCE STATUS mysqld2;
instance_name status version instance_name status version_number version
mysqld2 online VERSION mysqld2 online VERSION_NUMBER VERSION
SHOW VARIABLES LIKE 'port'; SHOW VARIABLES LIKE 'port';
Variable_name Value Variable_name Value
port IM_MYSQLD1_PORT port IM_MYSQLD1_PORT
...@@ -28,11 +28,11 @@ instance_name status ...@@ -28,11 +28,11 @@ instance_name status
mysqld1 online mysqld1 online
mysqld2 offline mysqld2 offline
SHOW INSTANCE STATUS mysqld1; SHOW INSTANCE STATUS mysqld1;
instance_name status version instance_name status version_number version
mysqld1 online VERSION mysqld1 online VERSION_NUMBER VERSION
SHOW INSTANCE STATUS mysqld2; SHOW INSTANCE STATUS mysqld2;
instance_name status version instance_name status version_number version
mysqld2 offline VERSION mysqld2 offline VERSION_NUMBER VERSION
START INSTANCE mysqld3; START INSTANCE mysqld3;
ERROR HY000: Bad instance name. Check that the instance with such a name exists ERROR HY000: Bad instance name. Check that the instance with such a name exists
START INSTANCE mysqld1; START INSTANCE mysqld1;
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
########################################################################### ###########################################################################
SHOW INSTANCES; SHOW INSTANCES;
--replace_column 3 VERSION --replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1; SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION --replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld2; SHOW INSTANCE STATUS mysqld2;
########################################################################### ###########################################################################
...@@ -38,9 +38,9 @@ START INSTANCE mysqld2; ...@@ -38,9 +38,9 @@ START INSTANCE mysqld2;
--sleep 3 --sleep 3
SHOW INSTANCES; SHOW INSTANCES;
--replace_column 3 VERSION --replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1; SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION --replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld2; SHOW INSTANCE STATUS mysqld2;
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK) --connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
...@@ -66,9 +66,9 @@ STOP INSTANCE mysqld2; ...@@ -66,9 +66,9 @@ STOP INSTANCE mysqld2;
--sleep 3 --sleep 3
SHOW INSTANCES; SHOW INSTANCES;
--replace_column 3 VERSION --replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1; SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION --replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld2; SHOW INSTANCE STATUS mysqld2;
########################################################################### ###########################################################################
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "options.h" #include "options.h"
#include <m_string.h> #include <m_string.h>
#include <m_ctype.h>
#include <mysql.h> #include <mysql.h>
#include <my_dir.h> #include <my_dir.h>
...@@ -62,6 +63,31 @@ static inline int put_to_buff(Buffer *buff, const char *str, uint *position) ...@@ -62,6 +63,31 @@ static inline int put_to_buff(Buffer *buff, const char *str, uint *position)
} }
static int parse_version_number(const char *version_str, char *version,
uint version_size)
{
const char *start= version_str;
const char *end;
// skip garbage
while (!my_isdigit(default_charset_info, *start))
start++;
end= start;
// skip digits and dots
while (my_isdigit(default_charset_info, *end) || *end == '.')
end++;
if ((uint)(end - start) >= version_size)
return -1;
strncpy(version, start, end-start);
version[end-start]= '\0';
return 0;
}
/* implementation for Show_instances: */ /* implementation for Show_instances: */
...@@ -174,9 +200,10 @@ int Show_instance_status::execute(struct st_net *net, ...@@ -174,9 +200,10 @@ int Show_instance_status::execute(struct st_net *net,
{ {
enum { MAX_VERSION_LENGTH= 40 }; enum { MAX_VERSION_LENGTH= 40 };
Buffer send_buff; /* buffer for packets */ Buffer send_buff; /* buffer for packets */
LIST name, status, version; LIST name, status, version, version_number;
LIST *field_list; LIST *field_list;
NAME_WITH_LENGTH name_field, status_field, version_field; NAME_WITH_LENGTH name_field, status_field, version_field,
version_number_field;
uint position=0; uint position=0;
if (!instance_name) if (!instance_name)
...@@ -192,7 +219,11 @@ int Show_instance_status::execute(struct st_net *net, ...@@ -192,7 +219,11 @@ int Show_instance_status::execute(struct st_net *net,
version_field.name= (char*) "version"; version_field.name= (char*) "version";
version_field.length= MAX_VERSION_LENGTH; version_field.length= MAX_VERSION_LENGTH;
version.data= &version_field; version.data= &version_field;
version_number_field.name= (char*) "version_number";
version_number_field.length= MAX_VERSION_LENGTH;
version_number.data= &version_number_field;
field_list= list_add(NULL, &version); field_list= list_add(NULL, &version);
field_list= list_add(field_list, &version_number);
field_list= list_add(field_list, &status); field_list= list_add(field_list, &status);
field_list= list_add(field_list, &name); field_list= list_add(field_list, &name);
...@@ -210,10 +241,21 @@ int Show_instance_status::execute(struct st_net *net, ...@@ -210,10 +241,21 @@ int Show_instance_status::execute(struct st_net *net,
store_to_protocol_packet(&send_buff, (char*) "offline", &position); store_to_protocol_packet(&send_buff, (char*) "offline", &position);
if (instance->options.mysqld_version) if (instance->options.mysqld_version)
{
char parsed_version[MAX_VERSION_LENGTH];
parse_version_number(instance->options.mysqld_version, parsed_version,
sizeof(parsed_version));
store_to_protocol_packet(&send_buff, parsed_version, &position);
store_to_protocol_packet(&send_buff, instance->options.mysqld_version, store_to_protocol_packet(&send_buff, instance->options.mysqld_version,
&position); &position);
}
else else
{
store_to_protocol_packet(&send_buff, (char*) "unknown", &position); store_to_protocol_packet(&send_buff, (char*) "unknown", &position);
store_to_protocol_packet(&send_buff, (char*) "unknown", &position);
}
if (send_buff.is_error() || if (send_buff.is_error() ||
......
...@@ -138,9 +138,14 @@ int Instance_options::fill_instance_version() ...@@ -138,9 +138,14 @@ int Instance_options::fill_instance_version()
if (*result != '\0') if (*result != '\0')
{ {
char *start;
/* chop the newline from the end of the version string */ /* chop the newline from the end of the version string */
result[strlen(result) - NEWLINE_LEN]= '\0'; result[strlen(result) - NEWLINE_LEN]= '\0';
mysqld_version= strdup_root(&alloc, result); /* trim leading whitespaces */
start= result;
while (my_isspace(default_charset_info, *start))
++start;
mysqld_version= strdup_root(&alloc, start);
} }
err: err:
return rc; return rc;
...@@ -167,8 +172,6 @@ err: ...@@ -167,8 +172,6 @@ err:
int Instance_options::fill_log_options() int Instance_options::fill_log_options()
{ {
Buffer buff; Buffer buff;
uint position= 0;
char **tmp_argv= argv;
enum { MAX_LOG_OPTION_LENGTH= 256 }; enum { MAX_LOG_OPTION_LENGTH= 256 };
char datadir[MAX_LOG_OPTION_LENGTH]; char datadir[MAX_LOG_OPTION_LENGTH];
char hostname[MAX_LOG_OPTION_LENGTH]; char hostname[MAX_LOG_OPTION_LENGTH];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment