~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to myisam/mi_rename.c

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
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; either version 2 of the License, or
 
6
   (at your option) any later version.
 
7
 
 
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.
 
12
 
 
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 */
 
16
 
 
17
/*
 
18
  Rename a table
 
19
*/
 
20
 
 
21
#include "fulltext.h"
 
22
 
 
23
int mi_rename(const char *old_name, const char *new_name)
 
24
{
 
25
  char from[FN_REFLEN],to[FN_REFLEN];
 
26
#ifdef USE_RAID
 
27
  uint raid_type=0,raid_chunks=0;
 
28
#endif
 
29
  DBUG_ENTER("mi_rename");
 
30
 
 
31
#ifdef EXTRA_DEBUG
 
32
  check_table_is_closed(old_name,"rename old_table");
 
33
  check_table_is_closed(new_name,"rename new table2");
 
34
#endif
 
35
#ifdef USE_RAID
 
36
  {
 
37
    MI_INFO *info;
 
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;
 
42
    mi_close(info);
 
43
  }
 
44
#ifdef EXTRA_DEBUG
 
45
  check_table_is_closed(old_name,"rename raidcheck");
 
46
#endif
 
47
#endif /* USE_RAID */
 
48
 
 
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);
 
55
#ifdef USE_RAID
 
56
  if (raid_type)
 
57
    DBUG_RETURN(my_raid_rename(from, to, raid_chunks, MYF(MY_WME)) ? my_errno :
 
58
                0);
 
59
#endif
 
60
  DBUG_RETURN(my_rename_with_symlink(from, to,MYF(MY_WME)) ? my_errno : 0);
 
61
}