1 /* Copyright (c) 2000, 2017, 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, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23 /*
24 deletes a table
25 */
26
27 #include "fulltext.h"
28
mi_delete_table(const char * name)29 int mi_delete_table(const char *name)
30 {
31 char from[FN_REFLEN];
32 DBUG_ENTER("mi_delete_table");
33
34 #ifdef EXTRA_DEBUG
35 check_table_is_closed(name,"delete");
36 #endif
37
38 fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
39 if (my_is_symlink(from, NULL) && (*myisam_test_invalid_symlink)(from))
40 {
41 /*
42 Symlink is pointing to file in data directory.
43 Remove symlink, keep file.
44 */
45 if (mysql_file_delete(mi_key_file_kfile, from, MYF(MY_WME)))
46 DBUG_RETURN(my_errno);
47 }
48 else
49 {
50 if (mysql_file_delete_with_symlink(mi_key_file_kfile, from, MYF(MY_WME)))
51 DBUG_RETURN(my_errno);
52 }
53 fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
54 if (my_is_symlink(from, NULL) && (*myisam_test_invalid_symlink)(from))
55 {
56 /*
57 Symlink is pointing to file in data directory.
58 Remove symlink, keep file.
59 */
60 if (mysql_file_delete(mi_key_file_dfile, from, MYF(MY_WME)))
61 DBUG_RETURN(my_errno);
62 }
63 else
64 {
65 if (mysql_file_delete_with_symlink(mi_key_file_dfile, from, MYF(MY_WME)))
66 DBUG_RETURN(my_errno);
67 }
68 DBUG_RETURN(0);
69 }
70