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 #include <drizzled/message/table.h>
00024 #include <drizzled/charset.h>
00025 #include <drizzled/catalog/local.h>
00026
00027 namespace drizzled {
00028 namespace message {
00029 namespace table {
00030
00031 shared_ptr make_shared(const identifier::Table& identifier, const std::string &engine_arg)
00032 {
00033 shared_ptr shared(new message::Table);
00034
00035 init(*shared, identifier.getTableName(), identifier.getSchemaName(), engine_arg);
00036
00037 return shared;
00038 }
00039
00040 shared_ptr make_shared(const std::string &name_arg, const std::string &schema_arg, const std::string &engine_arg)
00041 {
00042 shared_ptr shared(new message::Table);
00043
00044 init(*shared, name_arg, schema_arg, engine_arg);
00045
00046 return shared;
00047 }
00048
00049 void init(drizzled::message::Table &arg, const std::string &name_arg, const std::string &schema_arg, const std::string &engine_arg)
00050 {
00051 arg.set_name(name_arg);
00052 arg.set_schema(schema_arg);
00053 arg.set_creation_timestamp(time(NULL));
00054 arg.set_update_timestamp(time(NULL));
00055 arg.mutable_engine()->set_name(engine_arg);
00056
00057
00058 uuid_t uu;
00059 char uuid_string[37];
00060 uuid_generate_random(uu);
00061 uuid_unparse(uu, uuid_string);
00062 arg.set_uuid(uuid_string, 36);
00063
00064 arg.set_version(1);
00065
00066 if (not arg.has_type())
00067 {
00068 arg.set_type(drizzled::message::Table::STANDARD);
00069 }
00070
00071 arg.mutable_options()->set_collation_id(default_charset_info->number);
00072 arg.mutable_options()->set_collation(default_charset_info->name);
00073
00074 arg.set_catalog(drizzled::catalog::local()->name());
00075 }
00076
00077 void update(drizzled::message::Table &arg)
00078 {
00079 arg.set_version(arg.version() + 1);
00080 arg.set_update_timestamp(time(NULL));
00081 }
00082
00083 }
00084 }
00085 }