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"
23
#include "drizzled/table_identifier.h"
26
using namespace drizzled;
28
static const string STANDARD("STANDARD");
29
static const string TEMPORARY("TEMPORARY");
30
static const string INTERNAL("INTERNAL");
31
static const string FUNCTION("FUNCTION");
33
static const string DEFAULT("DEFAULT");
34
static const string FIXED("FIXED");
35
static const string DYNAMIC("DYNAMIC");
36
static const string COMPRESSED("COMPRESSED");
37
static const string REDUNDANT("REDUNDANT");
38
static const string COMPACT("COMPACT");
39
static const string PAGE("PAGE");
41
static const string VARCHAR("VARCHAR");
42
static const string DOUBLE("DOUBLE");
43
static const string BLOB("BLOB");
44
static const string ENUM("ENUM");
45
static const string INTEGER("INTEGER");
46
static const string BIGINT("BIGINT");
47
static const string DECIMAL("DECIMAL");
48
static const string DATE("DATE");
49
static const string TIMESTAMP("TIMESTAMP");
50
static const string DATETIME("DATETIME");
52
TablesTool::TablesTool() :
55
add_field("TABLE_SCHEMA");
56
add_field("TABLE_NAME");
57
add_field("TABLE_TYPE");
59
add_field("ROW_FORMAT", 10);
60
add_field("TABLE_COLLATION");
61
add_field("TABLE_COMMENT", 2048);
64
TablesTool::Generator::Generator(Field **arg) :
65
SchemasTool::Generator(arg),
66
is_tables_primed(false)
70
bool TablesTool::Generator::nextTableCore()
78
if (not isSchemaPrimed())
82
plugin::StorageEngine::getTableNames(schema_name(), table_names);
83
table_iterator= table_names.begin();
84
is_tables_primed= true;
87
if (table_iterator == table_names.end())
92
Session *session= current_session;
94
build_table_filename(path, sizeof(path), schema_name().c_str(), table_name().c_str(), false);
95
plugin::StorageEngine::getTableDefinition(*session,
97
schema_name().c_str(),
103
if (checkTableName())
109
bool TablesTool::Generator::nextTable()
111
while (not nextTableCore())
114
if (is_tables_primed && table_iterator != table_names.end())
117
if (not nextSchema())
119
is_tables_primed= false;
125
bool TablesTool::Generator::checkTableName()
127
if (isWild(table_name()))
130
if (not table_predicate.empty() && table_predicate.compare(table_name()))
136
bool TablesTool::Generator::populate()
146
void TablesTool::Generator::pushRow(message::Table::TableOptions::RowType type)
151
case message::Table::TableOptions::ROW_TYPE_DEFAULT:
154
case message::Table::TableOptions::ROW_TYPE_FIXED:
157
case message::Table::TableOptions::ROW_TYPE_DYNAMIC:
160
case message::Table::TableOptions::ROW_TYPE_COMPRESSED:
163
case message::Table::TableOptions::ROW_TYPE_REDUNDANT:
166
case message::Table::TableOptions::ROW_TYPE_COMPACT:
169
case message::Table::TableOptions::ROW_TYPE_PAGE:
175
void TablesTool::Generator::pushType(message::Table::Field::FieldType type)
180
case message::Table::Field::VARCHAR:
183
case message::Table::Field::DOUBLE:
186
case message::Table::Field::BLOB:
189
case message::Table::Field::ENUM:
192
case message::Table::Field::INTEGER:
195
case message::Table::Field::BIGINT:
198
case message::Table::Field::DECIMAL:
201
case message::Table::Field::DATE:
204
case message::Table::Field::TIMESTAMP:
207
case message::Table::Field::DATETIME:
213
void TablesTool::Generator::fill()
224
switch (table_proto.type())
227
case message::Table::STANDARD:
230
case message::Table::TEMPORARY:
233
case message::Table::INTERNAL:
236
case message::Table::FUNCTION:
243
push(table_proto.engine().name());
246
pushRow(table_proto.options().row_type());
248
/* TABLE_COLLATION */
249
push(table_proto.options().collation());
252
push(table_proto.options().comment());
255
bool ShowTables::Generator::checkSchema()
257
Session *session= current_session;
259
if (session->lex->select_lex.db)
261
return schema_name().compare(session->lex->select_lex.db);
263
return session->db.compare(schema_name());