summaryrefslogtreecommitdiff
path: root/client/mysqldump.c
diff options
context:
space:
mode:
authorunknown <reggie@mdk10.(none)>2005-03-14 16:47:35 -0600
committerunknown <reggie@mdk10.(none)>2005-03-14 16:47:35 -0600
commit2722a28691d55a9352794dcca5565ebec56c901b (patch)
tree46edcf57991cf42ece7a0862bfe50ab09349bc78 /client/mysqldump.c
parent90697f2467fda156d9a939738e443200a090884f (diff)
downloadmariadb-git-2722a28691d55a9352794dcca5565ebec56c901b.tar.gz
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
Diffstat (limited to 'client/mysqldump.c')
-rw-r--r--client/mysqldump.c22
1 files changed, 22 insertions, 0 deletions
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);