summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/default.c2
-rw-r--r--mysys/md5.c2
-rw-r--r--mysys/mf_arr_appstr.c2
-rw-r--r--mysys/mf_iocache2.c6
-rw-r--r--mysys/mf_keycache.c37
-rw-r--r--mysys/mf_pack.c6
-rw-r--r--mysys/mf_qsort.c2
-rw-r--r--mysys/mf_qsort2.c2
-rw-r--r--mysys/mf_radix.c2
-rw-r--r--mysys/mf_same.c2
-rw-r--r--mysys/mf_soundex.c2
-rw-r--r--mysys/mf_wcomp.c2
-rw-r--r--mysys/mulalloc.c2
-rw-r--r--mysys/my_access.c2
-rw-r--r--mysys/my_aes.c2
-rw-r--r--mysys/my_alarm.c2
-rw-r--r--mysys/my_bitmap.c2
-rw-r--r--mysys/my_compare.c2
-rw-r--r--mysys/my_conio.c2
-rw-r--r--mysys/my_context.c34
-rw-r--r--mysys/my_crc32.c2
-rw-r--r--mysys/my_delete.c166
-rw-r--r--mysys/my_div.c2
-rw-r--r--mysys/my_fopen.c2
-rw-r--r--mysys/my_getopt.c2
-rw-r--r--mysys/my_getpagesize.c2
-rw-r--r--mysys/my_getsystime.c2
-rw-r--r--mysys/my_libwrap.c2
-rw-r--r--mysys/my_memmem.c2
-rw-r--r--mysys/my_mkdir.c2
-rw-r--r--mysys/my_read.c9
-rw-r--r--mysys/my_redel.c2
-rw-r--r--mysys/my_symlink2.c2
-rw-r--r--mysys/test_dir.c2
-rw-r--r--mysys/test_xml.c2
-rw-r--r--mysys/typelib.c2
36 files changed, 188 insertions, 130 deletions
diff --git a/mysys/default.c b/mysys/default.c
index 70738e11d4b..046b1445c51 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/****************************************************************************
Add all options from files named "group".cnf from the default_directories
diff --git a/mysys/md5.c b/mysys/md5.c
index 22a5e409a09..655befa546a 100644
--- a/mysys/md5.c
+++ b/mysys/md5.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
* This code implements the MD5 message-digest algorithm.
diff --git a/mysys/mf_arr_appstr.c b/mysys/mf_arr_appstr.c
index 1edbea9df4a..5ea0a098c5d 100644
--- a/mysys/mf_arr_appstr.c
+++ b/mysys/mf_arr_appstr.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
#include <m_string.h> /* strcmp() */
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index ff05b7fa485..250dc5064a9 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -63,6 +63,8 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file)
DBUG_RETURN(1);
cache->read_pos= cache->read_end;
} while ((bytes_in_cache= my_b_fill(cache)));
+ if(cache->error == -1)
+ DBUG_RETURN(1);
DBUG_RETURN(0);
}
@@ -219,6 +221,8 @@ size_t my_b_fill(IO_CACHE *info)
info->error= 0;
return 0; /* EOF */
}
+ DBUG_EXECUTE_IF ("simulate_my_b_fill_error",
+ {DBUG_SET("+d,simulate_file_read_error");});
if ((length= my_read(info->file,info->buffer,max_length,
info->myflags)) == (size_t) -1)
{
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 5b52998f3ca..1ee71e55b68 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -642,8 +642,7 @@ err:
SYNOPSIS
prepare_resize_simple_key_cache()
- keycache pointer to the control block of a simple key cache
- with_resize_queue <=> resize queue is used
+ keycache pointer to the control block of a simple key cache
release_lock <=> release the key cache lock before return
DESCRIPTION
@@ -651,10 +650,8 @@ err:
this it destroys the key cache calling end_simple_key_cache. The function
takes the parameter keycache as a pointer to the control block
structure of the type SIMPLE_KEY_CACHE_CB for this key cache.
- The parameter with_resize_queue determines weather the resize queue is
- involved (MySQL server never uses this queue). The parameter release_lock
- says weather the key cache lock must be released before return from
- the function.
+ The parameter release_lock says whether the key cache lock must be
+ released before return from the function.
RETURN VALUE
0 - on success,
@@ -668,7 +665,6 @@ err:
static
int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
- my_bool with_resize_queue,
my_bool release_lock)
{
int res= 0;
@@ -682,7 +678,7 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
one resizer only. In set_var.cc keycache->in_init is used to block
multiple attempts.
*/
- while (with_resize_queue && keycache->in_resize)
+ while (keycache->in_resize)
{
/* purecov: begin inspected */
wait_on_queue(&keycache->resize_queue, &keycache->cache_lock);
@@ -744,8 +740,7 @@ finish:
SYNOPSIS
finish_resize_simple_key_cache()
- keycache pointer to the control block of a simple key cache
- with_resize_queue <=> resize queue is used
+ keycache pointer to the control block of a simple key cache
acquire_lock <=> acquire the key cache lock at start
DESCRIPTION
@@ -754,9 +749,7 @@ finish:
keycache as a pointer to the control block structure of the type
SIMPLE_KEY_CACHE_CB for this key cache. The function sets the flag
in_resize in this structure to FALSE.
- The parameter with_resize_queue determines weather the resize queue
- is involved (MySQL server never uses this queue).
- The parameter acquire_lock says weather the key cache lock must be
+ The parameter acquire_lock says whether the key cache lock must be
acquired at the start of the function.
RETURN VALUE
@@ -770,7 +763,6 @@ finish:
static
void finish_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
- my_bool with_resize_queue,
my_bool acquire_lock)
{
DBUG_ENTER("finish_resize_simple_key_cache");
@@ -786,11 +778,10 @@ void finish_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
*/
keycache->in_resize= 0;
- if (with_resize_queue)
- {
- /* Signal waiting threads. */
- release_whole_queue(&keycache->resize_queue);
- }
+
+ /* Signal waiting threads. */
+ release_whole_queue(&keycache->resize_queue);
+
keycache_pthread_mutex_unlock(&keycache->cache_lock);
@@ -857,7 +848,7 @@ int resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache, uint key_cache_block_
We do not lose the cache_lock and will release it only at the end of
this function.
*/
- if (prepare_resize_simple_key_cache(keycache, 1, 0))
+ if (prepare_resize_simple_key_cache(keycache, 0))
goto finish;
/* The following will work even if use_mem is 0 */
@@ -865,7 +856,7 @@ int resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache, uint key_cache_block_
division_limit, age_threshold);
finish:
- finish_resize_simple_key_cache(keycache, 1, 0);
+ finish_resize_simple_key_cache(keycache, 0);
DBUG_RETURN(blocks);
}
@@ -5247,7 +5238,7 @@ int resize_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
}
for (i= 0; i < partitions; i++)
{
- err|= prepare_resize_simple_key_cache(keycache->partition_array[i], 0, 1);
+ err|= prepare_resize_simple_key_cache(keycache->partition_array[i], 1);
}
if (!err)
blocks= init_partitioned_key_cache(keycache, key_cache_block_size,
@@ -5256,7 +5247,7 @@ int resize_partitioned_key_cache(PARTITIONED_KEY_CACHE_CB *keycache,
{
for (i= 0; i < partitions; i++)
{
- finish_resize_simple_key_cache(keycache->partition_array[i], 0, 1);
+ finish_resize_simple_key_cache(keycache->partition_array[i], 1);
}
}
DBUG_RETURN(blocks);
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index d684be238e6..e246ff17f22 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -215,12 +215,6 @@ size_t cleanup_dirname(register char *to, const char *from)
}
else if (pos-start > 1 && pos[-1] == FN_CURLIB && pos[-2] == FN_LIBCHAR)
pos-=2; /* Skip /./ */
- else if (pos > buff+1 && pos[-1] == FN_HOMELIB && pos[-2] == FN_LIBCHAR)
- { /* Found ..../~/ */
- buff[0]=FN_HOMELIB;
- buff[1]=FN_LIBCHAR;
- start=buff; pos=buff+1;
- }
}
}
(void) strmov(to,buff);
diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c
index 9e1ee2782a4..e681ac9cec4 100644
--- a/mysys/mf_qsort.c
+++ b/mysys/mf_qsort.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
qsort implementation optimized for comparison of pointers
diff --git a/mysys/mf_qsort2.c b/mysys/mf_qsort2.c
index ca2bd1a4952..29f92c38926 100644
--- a/mysys/mf_qsort2.c
+++ b/mysys/mf_qsort2.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* qsort that sends one extra argument to the compare subrutine */
diff --git a/mysys/mf_radix.c b/mysys/mf_radix.c
index 2df1220acdd..7ae4ac9211f 100644
--- a/mysys/mf_radix.c
+++ b/mysys/mf_radix.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
Radixsort for pointers to fixed length strings.
diff --git a/mysys/mf_same.c b/mysys/mf_same.c
index 6738dc8051e..b4af4cbf1b6 100644
--- a/mysys/mf_same.c
+++ b/mysys/mf_same.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Kopierar biblioteksstrukturen och extensionen fr}n ett filnamn */
diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c
index 3a3dab52dd6..b3718f20b3f 100644
--- a/mysys/mf_soundex.c
+++ b/mysys/mf_soundex.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/****************************************************************
* SOUNDEX ALGORITHM in C *
diff --git a/mysys/mf_wcomp.c b/mysys/mf_wcomp.c
index 4786537d1a5..74e6fccb5a1 100644
--- a/mysys/mf_wcomp.c
+++ b/mysys/mf_wcomp.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Funktions for comparing with wild-cards */
diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c
index f4ca3d9f9ab..2caac6997ee 100644
--- a/mysys/mulalloc.c
+++ b/mysys/mulalloc.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
#include <stdarg.h>
diff --git a/mysys/my_access.c b/mysys/my_access.c
index 453d3e29cdf..b96e11d9809 100644
--- a/mysys/my_access.c
+++ b/mysys/my_access.c
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
#include <m_string.h>
diff --git a/mysys/my_aes.c b/mysys/my_aes.c
index 575d4702dee..5c52a0b1ab5 100644
--- a/mysys/my_aes.c
+++ b/mysys/my_aes.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
diff --git a/mysys/my_alarm.c b/mysys/my_alarm.c
index d6a0da1bd13..31f98958f61 100644
--- a/mysys/my_alarm.c
+++ b/mysys/my_alarm.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Function to set a varible when we got a alarm */
/* Used by my_lock samt functions in m_alarm.h */
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 83d03177eba..851fe2b1026 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
Handling of uchar arrays as large bitmaps.
diff --git a/mysys/my_compare.c b/mysys/my_compare.c
index 9e192e52fb7..82b30ab3ed3 100644
--- a/mysys/my_compare.c
+++ b/mysys/my_compare.c
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include <my_global.h>
#include <m_ctype.h>
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index 5dbd31193a9..dc87b83f6b4 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
diff --git a/mysys/my_context.c b/mysys/my_context.c
index 08dc0920f21..9be5ab80468 100644
--- a/mysys/my_context.c
+++ b/mysys/my_context.c
@@ -726,3 +726,37 @@ my_context_continue(struct my_context *c)
}
#endif /* MY_CONTEXT_USE_WIN32_FIBERS */
+
+#ifdef MY_CONTEXT_DISABLE
+int
+my_context_continue(struct my_context *c)
+{
+ return -1;
+}
+
+
+int
+my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
+{
+ return -1;
+}
+
+
+int
+my_context_yield(struct my_context *c)
+{
+ return -1;
+}
+
+int
+my_context_init(struct my_context *c, size_t stack_size)
+{
+ return -1; /* Out of memory */
+}
+
+void
+my_context_destroy(struct my_context *c)
+{
+}
+
+#endif
diff --git a/mysys/my_crc32.c b/mysys/my_crc32.c
index 51c553da5ea..27800098f12 100644
--- a/mysys/my_crc32.c
+++ b/mysys/my_crc32.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
diff --git a/mysys/my_delete.c b/mysys/my_delete.c
index 0655501aa16..c1a821e90c2 100644
--- a/mysys/my_delete.c
+++ b/mysys/my_delete.c
@@ -17,13 +17,23 @@
#include "mysys_err.h"
#include <my_sys.h>
+#ifdef _WIN32
+static int my_win_unlink(const char *name);
+#endif
+
int my_delete(const char *name, myf MyFlags)
{
int err;
DBUG_ENTER("my_delete");
DBUG_PRINT("my",("name %s MyFlags %lu", name, MyFlags));
- if ((err = unlink(name)) == -1)
+#ifdef _WIN32
+ err = my_win_unlink(name);
+#else
+ err = unlink(name);
+#endif
+
+ if(err)
{
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
@@ -36,90 +46,108 @@ int my_delete(const char *name, myf MyFlags)
DBUG_RETURN(err);
} /* my_delete */
-#if defined(__WIN__)
-/**
- 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.
+#if defined (_WIN32)
+/*
+ Delete file.
- @param the name of the being deleted file
- @param the flags instructing how to react on an error internally in
- the function
+ The function also makes best effort to minimize number of errors,
+ where another program (or thread in the current program) has the the same file
+ open.
- @note The per-thread @c my_errno holds additional info for a caller to
- decide how critical the error can be.
+ We're using 2 tricks to prevent the errors.
- @retval
- 0 ok
- @retval
- 1 error
+ 1. A usual Win32's DeleteFile() can with ERROR_SHARED_VIOLATION,
+ because the file is opened in another application (often, antivirus or backup)
+
+ We avoid the error by using CreateFile() with FILE_FLAG_DELETE_ON_CLOSE, instead
+ of DeleteFile()
+ 2. If file which is deleted (delete on close) but has not entirely gone,
+ because it is still opened by some app, an attempt to trcreate file with the
+ same name would result in yet another error. The workaround here is renaming
+ a file to unique name.
-*/
-int nt_share_delete(const char *name, myf MyFlags)
+ Symbolic link are deleted without renaming. Directories are not deleted.
+ */
+static int my_win_unlink(const char *name)
{
- 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--)
+ HANDLE handle= INVALID_HANDLE_VALUE;
+ DWORD attributes;
+ DWORD last_error;
+ char unique_filename[MAX_PATH + 35];
+ unsigned long long tsc; /* time stamp counter, for unique filename*/
+
+ DBUG_ENTER("my_win_unlink");
+ attributes= GetFileAttributes(name);
+ if (attributes == INVALID_FILE_ATTRIBUTES)
{
- errno= 0;
- sprintf(buf, "%s.%08X.deleted", name, cnt);
- if (MoveFile(name, buf))
- break;
-
- if ((errno= GetLastError()) == ERROR_ALREADY_EXISTS)
- continue;
-
- /* This happened during tests with MERGE tables. */
- if (errno == ERROR_ACCESS_DENIED)
- continue;
-
- DBUG_PRINT("warning", ("Failed to rename %s to %s, errno: %d",
- name, buf, errno));
- break;
+ last_error= GetLastError();
+ DBUG_PRINT("error",("GetFileAttributes(%s) failed with %u\n", name, last_error));
+ goto error;
}
- if (errno == ERROR_FILE_NOT_FOUND)
+ if (attributes & FILE_ATTRIBUTE_DIRECTORY)
{
- my_errno= ENOENT; // marking, that `name' doesn't exist
+ DBUG_PRINT("error",("can't remove %s - it is a directory\n", name));
+ errno= EINVAL;
+ DBUG_RETURN(-1);
}
- else if (errno == 0)
+
+ if (attributes & FILE_ATTRIBUTE_REPARSE_POINT)
+ {
+ /* Symbolic link. Delete link, the not target */
+ if (!DeleteFile(name))
+ {
+ last_error= GetLastError();
+ DBUG_PRINT("error",("DeleteFile(%s) failed with %u\n", name,last_error));
+ goto error;
+ }
+ DBUG_RETURN(0);
+ }
+
+ handle= CreateFile(name, DELETE, 0, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+ if (handle != INVALID_HANDLE_VALUE)
{
- if (DeleteFile(buf))
- DBUG_RETURN(0);
/*
- The below is more complicated than necessary. For some reason, the
- assignment to my_errno clears the error number, which is retrieved
- by GetLastError() (VC2005EE). Assigning to errno first, allows to
- retrieve the correct value.
+ We opened file without sharing flags (exclusive), noone else has this file
+ opened, thus it is save to close handle to remove it. No renaming is
+ necessary.
*/
- errno= GetLastError();
- if (errno == 0)
- my_errno= ENOENT; // marking, that `buf' doesn't exist
- else
- my_errno= errno;
+ CloseHandle(handle);
+ DBUG_RETURN(0);
+ }
+
+ /*
+ Can't open file exclusively, hence the file must be already opened by
+ someone else. Open it for delete (with all FILE_SHARE flags set),
+ rename to unique name, close.
+ */
+ handle= CreateFile(name, DELETE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+ if (handle == INVALID_HANDLE_VALUE)
+ {
+ last_error= GetLastError();
+ DBUG_PRINT("error",
+ ("CreateFile(%s) with FILE_FLAG_DELETE_ON_CLOSE failed with %u\n",
+ name,last_error));
+ goto error;
}
- else
- my_errno= errno;
- if (MyFlags & (MY_FAE+MY_WME))
- my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)),
- name, my_errno);
+ tsc= __rdtsc();
+ my_snprintf(unique_filename,sizeof(unique_filename),"%s.%llx.deleted",
+ name, tsc);
+ if (!MoveFile(name, unique_filename))
+ {
+ DBUG_PRINT("warning", ("moving %s to unique filename failed, error %u\n",
+ name,GetLastError()));
+ }
+
+ CloseHandle(handle);
+ DBUG_RETURN(0);
+
+error:
+ my_osmaperr(last_error);
DBUG_RETURN(-1);
}
-#endif
+#endif \ No newline at end of file
diff --git a/mysys/my_div.c b/mysys/my_div.c
index d29d3668852..29f04a7a01b 100644
--- a/mysys/my_div.c
+++ b/mysys/my_div.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 8a30dd6c10b..f1a4d078440 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
#include "my_static.h"
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 7905ad90877..0645e413672 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include <my_global.h>
#include <m_string.h>
diff --git a/mysys/my_getpagesize.c b/mysys/my_getpagesize.c
index b0560cede35..2c2804dfab8 100644
--- a/mysys/my_getpagesize.c
+++ b/mysys/my_getpagesize.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c
index 2a23a699f69..74289556262 100644
--- a/mysys/my_getsystime.c
+++ b/mysys/my_getsystime.c
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
diff --git a/mysys/my_libwrap.c b/mysys/my_libwrap.c
index e72334ba806..dea4bca114e 100644
--- a/mysys/my_libwrap.c
+++ b/mysys/my_libwrap.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
This is needed to be able to compile with original libwrap header
diff --git a/mysys/my_memmem.c b/mysys/my_memmem.c
index c000f14bc66..5184037ed39 100644
--- a/mysys/my_memmem.c
+++ b/mysys/my_memmem.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include <my_global.h>
#include <m_string.h>
diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c
index 676c6c1cd51..0e77180cd75 100644
--- a/mysys/my_mkdir.c
+++ b/mysys/my_mkdir.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "mysys_priv.h"
#include "mysys_err.h"
diff --git a/mysys/my_read.c b/mysys/my_read.c
index 66b7f6d353d..922da5a7e95 100644
--- a/mysys/my_read.c
+++ b/mysys/my_read.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -51,6 +51,13 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
#else
readbytes= read(Filedes, Buffer, Count);
#endif
+ DBUG_EXECUTE_IF ("simulate_file_read_error",
+ {
+ errno= ENOSPC;
+ readbytes= (size_t) -1;
+ DBUG_SET("-d,simulate_file_read_error");
+ DBUG_SET("-d,simulate_my_b_fill_error");
+ });
if (readbytes != Count)
{
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 3c68e69b46a..61e61b40791 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -58,7 +58,7 @@ int my_redel(const char *org_name, const char *tmp_name,
if (my_rename(org_name, name_buff, MyFlags))
goto end;
}
- else if (my_delete_allow_opened(org_name, MyFlags))
+ else if (my_delete(org_name, MyFlags))
goto end;
if (my_rename(tmp_name,org_name,MyFlags))
goto end;
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c
index bc7ac751fad..e8ac1dedec1 100644
--- a/mysys/my_symlink2.c
+++ b/mysys/my_symlink2.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
Advanced symlink handling.
diff --git a/mysys/test_dir.c b/mysys/test_dir.c
index 54e6c99e21e..0ac559568b1 100644
--- a/mysys/test_dir.c
+++ b/mysys/test_dir.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* TODO: Test all functions */
diff --git a/mysys/test_xml.c b/mysys/test_xml.c
index 0cb10e1c8d9..e5ff42ab2f5 100644
--- a/mysys/test_xml.c
+++ b/mysys/test_xml.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include <stdio.h>
#include <string.h>
diff --git a/mysys/typelib.c b/mysys/typelib.c
index a332adf6af5..75744a65ec8 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Functions to handle typelib */