21
21
#include "config.h"
22
22
#include "plugin/show_dictionary/dictionary.h"
23
#include "drizzled/identifier.h"
23
#include "drizzled/table_identifier.h"
26
26
using namespace std;
27
27
using namespace drizzled;
29
29
static const string VARCHAR("VARCHAR");
30
/* VARBINARY already defined elsewhere */
31
static const string VARBIN("VARBINARY");
32
30
static const string DOUBLE("DOUBLE");
33
31
static const string BLOB("BLOB");
34
static const string TEXT("TEXT");
35
32
static const string ENUM("ENUM");
36
33
static const string INTEGER("INTEGER");
37
34
static const string BIGINT("BIGINT");
41
38
static const string DATETIME("DATETIME");
43
40
ShowColumns::ShowColumns() :
44
show_dictionary::Show("SHOW_COLUMNS")
41
plugin::TableFunction("DATA_DICTIONARY", "SHOW_COLUMNS")
46
43
add_field("Field");
48
add_field("Null", plugin::TableFunction::BOOLEAN, 0 , false);
45
add_field("Null", plugin::TableFunction::BOOLEAN);
49
46
add_field("Default");
50
add_field("Default_is_NULL", plugin::TableFunction::BOOLEAN, 0, false);
47
add_field("Default_is_NULL", plugin::TableFunction::BOOLEAN);
51
48
add_field("On_Update");
54
51
ShowColumns::Generator::Generator(Field **arg) :
55
show_dictionary::Show::Generator(arg),
52
plugin::TableFunction::Generator(arg),
56
53
is_tables_primed(false),
57
54
is_columns_primed(false),
60
if (not isShowQuery())
63
statement::Show *select= static_cast<statement::Show *>(getSession().lex->statement);
57
statement::Select *select= static_cast<statement::Select *>(getSession().lex->statement);
65
59
if (not select->getShowTable().empty() && not select->getShowSchema().empty())
67
61
table_name.append(select->getShowTable().c_str());
68
identifier::Table identifier(select->getShowSchema().c_str(), select->getShowTable().c_str());
62
TableIdentifier identifier(select->getShowSchema().c_str(), select->getShowTable().c_str());
70
64
is_tables_primed= plugin::StorageEngine::getTableDefinition(getSession(),
88
82
is_columns_primed= true;
91
if (column_iterator >= getTableProto()->field_size())
85
if (column_iterator >= getTableProto().field_size())
94
column= getTableProto()->field(column_iterator);
88
column= getTableProto().field(column_iterator);
121
void ShowColumns::Generator::pushType(message::Table::Field::FieldType type, const string collation)
115
void ShowColumns::Generator::pushType(message::Table::Field::FieldType type)
126
120
case message::Table::Field::VARCHAR:
127
push(collation.compare("binary") ? VARCHAR : VARBIN);
129
123
case message::Table::Field::DOUBLE:
132
126
case message::Table::Field::BLOB:
133
push(collation.compare("binary") ? TEXT : BLOB);
135
129
case message::Table::Field::ENUM:
163
157
push(column.name());
166
pushType(column.type(), column.string_options().collation());
160
pushType(column.type());
169
push(not column.constraints().is_notnull());
163
push(column.constraints().is_nullable());
172
if (column.options().has_default_value())
173
push(column.options().default_value());
174
else if (column.options().has_default_expression())
175
push(column.options().default_expression());
177
push(column.options().default_bin_value());
166
push(column.options().default_value());
179
168
/* Default_is_NULL */
180
169
push(column.options().default_null());
183
push(column.options().update_expression());
172
push(column.options().update_value());