1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
* @file Implementation of the AlterInfo class
25
#include "drizzled/server_includes.h"
26
#include "drizzled/alter_info.h"
27
#include "drizzled/alter_drop.h"
28
#include "drizzled/alter_column.h"
29
#include "drizzled/key.h"
30
#include "drizzled/create_field.h"
32
AlterInfo::AlterInfo() :
34
keys_onoff(LEAVE_AS_IS),
35
tablespace_op(NO_TABLESPACE_OP),
37
build_method(HA_BUILD_DEFAULT),
39
error_if_not_empty(false)
42
void AlterInfo::reset()
49
keys_onoff= LEAVE_AS_IS;
50
tablespace_op= NO_TABLESPACE_OP;
52
build_method= HA_BUILD_DEFAULT;
54
error_if_not_empty= false;
58
Construct a copy of this object to be used for mysql_alter_table
59
and mysql_create_table.
61
Historically, these two functions modify their AlterInfo
62
arguments. This behaviour breaks re-execution of prepared
63
statements and stored procedures and is compensated by always
64
supplying a copy of AlterInfo to these functions.
66
@return You need to use check the error in Session for out
67
of memory condition after calling this function.
69
AlterInfo::AlterInfo(const AlterInfo &rhs, MEM_ROOT *mem_root) :
70
drop_list(rhs.drop_list, mem_root),
71
alter_list(rhs.alter_list, mem_root),
72
key_list(rhs.key_list, mem_root),
73
create_list(rhs.create_list, mem_root),
75
keys_onoff(rhs.keys_onoff),
76
tablespace_op(rhs.tablespace_op),
77
no_parts(rhs.no_parts),
78
build_method(rhs.build_method),
79
datetime_field(rhs.datetime_field),
80
error_if_not_empty(rhs.error_if_not_empty)
83
Make deep copies of used objects.
84
This is not a fully deep copy - clone() implementations
85
of AlterDrop, AlterColumn, Key, foreign_key, Key_part_spec
86
do not copy string constants. At the same length the only
87
reason we make a copy currently is that ALTER/CREATE TABLE
88
code changes input AlterInfo definitions, but string
89
constants never change.
91
list_copy_and_replace_each_value(drop_list, mem_root);
92
list_copy_and_replace_each_value(alter_list, mem_root);
93
list_copy_and_replace_each_value(key_list, mem_root);
94
list_copy_and_replace_each_value(create_list, mem_root);