22 #include <plugin/show_dictionary/dictionary.h>
23 #include <drizzled/identifier.h>
24 #include <drizzled/message.h>
29 using namespace drizzled;
31 ShowCreateSchema::ShowCreateSchema() :
32 show_dictionary::Show(
"SCHEMA_SQL_DEFINITION")
34 add_field(
"SCHEMA_NAME", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
35 add_field(
"SCHEMA_SQL_DEFINITION", plugin::TableFunction::STRING, TABLE_FUNCTION_BLOB_SIZE,
false);
38 ShowCreateSchema::Generator::Generator(
Field **arg) :
39 show_dictionary::Show::Generator(arg),
42 if (not isShowQuery())
47 if (not select.getShowSchema().empty())
49 schema_name.append(select.getShowTable());
51 select.getShowSchema());
53 if (not plugin::Authorization::isAuthorized(*getSession().user(),
56 drizzled::error::access(*getSession().user(), identifier);
60 schema_message= plugin::StorageEngine::getSchemaDefinition(identifier);
62 if_not_exists= select.getShowExists();
66 bool ShowCreateSchema::Generator::populate()
68 if (not schema_message)
75 buffer.append(
"CREATE DATABASE ");
78 buffer.append(
"IF NOT EXISTS ");
81 buffer.append(schema_message->name());
84 if (schema_message->has_collation())
86 buffer.append(
" COLLATE = ");
87 buffer.append(schema_message->collation());
90 if (not message::is_replicated(*schema_message))
92 buffer.append(
" REPLICATE = FALSE");
96 push(schema_message->name());
99 schema_message.reset();