22 #include <plugin/show_dictionary/dictionary.h>
23 #include <drizzled/identifier.h>
24 #include <drizzled/message.h>
26 #include <google/protobuf/text_format.h>
27 #include <drizzled/plugin/authorization.h>
31 using namespace drizzled;
33 ShowCreateTable::ShowCreateTable() :
34 show_dictionary::Show(
"TABLE_SQL_DEFINITION")
36 add_field(
"TABLE_NAME", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
37 add_field(
"TABLE_SQL_DEFINITION", plugin::TableFunction::STRING, TABLE_FUNCTION_BLOB_SIZE,
false);
40 ShowCreateTable::Generator::Generator(
Field **arg) :
41 show_dictionary::Show::Generator(arg),
44 if (not isShowQuery())
49 if (not select.getShowTable().empty() && not select.getShowSchema().empty())
52 select.getShowSchema(),
53 select.getShowTable());
55 if (not plugin::Authorization::isAuthorized(*getSession().user(),
58 drizzled::error::access(*getSession().user(), identifier);
62 table_message= plugin::StorageEngine::getTableMessage(getSession(),
68 my_error(ER_BAD_TABLE_ERROR, identifier);
72 bool ShowCreateTable::Generator::populate()
74 enum drizzled::message::TransformSqlError transform_err;
79 std::string create_sql;
80 transform_err= message::transformTableDefinitionToSql(*table_message,
84 if (transform_err != drizzled::message::NONE)
89 push(table_message->name());