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