1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 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
#include "plugin/schema_dictionary/dictionary.h"
26
extern size_t build_table_filename(char *buff,
29
const char *table_name,
34
using namespace drizzled;
36
static const string STANDARD("STANDARD");
37
static const string TEMPORARY("TEMPORARY");
38
static const string INTERNAL("INTERNAL");
39
static const string FUNCTION("FUNCTION");
41
static const string DEFAULT("DEFAULT");
42
static const string FIXED("FIXED");
43
static const string DYNAMIC("DYNAMIC");
44
static const string COMPRESSED("COMPRESSED");
45
static const string REDUNDANT("REDUNDANT");
46
static const string COMPACT("COMPACT");
47
static const string PAGE("PAGE");
50
TablesTool::TablesTool() :
53
add_field("TABLE_SCHEMA");
54
add_field("TABLE_NAME");
55
add_field("TABLE_TYPE");
57
add_field("ROW_FORMAT", 10);
58
add_field("TABLE_COLLATION");
59
add_field("TABLE_COMMENT", 2048);
62
TablesTool::Generator::Generator(Field **arg) :
63
SchemasTool::Generator(arg),
64
is_tables_primed(false)
68
bool TablesTool::Generator::nextTableCore()
76
if (not isSchemaPrimed())
80
plugin::StorageEngine::getTableNames(schema_name(), table_names);
81
table_iterator= table_names.begin();
82
is_tables_primed= true;
85
if (table_iterator == table_names.end())
90
Session *session= current_session;
92
build_table_filename(path, sizeof(path), schema_name().c_str(), table_name().c_str(), false);
93
plugin::StorageEngine::getTableDefinition(*session,
95
schema_name().c_str(),
101
if (checkTableName())
107
bool TablesTool::Generator::nextTable()
109
while (not nextTableCore())
112
if (is_tables_primed && table_iterator != table_names.end())
115
if (not nextSchema())
117
is_tables_primed= false;
123
bool TablesTool::Generator::checkTableName()
125
return isWild(table_name());
128
bool TablesTool::Generator::populate()
138
void TablesTool::Generator::pushRow(message::Table::TableOptions::RowType type)
143
case message::Table::TableOptions::ROW_TYPE_DEFAULT:
146
case message::Table::TableOptions::ROW_TYPE_FIXED:
149
case message::Table::TableOptions::ROW_TYPE_DYNAMIC:
152
case message::Table::TableOptions::ROW_TYPE_COMPRESSED:
155
case message::Table::TableOptions::ROW_TYPE_REDUNDANT:
158
case message::Table::TableOptions::ROW_TYPE_COMPACT:
161
case message::Table::TableOptions::ROW_TYPE_PAGE:
167
void TablesTool::Generator::fill()
178
switch (table_proto.type())
181
case message::Table::STANDARD:
184
case message::Table::TEMPORARY:
187
case message::Table::INTERNAL:
190
case message::Table::FUNCTION:
197
push(table_proto.engine().name());
200
pushRow(table_proto.options().row_type());
202
/* TABLE_COLLATION */
203
push(table_proto.options().collation());
206
push(table_proto.options().comment());
209
bool TableNames::Generator::checkSchema()
211
Session *session= current_session;
213
if (session->lex->select_lex.db)
215
return schema_name().compare(session->lex->select_lex.db);
217
return session->db.compare(schema_name());