~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session/table_messages.cc

update

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/session/table_messages.h>
25
25
#include <drizzled/identifier.h>
26
26
#include <drizzled/message/table.h>
27
 
 
 
27
#include <drizzled/util/find_ptr.h>
28
28
#include <string>
29
29
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
namespace session
34
 
{
 
30
namespace drizzled {
 
31
namespace session {
35
32
 
36
33
bool TableMessages::storeTableMessage(const identifier::Table &identifier, message::Table &table_message)
37
34
{
38
35
  table_message_cache.insert(make_pair(identifier.getPath(), table_message));
39
 
 
40
36
  return true;
41
37
}
42
38
 
43
39
bool TableMessages::removeTableMessage(const identifier::Table &identifier)
44
40
{
45
 
  Cache::iterator iter;
46
 
 
47
 
  iter= table_message_cache.find(identifier.getPath());
48
 
 
 
41
  Cache::iterator iter= table_message_cache.find(identifier.getPath());
49
42
  if (iter == table_message_cache.end())
50
43
    return false;
51
 
 
52
44
  table_message_cache.erase(iter);
53
 
 
54
45
  return true;
55
46
}
56
47
 
57
48
bool TableMessages::getTableMessage(const identifier::Table &identifier, message::Table &table_message)
58
49
{
59
 
  Cache::iterator iter;
60
 
 
61
 
  iter= table_message_cache.find(identifier.getPath());
62
 
 
63
 
  if (iter == table_message_cache.end())
 
50
  Cache::mapped_type* ptr= find_ptr(table_message_cache, identifier.getPath());
 
51
  if (!ptr)
64
52
    return false;
65
 
 
66
 
  table_message.CopyFrom((iter->second));
67
 
 
 
53
  table_message.CopyFrom(*ptr);
68
54
  return true;
69
55
}
70
56
 
71
57
bool TableMessages::doesTableMessageExist(const identifier::Table &identifier)
72
58
{
73
 
  Cache::iterator iter;
74
 
 
75
 
  iter= table_message_cache.find(identifier.getPath());
76
 
 
77
 
  if (iter == table_message_cache.end())
78
 
  {
79
 
    return false;
80
 
  }
81
 
 
82
 
  return true;
 
59
  return find_ptr(table_message_cache, identifier.getPath());
83
60
}
84
61
 
85
62
bool TableMessages::renameTableMessage(const identifier::Table &from, const identifier::Table &to)
86
63
{
87
 
  Cache::iterator iter;
88
 
 
89
64
  table_message_cache[to.getPath()]= table_message_cache[from.getPath()];
90
 
 
91
 
  iter= table_message_cache.find(to.getPath());
92
 
 
93
 
  if (iter == table_message_cache.end())
94
 
  {
 
65
  Cache::mapped_type* ptr= find_ptr(table_message_cache, to.getPath());
 
66
  if (!ptr)
95
67
    return false;
96
 
  }
97
 
 
98
 
  iter->second.set_schema(to.getSchemaName());
99
 
  iter->second.set_name(to.getTableName());
100
 
 
 
68
  ptr->set_schema(to.getSchemaName());
 
69
  ptr->set_name(to.getTableName());
101
70
  return true;
102
71
}
103
72