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/* drop and alter of tablespaces */
17
18#include "mariadb.h"
19#include "sql_priv.h"
20#include "unireg.h"
21#include "sql_tablespace.h"
22#include "sql_table.h" // write_bin_log
23#include "sql_class.h" // THD
24
25int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
26{
27 int error= HA_ADMIN_NOT_IMPLEMENTED;
28 handlerton *hton= ts_info->storage_engine;
29
30 DBUG_ENTER("mysql_alter_tablespace");
31 /*
32 If the user haven't defined an engine, this will fallback to using the
33 default storage engine.
34 */
35 if (hton == NULL || hton->state != SHOW_OPTION_YES)
36 {
37 hton= ha_default_handlerton(thd);
38 if (ts_info->storage_engine != 0)
39 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
40 ER_WARN_USING_OTHER_HANDLER,
41 ER_THD(thd, ER_WARN_USING_OTHER_HANDLER),
42 hton_name(hton)->str,
43 ts_info->tablespace_name ? ts_info->tablespace_name
44 : ts_info->logfile_group_name);
45 }
46
47 if (hton->alter_tablespace)
48 {
49 if (unlikely((error= hton->alter_tablespace(hton, thd, ts_info))))
50 {
51 if (error == 1)
52 DBUG_RETURN(1);
53
54 if (error == HA_ADMIN_NOT_IMPLEMENTED)
55 my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "");
56 else
57 my_error(error, MYF(0));
58
59 DBUG_RETURN(error);
60 }
61 }
62 else
63 {
64 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
65 ER_ILLEGAL_HA_CREATE_OPTION,
66 ER_THD(thd, ER_ILLEGAL_HA_CREATE_OPTION),
67 hton_name(hton)->str,
68 "TABLESPACE or LOGFILE GROUP");
69 }
70 error= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
71 DBUG_RETURN(error);
72}
73