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())
53 if (not plugin::Authorization::isAuthorized(*getSession().user(),
56 drizzled::error::access(*getSession().user(), identifier);
60 table_message= plugin::StorageEngine::getTableMessage(getSession(),
66 my_error(ER_BAD_TABLE_ERROR, identifier);
70 bool ShowCreateTable::Generator::populate()
72 enum drizzled::message::TransformSqlError transform_err;
77 std::string create_sql;
78 transform_err= message::transformTableDefinitionToSql(*table_message,
82 if (transform_err != drizzled::message::NONE)
87 push(table_message->name());