Skip to content

Commit 41c4144

Browse files
mysql_upgrade win fixes
1 parent 50669c4 commit 41c4144

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

client/mysql_upgrade.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)
335335

336336
va_end(args);
337337

338+
#ifdef __WIN__
339+
dynstr_append(&ds_cmdline, "\"");
340+
#endif
341+
338342
DBUG_PRINT("info", ("Running: %s", ds_cmdline.str));
339343
ret= run_command(ds_cmdline.str, ds_res);
340344
DBUG_PRINT("exit", ("ret: %d", ret));
@@ -354,11 +358,11 @@ static my_bool get_full_path_to_executable(char* path)
354358
{
355359
my_bool ret;
356360
DBUG_ENTER("get_full_path_to_executable");
357-
#ifdef WIN
358-
ret= GetModuleFileName(NULL, path, FN_REFLEN) != 0;
361+
#ifdef __WIN__
362+
ret= (GetModuleFileName(NULL, path, FN_REFLEN) == 0);
359363
#else
360364
/* my_readlink returns 0 if a symlink was read */
361-
ret= my_readlink(path, "/proc/self/exe", MYF(0)) != 0;
365+
ret= (my_readlink(path, "/proc/self/exe", MYF(0)) != 0);
362366
/* Might also want to try with /proc/$$/exe if the above fails */
363367
#endif
364368
DBUG_PRINT("exit", ("path: %s", path));
@@ -416,8 +420,7 @@ static void find_tool(char *tool_path, const char *tool_name)
416420
DBUG_PRINT("enter", ("path: %s", path));
417421

418422
/* Chop off last char(since it might be a /) */
419-
size_t pos= max((strlen(path)-1), 0);
420-
path[pos]= 0;
423+
path[max((strlen(path)-1), 0)]= 0;
421424

422425
/* Chop off last dir part */
423426
dirname_part(path, path);

scripts/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings)
2020
# Build comp_sql - used for embedding SQL in C or C++ programs
2121
GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
2222

23-
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/client/mysql_fix_privilege_tables_sql.c
23+
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c
2424
COMMAND ${COMP_SQL_EXE}
25-
${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql
26-
${PROJECT_SOURCE_DIR}/client/mysql_fix_privilege_tables_sql.c
25+
mysql_fix_privilege_tables.sql
26+
mysql_fix_privilege_tables_sql.c
2727
DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql)
2828

29+
ADD_CUSTOM_TARGET(GenFixPrivs
30+
ALL
31+
DEPENDS ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c)

scripts/comp_sql.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
7474
while(*end && *end != '.')
7575
end++;
7676
*end= 0;
77-
fprintf(out, "const char* %s={\"\\\n", infile_name);
77+
fprintf(out, "const char* %s={\n\"", infile_name);
7878

7979
while (fgets(buff, sizeof(buff), in))
8080
{
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
8787
Reached end of line, add escaped newline, escaped
8888
backslash and a newline to outfile
8989
*/
90-
fprintf(out, "\\n\\\n");
90+
fprintf(out, "\\n \"\n\"");
9191
curr++;
9292
}
9393
else if (*curr == '\r')

0 commit comments

Comments
 (0)