22#include <plugin/show_dictionary/dictionary.h>
23#include <drizzled/identifier.h>
29ShowColumns::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");
40ShowColumns::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(getSession().catalog().identifier(),
55 select.getShowSchema().c_str(),
56 select.getShowTable().c_str());
58 if (not plugin::Authorization::isAuthorized(*getSession().user(),
61 drizzled::error::access(*getSession().user(), identifier);
65 table_proto= plugin::StorageEngine::getTableMessage(getSession(), identifier);
68 is_tables_primed=
true;
72bool ShowColumns::Generator::nextColumnCore()
74 if (is_columns_primed)
80 if (not isTablesPrimed())
84 is_columns_primed=
true;
87 if (column_iterator >= getTableProto()->field_size())
90 column= getTableProto()->field(column_iterator);
96bool ShowColumns::Generator::nextColumn()
98 while (not nextColumnCore())
106bool ShowColumns::Generator::populate()
109 if (not nextColumn())
118void ShowColumns::Generator::fill()
124 push(drizzled::message::type(column));
127 push(not column.constraints().is_notnull());
130 if (column.options().has_default_value())
131 push(column.options().default_value());
132 else if (column.options().has_default_expression())
133 push(column.options().default_expression());
135 push(column.options().default_bin_value());
138 push(column.options().default_null());
141 push(column.options().update_expression());
TODO: Rename this file - func.h is stupid.