MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mi_delete_table.c
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  deletes a table
18 */
19 
20 #include "fulltext.h"
21 
22 int mi_delete_table(const char *name)
23 {
24  char from[FN_REFLEN];
25  DBUG_ENTER("mi_delete_table");
26 
27 #ifdef EXTRA_DEBUG
28  check_table_is_closed(name,"delete");
29 #endif
30 
31  fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
32  if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
33  {
34  /*
35  Symlink is pointing to file in data directory.
36  Remove symlink, keep file.
37  */
38  if (mysql_file_delete(mi_key_file_kfile, from, MYF(MY_WME)))
39  DBUG_RETURN(my_errno);
40  }
41  else
42  {
43  if (mysql_file_delete_with_symlink(mi_key_file_kfile, from, MYF(MY_WME)))
44  DBUG_RETURN(my_errno);
45  }
46  fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
47  if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
48  {
49  /*
50  Symlink is pointing to file in data directory.
51  Remove symlink, keep file.
52  */
53  if (mysql_file_delete(mi_key_file_dfile, from, MYF(MY_WME)))
54  DBUG_RETURN(my_errno);
55  }
56  else
57  {
58  if (mysql_file_delete_with_symlink(mi_key_file_dfile, from, MYF(MY_WME)))
59  DBUG_RETURN(my_errno);
60  }
61  DBUG_RETURN(0);
62 }