From 19538177775027e6852bd109c5da7f1fb73cf790 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Mar 2005 16:47:35 -0600 Subject: Bug #6660 mysqldump creates bad pathnames on Windows This really should not happen on Windows and part of the problem not fixed here is why show create table includes data directory when being run on Windows. However, this patch fixes the bug in mysqldump.c mysqldump.c: Added fixPaths function to convert \ to / in data directory and index directory entries only on Windows client/mysqldump.c: Added fixPaths function to convert \ to / in data directory and index directory entries only on Windows BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + client/mysqldump.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index f64d9ca4042..8a0c32e37d1 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -190,6 +190,7 @@ ramil@mysql.com ranger@regul.home.lan rburnett@build.mysql.com reggie@bob.(none) +reggie@mdk10.(none) root@home.(none) root@mc04.(none) root@x3.internalnet diff --git a/client/mysqldump.c b/client/mysqldump.c index a53dc319b2e..5ac5efb5128 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1080,6 +1080,27 @@ static void print_xml_row(FILE *xml_file, const char *row_name, check_io(xml_file); } + +/* fixPaths -- on Windows only, this function will iterate through the output + of show create table and change any \ characters that appear in the data directory + or index directory elements to be / + + RETURN + void +*/ +static void fixPaths(char *buf, int buflen) +{ +#ifdef __WIN__ + int i = 0; + for (i=0; i < buflen; i++) + { + if (buf[i] != '\\') continue; + if (i != 0 && buf[i-1] == '\\') continue; + if (i != (buflen-1) && buf[i+1] == '\\') continue; + buf[i] = '/';} +#endif +} + /* getStructure -- retrievs database structure, prints out corresponding CREATE statement and fills out insert_pat. @@ -1159,6 +1180,7 @@ static uint getTableStructure(char *table, char* db) tableRes=mysql_store_result(sock); row=mysql_fetch_row(tableRes); + fixPaths(row[1], strlen(row[1])); // this really only does something on Windows fprintf(sql_file, "%s;\n", row[1]); check_io(sql_file); mysql_free_result(tableRes); -- cgit v1.2.1 From c209d1128826cec3a153dd723049dcca6200d9a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Mar 2005 11:33:06 -0600 Subject: Bug #6660 mysqldump creates bad pathnames on Windows This is a modifiction of my previous patch after receiving feedback. This is a better way to fix the problem. With this patch, data directory and index directory will use only forward slashes (/) when on Windows. mysqldump.c: Removed fixPaths routine. Was improper fix for bug #6660 sql_show.cc: Changed append_directory to convert backslashes to foward slashes when on Windows. sql/sql_show.cc: Changed append_directory to convert backslashes to foward slashes when on Windows. client/mysqldump.c: Removed fixPaths routine. Was improper fix for bug #6660 --- client/mysqldump.c | 21 --------------------- sql/sql_show.cc | 9 +++++++++ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 5ac5efb5128..fa36ce0242d 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1081,26 +1081,6 @@ static void print_xml_row(FILE *xml_file, const char *row_name, } -/* fixPaths -- on Windows only, this function will iterate through the output - of show create table and change any \ characters that appear in the data directory - or index directory elements to be / - - RETURN - void -*/ -static void fixPaths(char *buf, int buflen) -{ -#ifdef __WIN__ - int i = 0; - for (i=0; i < buflen; i++) - { - if (buf[i] != '\\') continue; - if (i != 0 && buf[i-1] == '\\') continue; - if (i != (buflen-1) && buf[i+1] == '\\') continue; - buf[i] = '/';} -#endif -} - /* getStructure -- retrievs database structure, prints out corresponding CREATE statement and fills out insert_pat. @@ -1180,7 +1160,6 @@ static uint getTableStructure(char *table, char* db) tableRes=mysql_store_result(sock); row=mysql_fetch_row(tableRes); - fixPaths(row[1], strlen(row[1])); // this really only does something on Windows fprintf(sql_file, "%s;\n", row[1]); check_io(sql_file); mysql_free_result(tableRes); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8d741b4dc67..a85a6f92d70 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1227,7 +1227,16 @@ static void append_directory(THD *thd, String *packet, const char *dir_type, packet->append(' '); packet->append(dir_type); packet->append(" DIRECTORY='", 12); +#ifdef __WIN__ + char *winfilename = strdup(filename); + for (uint i=0; i < length; i++) + if (winfilename[i] == '\\') + winfilename[i] = '/'; + packet->append(winfilename, length); + free(winfilename); +#else packet->append(filename, length); +#endif packet->append('\''); } } -- cgit v1.2.1