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());
52 if (not plugin::Authorization::isAuthorized(*getSession().user(),
55 drizzled::error::access(*getSession().user(), identifier);
59 schema_message= plugin::StorageEngine::getSchemaDefinition(identifier);
61 if_not_exists= select.getShowExists();
65 bool ShowCreateSchema::Generator::populate()
67 if (not schema_message)
74 buffer.append(
"CREATE DATABASE ");
77 buffer.append(
"IF NOT EXISTS ");
80 buffer.append(schema_message->name());
83 if (schema_message->has_collation())
85 buffer.append(
" COLLATE = ");
86 buffer.append(schema_message->collation());
89 if (not message::is_replicated(*schema_message))
91 buffer.append(
" REPLICATE = FALSE");
95 push(schema_message->name());
98 schema_message.reset();