From: Date: June 27 2006 7:56pm Subject: bk commit into 5.0 tree (aivanov:1.2191) BUG#19208 List-Archive: http://lists.mysql.com/commits/8338 X-Bug: 19208 Message-Id: Below is the list of changes that have just been committed into a local 5.0 repository of alexi. When alexi 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.2191 06/06/27 21:56:07 aivanov@stripped +2 -0 Fixing BUG#17719 "Delete of binlog files fails on Windows" and BUG#19208 "Test 'rpl000017 hangs on Windows". Both bugs are caused by attempting to delete an opened file and to immediatedly create a new one with the same name. On Windows this can be supported (and currently is temporaly fixed) only on NT platforms (by using FILE_SHARE_DELETE attribute and with renaming the file before deletion). Because deleting of not-closed file is not supported by all (at least, by all Win-) platforms such cases should be eliminated by "code redesign". sql/log.cc 1.189 06/06/27 21:56:02 aivanov@stripped +62 -1 Adding nt_share_delete() function to be used for binlog file deletion. MYSQL_LOG::reset_logs() - deleting binlog file by the nt_shar_delete() function in case of Win NT. VC++Files/mysys/mysys.vcproj 1.5 06/06/27 21:56:02 aivanov@stripped +5 -5 Adding __NT__ def to all mysys Win configurations. Concerned with using nt_share_delete() function for deleting binlog file. (Perhaps it is better to define a separate NT configuration(s) though currently MySQL Win version is full-blooded for NT platform only). # 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: aivanov # Host: mysqld.localdomain # Root: /home/alexi/bugs/mysql-5.0-19208 --- 1.188/sql/log.cc 2006-03-31 13:47:59 +04:00 +++ 1.189/sql/log.cc 2006-06-27 21:56:02 +04:00 @@ -902,6 +902,59 @@ } +#ifdef __NT__ +/* + Delete file which is possibly not closed (WIN NT only) + + SYNOPSIS + nt_share_delete() + name file name + MyFlags flags + + NOTE + This function is intended to be used exclusively as a temporal solution + for Win NT in case when it is needed to delete a possibly not closed file. + Deleting not closed files can not be supported on Win 98 and ME. Because + of that deleting not closed files is considered harmfull and requires + redesigning of a code. + + RETURN VALUES + 0 ok + -1 error +*/ + +int nt_share_delete(const char *name, myf MyFlags) +{ + char buff[MAX_PATH]; + ulong cnt; + DBUG_ENTER("nt_share_delete"); + + for (cnt= GetTickCount(); cnt; cnt--) + { + sprintf(buff, "%s.%08X", name, cnt); + if (MoveFile(name, buff)) + break; + + if ((errno= GetLastError()) == ERROR_ALREADY_EXISTS) + continue; + + DBUG_PRINT("warning", ("Failed to rename %s to %s, errno: %d", + name, buff, errno)); + break; + } + + if (DeleteFile(buff)) + DBUG_RETURN(0); + + my_errno= GetLastError(); + if (MyFlags & (MY_FAE + MY_WME)) + my_error(ER_CANT_DELETE_FILE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), + name, my_errno); + + DBUG_RETURN(-1); +} +#endif + /* Delete all logs refered to in the index file Start writing to a new log file. The new index file will only contain @@ -959,14 +1012,22 @@ for (;;) { +#ifdef __NT__ + nt_share_delete(linfo.log_file_name, MYF(MY_WME)); +#else my_delete(linfo.log_file_name, MYF(MY_WME)); +#endif if (find_next_log(&linfo, 0)) break; } /* Start logging with a new file */ close(LOG_CLOSE_INDEX); - my_delete(index_file_name, MYF(MY_WME)); // Reset (open will update) +#ifdef __NT__ + nt_share_delete(index_file_name, MYF(MY_WME)); // Reset (open will update) +#else + my_delete(index_file_name, MYF(MY_WME)); // Reset (open will update) +#endif if (!thd->slave_thread) need_start_event=1; if (!open_index_file(index_file_name, 0)) --- 1.4/VC++Files/mysys/mysys.vcproj 2006-05-02 11:19:50 +04:00 +++ 1.5/VC++Files/mysys/mysys.vcproj 2006-06-27 21:56:02 +04:00 @@ -22,7 +22,7 @@ Optimization="0" OptimizeForProcessor="2" AdditionalIncludeDirectories="../include,../zlib" - PreprocessorDefinitions="_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR" + PreprocessorDefinitions="__NT__;_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR" RuntimeLibrary="1" PrecompiledHeaderFile=".\debug/mysys.pch" AssemblerListingLocation=".\debug/" @@ -71,7 +71,7 @@ InlineFunctionExpansion="1" OptimizeForProcessor="2" AdditionalIncludeDirectories="../include,../zlib" - PreprocessorDefinitions="USE_SYMDIR;NDEBUG;DBUG_OFF;_WINDOWS" + PreprocessorDefinitions="__NT__;USE_SYMDIR;NDEBUG;DBUG_OFF;_WINDOWS" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" @@ -121,7 +121,7 @@ InlineFunctionExpansion="1" OptimizeForProcessor="2" AdditionalIncludeDirectories="../include,../zlib" - PreprocessorDefinitions="DBUG_OFF;_WINDOWS;NDEBUG" + PreprocessorDefinitions="__NT__;DBUG_OFF;_WINDOWS;NDEBUG" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" @@ -170,7 +170,7 @@ Optimization="0" OptimizeForProcessor="2" AdditionalIncludeDirectories="../include,../zlib" - PreprocessorDefinitions="_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR;USE_TLS" + PreprocessorDefinitions="__NT__;_DEBUG;SAFEMALLOC;SAFE_MUTEX;_WINDOWS;USE_SYMDIR;USE_TLS" RuntimeLibrary="1" PrecompiledHeaderFile=".\mysys___Win32_TLS_DEBUG/mysys.pch" AssemblerListingLocation=".\mysys___Win32_TLS_DEBUG/" @@ -219,7 +219,7 @@ InlineFunctionExpansion="1" OptimizeForProcessor="2" AdditionalIncludeDirectories="../include,../zlib" - PreprocessorDefinitions="DBUG_OFF;_WINDOWS;NDEBUG;USE_TLS" + PreprocessorDefinitions="__NT__;DBUG_OFF;_WINDOWS;NDEBUG;USE_TLS" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE"