~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to sql/sql_tablespace.cc

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000-2004 MySQL 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; 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/* drop and alter of tablespaces */
 
17
 
 
18
#include "mysql_priv.h"
 
19
 
 
20
int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
 
21
{
 
22
  int error= HA_ADMIN_NOT_IMPLEMENTED;
 
23
  handlerton *hton= ts_info->storage_engine;
 
24
 
 
25
  DBUG_ENTER("mysql_alter_tablespace");
 
26
  /*
 
27
    If the user haven't defined an engine, this will fallback to using the
 
28
    default storage engine.
 
29
  */
 
30
  if (hton == NULL || hton->state != SHOW_OPTION_YES)
 
31
  {
 
32
    hton= ha_default_handlerton(thd);
 
33
    if (ts_info->storage_engine != 0)
 
34
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
 
35
                          ER_WARN_USING_OTHER_HANDLER,
 
36
                          ER(ER_WARN_USING_OTHER_HANDLER),
 
37
                          ha_resolve_storage_engine_name(hton),
 
38
                          ts_info->tablespace_name ? ts_info->tablespace_name
 
39
                                                : ts_info->logfile_group_name);
 
40
  }
 
41
 
 
42
  if (hton->alter_tablespace)
 
43
  {
 
44
    if ((error= hton->alter_tablespace(hton, thd, ts_info)))
 
45
    {
 
46
      if (error == HA_ADMIN_NOT_IMPLEMENTED)
 
47
      {
 
48
        my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "");
 
49
      }
 
50
      else if (error == 1)
 
51
      {
 
52
        DBUG_RETURN(1);
 
53
      }
 
54
      else
 
55
      {
 
56
        my_error(error, MYF(0));
 
57
      }
 
58
      DBUG_RETURN(error);
 
59
    }
 
60
  }
 
61
  else
 
62
  {
 
63
    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
 
64
                        ER_ILLEGAL_HA_CREATE_OPTION,
 
65
                        ER(ER_ILLEGAL_HA_CREATE_OPTION),
 
66
                        ha_resolve_storage_engine_name(hton),
 
67
                        "TABLESPACE or LOGFILE GROUP");
 
68
  }
 
69
  error= write_bin_log(thd, FALSE, thd->query(), thd->query_length());
 
70
  DBUG_RETURN(error);
 
71
}