~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/alter_info.cc

Reworked getTableNames() interface. Way simpler, less mallocs....

Added a straight vector<> for use with storage engines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
22
22
 * @file Implementation of the AlterInfo class
23
23
 */
24
24
 
25
 
#include "config.h"
 
25
#include "drizzled/server_includes.h"
26
26
#include "drizzled/alter_info.h"
27
27
#include "drizzled/alter_drop.h"
28
28
#include "drizzled/alter_column.h"
29
29
#include "drizzled/key.h"
30
30
#include "drizzled/create_field.h"
31
31
 
32
 
namespace drizzled
33
 
{
34
 
 
35
32
AlterInfo::AlterInfo() :
36
33
  flags(),
37
34
  keys_onoff(LEAVE_AS_IS),
38
35
  tablespace_op(NO_TABLESPACE_OP),
39
36
  no_parts(0),
40
37
  build_method(HA_BUILD_DEFAULT),
 
38
  datetime_field(NULL),
41
39
  error_if_not_empty(false)
42
40
{}
43
41
 
44
 
} /* namespace drizzled */
 
42
void AlterInfo::reset()
 
43
{
 
44
  drop_list.empty();
 
45
  alter_list.empty();
 
46
  key_list.empty();
 
47
  create_list.empty();
 
48
  flags.reset();
 
49
  keys_onoff= LEAVE_AS_IS;
 
50
  tablespace_op= NO_TABLESPACE_OP;
 
51
  no_parts= 0;
 
52
  build_method= HA_BUILD_DEFAULT;
 
53
  datetime_field= 0;
 
54
  error_if_not_empty= false;
 
55
}
 
56
 
 
57
/**
 
58
  Construct a copy of this object to be used for mysql_alter_table
 
59
  and mysql_create_table.
 
60
 
 
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.
 
65
 
 
66
  @return You need to use check the error in Session for out
 
67
  of memory condition after calling this function.
 
68
*/
 
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),
 
74
  flags(rhs.flags),
 
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)
 
81
{
 
82
  /*
 
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.
 
90
  */
 
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);
 
95
}