1 --- mysql-5.1.22-rc/client/mysql_upgrade.c 2007-09-24 13:30:24.000000000 +0300
2 +++ mysql-5.1.22-rc-upgrade/client/mysql_upgrade.c 2008-01-12 17:28:56.945615880 +0200
7 -static char mysql_path[FN_REFLEN];
8 -static char mysqlcheck_path[FN_REFLEN];
9 +static char *mysql_path = "/usr/bin/mysql";
10 +static char *mysqlcheck_path = "/usr/sbin/mysqlcheck";
12 static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag;
13 static uint my_end_arg= 0;
14 -static char *opt_user= (char*)"root";
15 +static char *opt_user= (char*)"mysql";
17 static DYNAMIC_STRING ds_args;
25 - Look for the tool in the same directory as mysql_upgrade.
27 - When running in a not yet installed build the the program
28 - will exist but it need to be invoked via it's libtool wrapper.
29 - Check if the found tool can executed and if not look in the
30 - directory one step higher up where the libtool wrapper normally
34 -static void find_tool(char *tool_path, const char *tool_name)
36 - char path[FN_REFLEN];
37 - DYNAMIC_STRING ds_tmp;
38 - DBUG_ENTER("find_tool");
39 - DBUG_PRINT("enter", ("progname: %s", my_progname));
41 - if (init_dynamic_string(&ds_tmp, "", 32, 32))
42 - die("Out of memory");
44 - /* Initialize path with the full path to this program */
45 - if (get_full_path_to_executable(path))
48 - Easy way to get full executable path failed, try
51 - if (my_progname[0] == FN_LIBCHAR)
53 - /* 1. my_progname contains full path */
54 - strmake(path, my_progname, FN_REFLEN);
56 - else if (my_progname[0] == '.')
58 - /* 2. my_progname contains relative path, prepend wd */
59 - char buf[FN_REFLEN];
60 - my_getwd(buf, FN_REFLEN, MYF(0));
61 - my_snprintf(path, FN_REFLEN, "%s%s", buf, my_progname);
65 - /* 3. Just go for it and hope tool is in path */
72 - DBUG_PRINT("enter", ("path: %s", path));
74 - /* Chop off last char(since it might be a /) */
75 - path[max((strlen(path)-1), 0)]= 0;
77 - /* Chop off last dir part */
78 - dirname_part(path, path, &path_len);
80 - /* Format name of the tool to search for */
81 - fn_format(tool_path, tool_name,
82 - path, "", MYF(MY_REPLACE_DIR));
84 - verbose("Looking for '%s' in: %s", tool_name, tool_path);
86 - /* Make sure the tool exists */
87 - if (my_access(tool_path, F_OK) != 0)
88 - die("Can't find '%s'", tool_path);
91 - Make sure it can be executed, otherwise try again
92 - in higher level directory
95 - while(run_tool(tool_path,
96 - &ds_tmp, /* Get output from command, discard*/
99 - IF_WIN("> NUL", "> /dev/null"),
102 - dynstr_free(&ds_tmp);
109 Run query using "mysql"
112 dynstr_append_os_quoted(&ds_args, "--user=", opt_user, NullS);
113 dynstr_append(&ds_args, " ");
116 - find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"));
118 - /* Find mysqlcheck */
119 - find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"));
122 Read the mysql_upgrade_info file to check if mysql_upgrade
123 already has been run for this installation of MySQL