From: Date: August 26 2005 12:19pm Subject: bk commit into 5.0 tree (SergeyV:1.1928) BUG#11815 List-Archive: http://lists.mysql.com/internals/28884 X-Bug: 11815 Message-Id: <200508261019.j7QAJZ7W001263@selena.creware.com> Below is the list of changes that have just been committed into a local 5.0 repository of sergeyv. When sergeyv does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1928 05/08/26 14:19:19 SergeyV@selena. +4 -0 Fixes bug #11815. Converts file path to MySQL canonical format to build correct query string while replicating LOAD INFILE statement. sql/log_event.cc 1.189 05/08/26 14:19:11 SergeyV@selena. +2 -1 Converts file path to MySQL canonical format to build correct query string while replicating LOAD INFILE statement. mysys/mf_format.c 1.20 05/08/26 14:19:10 SergeyV@selena. +2 -0 Added an option for fn_format function to convert path from system representation to MySQL native (canonical). mysys/mf_dirname.c 1.12 05/08/26 14:19:10 SergeyV@selena. +65 -0 Added a function to convert directory path from system representation to MySQL native (canonical). include/my_sys.h 1.167 05/08/26 14:19:08 SergeyV@selena. +1 -0 Added an option for fn_format function to convert path from system representation to MySQL native (canonical). # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: SergeyV # Host: selena. # Root: H:/MYSQL/src/mysql-5.0-11815 --- 1.166/include/my_sys.h 2005-08-19 22:55:19 +04:00 +++ 1.167/include/my_sys.h 2005-08-26 14:19:08 +04:00 @@ -98,6 +98,7 @@ #define MY_RETURN_REAL_PATH 32 /* return full path for file */ #define MY_SAFE_PATH 64 /* Return NULL if too long path */ #define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ +#define MY_CANONICAL_PATH 256 /* Returns MySQL canonical path */ /* My seek flags */ #define MY_SEEK_SET 0 --- 1.11/mysys/mf_dirname.c 2005-08-08 18:51:16 +04:00 +++ 1.12/mysys/mf_dirname.c 2005-08-26 14:19:10 +04:00 @@ -151,3 +151,68 @@ } return to; /* Pointer to end of dir */ } /* convert_dirname */ + + +/* + Convert directory name from this system to MySQL canonical represenation + + SYNPOSIS + unconvert_dirname() + to Store result here + from Original filename + from_end Pointer at end of filename (normally end \0) + + IMPLEMENTATION + If MSDOS converts '\' to '/' + If VMS converts '[' to '<' and ']' to '>' + Adds a '/' to end if the result string if there isn't one + and the last isn't dev_char. + Copies data from 'from' until ASCII(0) for until from == from_end + If you want to use the whole 'from' string, just send NullS as the + last argument. + + If the result string is larger than FN_REFLEN -1, then it's cut. + + RETURN + Returns pointer to end \0 in to +*/ +char *unconvert_dirname(char *to, const char *from, const char *from_end) +{ + char *to_org=to; + + /* We use -2 here, becasue we need place for the last '/' */ + if (!from_end || (from_end - from) > FN_REFLEN-2) + from_end=from+FN_REFLEN -2; + +#if FN_LIBCHAR != '/' || defined(FN_C_BEFORE_DIR_2) + { + for (; *from && from != from_end; from++) + { + if (*from == FN_LIBCHAR) + *to++= '/'; +#ifdef FN_C_BEFORE_DIR_2 + else if (*from == FN_C_BEFORE_DIR) + *to++= FN_C_BEFORE_DIR_2; + else if (*from == FN_C_AFTER_DIR) + *to++= FN_C_AFTER_DIR_2; +#endif + else + *to++= *from; + } + *to=0; + } +#else + /* This is ok even if to == from, becasue we need to cut the string */ + to= strmake(to, from, (uint) (from_end-from)); +#endif + + /* Add MySQL default dir separator to the end of directory path */ + if (to != to_org && (to[-1] != '/' && to[-1] != FN_DEVCHAR)) + { + *to++='/'; + *to=0; + } + + return to; /* Pointer to end of dir */ +} /* unconvert_dirname */ + --- 1.19/mysys/mf_format.c 2004-09-07 10:55:31 +04:00 +++ 1.20/mysys/mf_format.c 2005-08-26 14:19:10 +04:00 @@ -54,6 +54,8 @@ pack_dirname(dev,dev); /* Put in ./.. and ~/.. */ if (flag & MY_UNPACK_FILENAME) (void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */ + if (flag & MY_CANONICAL_PATH) + unconvert_dirname(dev,dir,NullS); /* Fix to MySQL representation */ if ((pos= (char*) strchr(name,FN_EXTCHAR)) != NullS) { if ((flag & MY_REPLACE_EXT) == 0) /* If we should keep old ext */ --- 1.188/sql/log_event.cc 2005-08-24 13:12:11 +04:00 +++ 1.189/sql/log_event.cc 2005-08-26 14:19:11 +04:00 @@ -121,7 +121,8 @@ static inline char* slave_load_file_stem(char*buf, uint file_id, int event_server_id) { - fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME); + fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", + MY_UNPACK_FILENAME | MY_CANONICAL_PATH); buf = strend(buf); buf = int10_to_str(::server_id, buf, 10); *buf++ = '-';