00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/util/string.h>
00024 #include <drizzled/session/table_messages.h>
00025 #include <drizzled/identifier.h>
00026 #include <drizzled/message/table.h>
00027 #include <drizzled/util/find_ptr.h>
00028 #include <string>
00029
00030 namespace drizzled {
00031 namespace session {
00032
00033 bool TableMessages::storeTableMessage(const identifier::Table &identifier, const message::Table &table_message)
00034 {
00035 table_message_cache.insert(make_pair(identifier.getPath(), table_message));
00036 return true;
00037 }
00038
00039 bool TableMessages::removeTableMessage(const identifier::Table &identifier)
00040 {
00041 Cache::iterator iter= table_message_cache.find(identifier.getPath());
00042 if (iter == table_message_cache.end())
00043 return false;
00044 table_message_cache.erase(iter);
00045 return true;
00046 }
00047
00048 bool TableMessages::getTableMessage(const identifier::Table &identifier, message::Table &table_message)
00049 {
00050 Cache::mapped_type* ptr= find_ptr(table_message_cache, identifier.getPath());
00051 if (!ptr)
00052 return false;
00053 table_message.CopyFrom(*ptr);
00054 return true;
00055 }
00056
00057 bool TableMessages::doesTableMessageExist(const identifier::Table &identifier)
00058 {
00059 return find_ptr(table_message_cache, identifier.getPath());
00060 }
00061
00062 bool TableMessages::renameTableMessage(const identifier::Table &from, const identifier::Table &to)
00063 {
00064 table_message_cache[to.getPath()]= table_message_cache[from.getPath()];
00065 Cache::mapped_type* ptr= find_ptr(table_message_cache, to.getPath());
00066 if (!ptr)
00067 return false;
00068 ptr->set_schema(to.getSchemaName());
00069 ptr->set_name(to.getTableName());
00070 return true;
00071 }
00072
00073 }
00074 }