diff --git a/include/my_sys.h b/include/my_sys.h index 5d155eb20cc50cb4079c56fba69152efd2b0ce6a..2dc4053f70d9af0470b1f2459ac3b6aeeb134f4b 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -531,6 +531,7 @@ typedef int (*Process_option_func)(void *ctx, const char *group_name, #include <my_alloc.h> + /* Prototypes for mysys and my_func functions */ extern int my_copy(const char *from,const char *to,myf MyFlags); @@ -604,6 +605,13 @@ extern File my_sopen(const char *path, int oflag, int shflag, int pmode); extern int check_if_legal_filename(const char *path); extern int check_if_legal_tablename(const char *path); +#if defined(__WIN__) && defined(__NT__) +extern int nt_share_delete(const char *name,myf MyFlags); +#define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags)) +#else +#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags)) +#endif + #ifndef TERMINATE extern void TERMINATE(FILE *file); #endif diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ca2eb6641cde3d1c61891f29f117da239a19142a..f757c59d90efd61ff45cdecb6ab95d67ac02fdf2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1049,7 +1049,9 @@ sub executable_setup () { # New CMake locations. "$glob_basedir/client/release", "$glob_basedir/client/debug"); - $exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-nt", + $exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-max-nt", + "$path_client_bindir/mysqld-max", + "$path_client_bindir/mysqld-nt", "$path_client_bindir/mysqld", "$path_client_bindir/mysqld-debug", "$path_client_bindir/mysqld-max", diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test index 00ae5c935bfba84183c832e6948e2ac7c665d005..313e22193f5618fc1b448f986daa0470dc773920 100644 --- a/mysql-test/t/rpl_openssl.test +++ b/mysql-test/t/rpl_openssl.test @@ -1,3 +1,7 @@ +# TODO: THIS TEST DOES NOT WORK ON WINDOWS +# This should be fixed. +--source include/not_windows.inc + source include/have_openssl.inc; source include/master-slave.inc; diff --git a/mysys/my_delete.c b/mysys/my_delete.c index 5670f03da64437be7508fbe75bfc32afd29bb745..de2a9814a5647c72410865816767fa34b51e349c 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -32,3 +32,54 @@ int my_delete(const char *name, myf MyFlags) } DBUG_RETURN(err); } /* my_delete */ + +#if defined(__WIN__) && defined(__NT__) +/* + Delete file which is possibly not closed. + + This function is intended to be used exclusively as a temporal solution + for Win NT in case when it is needed to delete a not closed file (note + that the file must be opened everywhere with FILE_SHARE_DELETE mode). + Deleting not-closed files can not be supported on Win 98|ME (and because + of that is considered harmful). + + The function deletes the file with its preliminary renaming. This is + because when not-closed share-delete file is deleted it still lives on + a disk until it will not be closed everwhere. This may conflict with an + attempt to create a new file with the same name. The deleted file is + renamed to <name>.<num>.deleted where <name> - the initial name of the + file, <num> - a hexadecimal number chosen to make the temporal name to + be unique. +*/ +int nt_share_delete(const char *name, myf MyFlags) +{ + char buf[MAX_PATH + 20]; + ulong cnt; + DBUG_ENTER("nt_share_delete"); + DBUG_PRINT("my",("name %s MyFlags %d", name, MyFlags)); + + for (cnt= GetTickCount(); cnt; cnt--) + { + sprintf(buf, "%s.%08X.deleted", name, cnt); + if (MoveFile(name, buf)) + break; + + if ((errno= GetLastError()) == ERROR_ALREADY_EXISTS) + continue; + + DBUG_PRINT("warning", ("Failed to rename %s to %s, errno: %d", + name, buf, errno)); + break; + } + + if (DeleteFile(buf)) + DBUG_RETURN(0); + + my_errno= GetLastError(); + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), + name, my_errno); + + DBUG_RETURN(-1); +} +#endif diff --git a/sql/log.cc b/sql/log.cc index 7168f7e2da7d2da177374a5aa3eb9b6fabde2ad3..ec73400ea3c0020a32404a5b81ce2cbc399a6d15 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2492,14 +2492,14 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd) for (;;) { - my_delete(linfo.log_file_name, MYF(MY_WME)); + my_delete_allow_opened(linfo.log_file_name, MYF(MY_WME)); 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) + my_delete_allow_opened(index_file_name, MYF(MY_WME)); // Reset (open will update) if (!thd->slave_thread) need_start_event=1; if (!open_index_file(index_file_name, 0))