00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include <uuid/uuid.h>
00025
00026 #include <drizzled/show.h>
00027 #include <drizzled/message/schema.h>
00028 #include <drizzled/session.h>
00029 #include <drizzled/charset_info.h>
00030
00031 #include <drizzled/catalog/local.h>
00032
00033 namespace drizzled {
00034 namespace message {
00035 namespace schema {
00036
00037 shared_ptr make_shared(identifier::Schema::const_reference identifier)
00038 {
00039 shared_ptr shared(new message::Schema);
00040
00041 init(*shared, identifier.getSchemaName());
00042
00043 return shared;
00044 }
00045
00046 shared_ptr make_shared(const std::string &name_arg)
00047 {
00048 shared_ptr shared(new message::Schema);
00049
00050 init(*shared, name_arg);
00051
00052 return shared;
00053 }
00054
00055 void init(drizzled::message::Schema &arg, const std::string &name_arg)
00056 {
00057 arg.set_name(name_arg);
00058 arg.set_catalog(drizzled::catalog::local()->name());
00059 arg.mutable_engine()->set_name(std::string("filesystem"));
00060 arg.set_creation_timestamp(time(NULL));
00061 arg.set_update_timestamp(time(NULL));
00062 if (not arg.has_collation())
00063 {
00064 arg.set_collation(default_charset_info->name);
00065 }
00066
00067
00068 uuid_t uu;
00069 char uuid_string[37];
00070 uuid_generate_random(uu);
00071 uuid_unparse(uu, uuid_string);
00072 arg.set_uuid(uuid_string, 36);
00073
00074 arg.set_version(1);
00075 }
00076
00077 }
00078 }
00079 }