1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
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; either version 2 of the License, or
6
(at your option) any later version.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
23
int mi_rename(const char *old_name, const char *new_name)
25
char from[FN_REFLEN],to[FN_REFLEN];
27
uint raid_type=0,raid_chunks=0;
29
DBUG_ENTER("mi_rename");
32
check_table_is_closed(old_name,"rename old_table");
33
check_table_is_closed(new_name,"rename new table2");
38
if (!(info=mi_open(old_name, O_RDONLY, 0)))
39
DBUG_RETURN(my_errno);
40
raid_type = info->s->base.raid_type;
41
raid_chunks = info->s->base.raid_chunks;
45
check_table_is_closed(old_name,"rename raidcheck");
49
fn_format(from,old_name,"",MI_NAME_IEXT,4);
50
fn_format(to,new_name,"",MI_NAME_IEXT,4);
51
if (my_rename_with_symlink(from, to, MYF(MY_WME)))
52
DBUG_RETURN(my_errno);
53
fn_format(from,old_name,"",MI_NAME_DEXT,4);
54
fn_format(to,new_name,"",MI_NAME_DEXT,4);
57
DBUG_RETURN(my_raid_rename(from, to, raid_chunks, MYF(MY_WME)) ? my_errno :
60
DBUG_RETURN(my_rename_with_symlink(from, to,MYF(MY_WME)) ? my_errno : 0);