~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/catalog/cache.cc

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:19:11 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051911-blfrsfy6yjvjg9rs
add note that impl of DROP INDEX should be documented

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
22
 
 
23
 
#include <drizzled/catalog/cache.h>
 
21
#include "config.h"
 
22
#include "drizzled/catalog.h"
 
23
#include "drizzled/catalog/cache.h"
24
24
 
25
25
namespace drizzled {
26
26
namespace catalog {
27
27
 
28
 
Instance::shared_ptr Cache::find(const identifier::Catalog &identifier, drizzled::error_t &error)
 
28
Instance::shared_ptr Cache::find(const identifier::Catalog &identifier, catalog::error_t &error)
29
29
{
30
30
  boost::mutex::scoped_lock scopedLock(_mutex);
31
31
  unordered_map::iterator iter= cache.find(identifier);
32
32
  if (iter != cache.end())
33
33
  {
34
34
    if (not (*iter).second)
35
 
    {
36
 
      error= ER_CATALOG_NO_LOCK;
37
 
    }
38
 
    else
39
 
    {
40
 
      error= EE_OK;
41
 
    }
 
35
      error= LOCKED;
42
36
 
43
37
    return (*iter).second;
44
38
  }
45
39
 
46
 
  error= ER_CATALOG_DOES_NOT_EXIST;
 
40
  error= NOT_FOUND;
47
41
  return catalog::Instance::shared_ptr();
48
42
}
49
43
 
59
53
  return false;
60
54
}
61
55
 
62
 
bool Cache::erase(const identifier::Catalog &identifier, drizzled::error_t &error)
 
56
bool Cache::erase(const identifier::Catalog &identifier, catalog::error_t &error)
63
57
{
64
58
  boost::mutex::scoped_lock scopedLock(_mutex);
65
59
 
73
67
 
74
68
    assert(0); // This should be imposssible
75
69
  }
76
 
  error= ER_CATALOG_DOES_NOT_EXIST;
 
70
  error= NOT_FOUND;
77
71
 
78
72
  return false;
79
73
}
80
74
 
81
 
bool Cache::unlock(const identifier::Catalog &identifier, drizzled::error_t &error)
 
75
bool Cache::unlock(const identifier::Catalog &identifier, catalog::error_t &error)
82
76
{
83
77
  boost::mutex::scoped_lock scopedLock(_mutex);
84
78
 
94
88
 
95
89
      assert(0); // This should be imposssible
96
90
    }
97
 
    error= EE_OK;
 
91
    error= FOUND;
98
92
  }
99
93
  else
100
94
  {
101
 
    error= ER_CATALOG_DOES_NOT_EXIST;
 
95
    error= NOT_FOUND;
102
96
  }
103
97
 
104
98
  return false;
105
99
}
106
100
 
107
 
bool Cache::lock(const identifier::Catalog &identifier, drizzled::error_t &error)
 
101
bool Cache::lock(const identifier::Catalog &identifier, catalog::error_t &error)
108
102
{
109
103
  boost::mutex::scoped_lock scopedLock(_mutex);
110
104
  std::pair<unordered_map::iterator, bool> ret= cache.insert(std::make_pair(identifier, catalog::Instance::shared_ptr()));
113
107
  {
114
108
    if (ret.first->second)
115
109
    {
116
 
      error= EE_OK;
 
110
      error= FOUND;
117
111
    }
118
112
    else
119
113
    {
120
 
      error= ER_CATALOG_NO_LOCK;
 
114
      error= LOCKED;
121
115
    }
122
116
  }
123
117
 
124
118
  return ret.second;
125
119
}
126
120
 
127
 
bool Cache::insert(const identifier::Catalog &identifier, catalog::Instance::shared_ptr instance, drizzled::error_t &error)
 
121
bool Cache::insert(const identifier::Catalog &identifier, catalog::Instance::shared_ptr instance, catalog::error_t &error)
128
122
{
129
123
  boost::mutex::scoped_lock scopedLock(_mutex);
130
124
  std::pair<unordered_map::iterator, bool> ret= cache.insert(std::make_pair(identifier, instance));
133
127
  {
134
128
    if (ret.first->second)
135
129
    {
136
 
      error= EE_OK;
 
130
      error= FOUND;
137
131
    }
138
132
    else
139
133
    {
140
 
      error= ER_CATALOG_NO_LOCK;
 
134
      error= LOCKED;
141
135
    }
142
136
  }
143
137