MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sql_tablespace.cc
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 Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 /* drop and alter of tablespaces */
17 
18 #include "sql_priv.h"
19 #include "unireg.h"
20 #include "sql_tablespace.h"
21 #include "sql_table.h" // write_bin_log
22 #include "sql_class.h" // THD
23 
24 int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
25 {
26  int error= HA_ADMIN_NOT_IMPLEMENTED;
27  handlerton *hton= ts_info->storage_engine;
28 
29  DBUG_ENTER("mysql_alter_tablespace");
30  /*
31  If the user haven't defined an engine, this will fallback to using the
32  default storage engine.
33  */
34  if (hton == NULL || hton->state != SHOW_OPTION_YES)
35  {
36  hton= ha_default_handlerton(thd);
37  if (ts_info->storage_engine != 0)
38  push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
39  ER_WARN_USING_OTHER_HANDLER,
40  ER(ER_WARN_USING_OTHER_HANDLER),
41  ha_resolve_storage_engine_name(hton),
42  ts_info->tablespace_name ? ts_info->tablespace_name
43  : ts_info->logfile_group_name);
44  }
45 
46  if (hton->alter_tablespace)
47  {
48  if ((error= hton->alter_tablespace(hton, thd, ts_info)))
49  {
50  if (error == HA_ADMIN_NOT_IMPLEMENTED)
51  {
52  my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "");
53  }
54  else if (error == 1)
55  {
56  DBUG_RETURN(1);
57  }
58  else
59  {
60  my_error(error, MYF(0));
61  }
62  DBUG_RETURN(error);
63  }
64  }
65  else
66  {
67  my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
68  ha_resolve_storage_engine_name(hton),
69  "TABLESPACE or LOGFILE GROUP");
70  DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
71  }
72  error= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
73  DBUG_RETURN(error);
74 }