1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
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"
27
using namespace drizzled;
29
static const string VARCHAR("VARCHAR");
30
static const string DOUBLE("DOUBLE");
31
static const string BLOB("BLOB");
32
static const string ENUM("ENUM");
33
static const string INTEGER("INTEGER");
34
static const string BIGINT("BIGINT");
35
static const string DECIMAL("DECIMAL");
36
static const string DATE("DATE");
37
static const string TIMESTAMP("TIMESTAMP");
38
static const string DATETIME("DATETIME");
40
ShowColumns::ShowColumns() :
41
plugin::TableFunction("DATA_DICTIONARY", "SHOW_COLUMNS")
45
add_field("Null", plugin::TableFunction::BOOLEAN);
47
add_field("Default_is_NULL", plugin::TableFunction::BOOLEAN);
48
add_field("On_Update");
51
ShowColumns::Generator::Generator(Field **arg) :
52
plugin::TableFunction::Generator(arg),
53
is_tables_primed(false),
54
is_columns_primed(false),
57
Session *session= current_session;
58
statement::Select *select= static_cast<statement::Select *>(session->lex->statement);
60
table_name.append(select->getShowTable().c_str());
61
TableIdentifier identifier(select->getShowSchema().c_str(), select->getShowTable().c_str());
63
is_tables_primed= plugin::StorageEngine::getTableDefinition(*session,
68
bool ShowColumns::Generator::nextColumnCore()
70
if (is_columns_primed)
76
if (not isTablesPrimed())
80
is_columns_primed= true;
83
if (column_iterator >= getTableProto().field_size())
86
column= getTableProto().field(column_iterator);
92
bool ShowColumns::Generator::nextColumn()
94
while (not nextColumnCore())
102
bool ShowColumns::Generator::populate()
105
if (not nextColumn())
113
void ShowColumns::Generator::pushType(message::Table::Field::FieldType type)
118
case message::Table::Field::VARCHAR:
121
case message::Table::Field::DOUBLE:
124
case message::Table::Field::BLOB:
127
case message::Table::Field::ENUM:
130
case message::Table::Field::INTEGER:
133
case message::Table::Field::BIGINT:
136
case message::Table::Field::DECIMAL:
139
case message::Table::Field::DATE:
142
case message::Table::Field::TIMESTAMP:
145
case message::Table::Field::DATETIME:
152
void ShowColumns::Generator::fill()
158
pushType(column.type());
161
push(column.constraints().is_nullable());
164
push(column.options().default_value());
166
/* Default_is_NULL */
167
push(column.options().default_null());
170
push(column.options().update_value());