summaryrefslogtreecommitdiff
path: root/sql/mysql_upgrade_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/mysql_upgrade_service.cc')
-rw-r--r--sql/mysql_upgrade_service.cc40
1 files changed, 17 insertions, 23 deletions
diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc
index 3850816010d..61f9f2542e9 100644
--- a/sql/mysql_upgrade_service.cc
+++ b/sql/mysql_upgrade_service.cc
@@ -366,6 +366,7 @@ static void get_service_config()
*/
static void change_service_config()
{
+ char defaults_file[MAX_PATH];
char default_character_set[64];
char buf[MAX_PATH];
char commandline[3 * MAX_PATH + 19];
@@ -375,17 +376,13 @@ static void change_service_config()
Write datadir to my.ini, after converting backslashes to
unix style slashes.
*/
- if (service_properties.datadir[0])
+ strcpy_s(buf, MAX_PATH, service_properties.datadir);
+ for(i= 0; buf[i]; i++)
{
- strcpy_s(buf, MAX_PATH, service_properties.datadir);
- for (i= 0; buf[i]; i++)
- {
- if (buf[i] == '\\')
- buf[i]= '/';
- }
- WritePrivateProfileString("mysqld", "datadir", buf,
- service_properties.inifile);
+ if (buf[i] == '\\')
+ buf[i]= '/';
}
+ WritePrivateProfileString("mysqld", "datadir",buf, service_properties.inifile);
/*
Remove basedir from defaults file, otherwise the service wont come up in
@@ -400,19 +397,19 @@ static void change_service_config()
*/
default_character_set[0]= 0;
GetPrivateProfileString("mysqld", "default-character-set", NULL,
- default_character_set, sizeof(default_character_set), service_properties.inifile);
+ default_character_set, sizeof(default_character_set), defaults_file);
if (default_character_set[0])
{
WritePrivateProfileString("mysqld", "default-character-set", NULL,
- service_properties.inifile);
+ defaults_file);
WritePrivateProfileString("mysqld", "character-set-server",
- default_character_set, service_properties.inifile);
+ default_character_set, defaults_file);
}
sprintf(defaults_file_param,"--defaults-file=%s", service_properties.inifile);
sprintf_s(commandline, "\"%s\" \"%s\" \"%s\"", mysqld_path,
defaults_file_param, opt_service);
- if (!my_ChangeServiceConfig(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
+ if (!ChangeServiceConfig(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE, commandline, NULL, NULL, NULL, NULL, NULL, NULL))
{
die("ChangeServiceConfig failed with %u", GetLastError());
@@ -486,8 +483,13 @@ int main(int argc, char **argv)
}
}
- old_mysqld_exe_exists= (GetFileAttributes(service_properties.mysqld_exe) !=
- INVALID_FILE_ATTRIBUTES);
+ old_mysqld_exe_exists = (GetFileAttributes(service_properties.mysqld_exe) != INVALID_FILE_ATTRIBUTES);
+ log("Phase %d/%d: Fixing server config file%s", ++phase, max_phases, my_ini_exists ? "" : "(skipped)");
+
+ snprintf(my_ini_bck, sizeof(my_ini_bck), "%s.BCK", service_properties.inifile);
+ CopyFile(service_properties.inifile, my_ini_bck, FALSE);
+ upgrade_config_file(service_properties.inifile);
+
bool do_start_stop_server = old_mysqld_exe_exists && initial_service_state != SERVICE_RUNNING;
log("Phase %d/%d: Start and stop server in the old version, to avoid crash recovery %s", ++phase, max_phases,
@@ -542,14 +544,6 @@ int main(int argc, char **argv)
start_duration_ms += 500;
}
}
-
- log("Phase %d/%d: Fixing server config file%s", ++phase, max_phases,
- my_ini_exists ? "" : "(skipped)");
- snprintf(my_ini_bck, sizeof(my_ini_bck), "%s.BCK",
- service_properties.inifile);
- CopyFile(service_properties.inifile, my_ini_bck, FALSE);
- upgrade_config_file(service_properties.inifile);
-
/*
Start mysqld.exe as non-service skipping privileges (so we do not
care about the password). But disable networking and enable pipe