22 #include <plugin/show_dictionary/dictionary.h>
23 #include <drizzled/identifier.h>
27 using namespace drizzled;
29 ShowColumns::ShowColumns() :
30 show_dictionary::Show(
"SHOW_COLUMNS")
34 add_field(
"Null", plugin::TableFunction::BOOLEAN, 0 ,
false);
36 add_field(
"Default_is_NULL", plugin::TableFunction::BOOLEAN, 0,
false);
37 add_field(
"On_Update");
40 ShowColumns::Generator::Generator(
Field **arg) :
41 show_dictionary::Show::Generator(arg),
42 is_tables_primed(false),
43 is_columns_primed(false),
46 if (not isShowQuery())
51 if (not select.getShowTable().empty() && not select.getShowSchema().empty())
53 table_name.append(select.getShowTable().c_str());
54 identifier::Table identifier(select.getShowSchema().c_str(), select.getShowTable().c_str());
56 if (not plugin::Authorization::isAuthorized(*getSession().user(),
59 drizzled::error::access(*getSession().user(), identifier);
63 table_proto= plugin::StorageEngine::getTableMessage(getSession(), identifier);
66 is_tables_primed=
true;
70 bool ShowColumns::Generator::nextColumnCore()
72 if (is_columns_primed)
78 if (not isTablesPrimed())
82 is_columns_primed=
true;
85 if (column_iterator >= getTableProto()->field_size())
88 column= getTableProto()->field(column_iterator);
94 bool ShowColumns::Generator::nextColumn()
96 while (not nextColumnCore())
104 bool ShowColumns::Generator::populate()
107 if (not nextColumn())
116 void ShowColumns::Generator::fill()
122 push(drizzled::message::type(column));
125 push(not column.constraints().is_notnull());
128 if (column.options().has_default_value())
129 push(column.options().default_value());
130 else if (column.options().has_default_expression())
131 push(column.options().default_expression());
133 push(column.options().default_bin_value());
136 push(column.options().default_null());
139 push(column.options().update_expression());