diff options
author | Satya B <satya.bn@sun.com> | 2009-07-27 11:50:13 +0530 |
---|---|---|
committer | Satya B <satya.bn@sun.com> | 2009-07-27 11:50:13 +0530 |
commit | 2478d51032fbbf5123bdd6d25afceef9ee03f88a (patch) | |
tree | 79be006349537719c9e628bbca7dc66073647aa6 /sql/handler.cc | |
parent | 30441aeadf28f053a75b58ec4c46d25dadc2ba97 (diff) | |
parent | cf505e4494e86e09ce2c83af4dfe9f434eacb88c (diff) | |
download | mariadb-git-2478d51032fbbf5123bdd6d25afceef9ee03f88a.tar.gz |
merging with mysql-5.1-bugteam branch
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index d9e8f5614f2..cfc3de1d889 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2977,6 +2977,7 @@ uint handler::get_dup_key(int error) */ int handler::delete_table(const char *name) { + int saved_error= 0; int error= 0; int enoent_or_zero= ENOENT; // Error if no file was deleted char buff[FN_REFLEN]; @@ -2986,21 +2987,31 @@ int handler::delete_table(const char *name) fn_format(buff, name, "", *ext, MY_UNPACK_FILENAME|MY_APPEND_EXT); if (my_delete_with_symlink(buff, MYF(0))) { - if ((error= my_errno) != ENOENT) - break; + if (my_errno != ENOENT) + { + /* + If error on the first existing file, return the error. + Otherwise delete as much as possible. + */ + if (enoent_or_zero) + return my_errno; + saved_error= my_errno; + } } else enoent_or_zero= 0; // No error for ENOENT error= enoent_or_zero; } - return error; + return saved_error ? saved_error : error; } int handler::rename_table(const char * from, const char * to) { int error= 0; - for (const char **ext= bas_ext(); *ext ; ext++) + const char **ext, **start_ext; + start_ext= bas_ext(); + for (ext= start_ext; *ext ; ext++) { if (rename_file_ext(from, to, *ext)) { @@ -3009,6 +3020,12 @@ int handler::rename_table(const char * from, const char * to) error= 0; } } + if (error) + { + /* Try to revert the rename. Ignore errors. */ + for (; ext >= start_ext; ext--) + rename_file_ext(to, from, *ext); + } return error; } |