1/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16/*
17 Rename a table
18*/
19
20#include "fulltext.h"
21
22int mi_rename(const char *old_name, const char *new_name)
23{
24 char from[FN_REFLEN],to[FN_REFLEN];
25 DBUG_ENTER("mi_rename");
26
27#ifdef EXTRA_DEBUG
28 check_table_is_closed(old_name,"rename old_table");
29 check_table_is_closed(new_name,"rename new table2");
30#endif
31
32 fn_format(from,old_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
33 fn_format(to,new_name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
34 if (mysql_file_rename_with_symlink(mi_key_file_kfile, from, to, MYF(MY_WME)))
35 DBUG_RETURN(my_errno);
36 fn_format(from,old_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
37 fn_format(to,new_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
38 DBUG_RETURN(mysql_file_rename_with_symlink(mi_key_file_dfile,
39 from, to,
40 MYF(MY_WME)) ? my_errno : 0);
41}
42