~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to drizzled/plugin/catalog.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
  }
51
51
};
52
52
 
53
 
Catalog::~Catalog()
54
 
{
55
 
}
56
 
 
57
 
bool Catalog::create(identifier::Catalog::const_reference identifier)
 
53
bool Catalog::create(const identifier::Catalog& identifier)
58
54
{
59
55
  message::catalog::shared_ptr message= message::catalog::make_shared(identifier);
60
56
  return create(identifier, message);
61
57
}
62
58
 
63
 
bool Catalog::create(identifier::Catalog::const_reference identifier, message::catalog::shared_ptr &message)
 
59
bool Catalog::create(const identifier::Catalog& identifier, message::catalog::shared_ptr &message)
64
60
{
65
61
  assert(message);
66
62
 
89
85
  return true;
90
86
}
91
87
 
92
 
bool Catalog::drop(identifier::Catalog::const_reference identifier)
 
88
bool Catalog::drop(const identifier::Catalog& identifier)
93
89
{
94
90
  if (identifier == drizzled::catalog::local_identifier())
95
91
  {
109
105
  BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
110
106
  {
111
107
    if (ref->drop(identifier))
 
108
    {
112
109
      drop_count++;
 
110
    }
113
111
  }
114
112
  assert(drop_count < 2);
115
113
 
122
120
  return true;
123
121
}
124
122
 
125
 
bool Catalog::lock(identifier::Catalog::const_reference identifier)
 
123
bool Catalog::lock(const identifier::Catalog& identifier)
126
124
{
127
125
  drizzled::error_t error;
128
126
  
129
127
  // We insert a lock into the cache, if this fails we bail.
130
 
  if (not catalog::Cache::singleton().lock(identifier, error))
 
128
  if (not catalog::Cache::lock(identifier, error))
131
129
  {
132
130
    my_error(error, identifier);
133
131
 
138
136
}
139
137
 
140
138
 
141
 
bool Catalog::unlock(identifier::Catalog::const_reference identifier)
 
139
bool Catalog::unlock(const identifier::Catalog& identifier)
142
140
{
143
141
  drizzled::error_t error;
144
 
  if (not catalog::Cache::singleton().unlock(identifier, error))
 
142
  if (not catalog::Cache::unlock(identifier, error))
145
143
  {
146
144
    my_error(error, identifier);
147
145
  }
156
154
  return false;
157
155
}
158
156
 
159
 
bool plugin::Catalog::exist(identifier::Catalog::const_reference identifier)
 
157
bool plugin::Catalog::exist(const identifier::Catalog& identifier)
160
158
{
161
 
  if (catalog::Cache::singleton().exist(identifier))
 
159
  if (catalog::Cache::exist(identifier))
 
160
  {
162
161
    return true;
 
162
  }
163
163
 
164
164
  BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
165
165
  {
166
166
    if (ref->exist(identifier))
 
167
    {
167
168
      return true;
 
169
    }
168
170
  }
169
171
 
170
172
  return false;
171
173
}
172
174
 
173
 
void plugin::Catalog::getIdentifiers(identifier::Catalog::vector &identifiers)
 
175
void plugin::Catalog::getIdentifiers(identifier::catalog::vector &identifiers)
174
176
{
175
177
  BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
176
178
  {
186
188
  }
187
189
}
188
190
 
189
 
message::catalog::shared_ptr plugin::Catalog::getMessage(identifier::Catalog::const_reference identifier)
 
191
message::catalog::shared_ptr plugin::Catalog::getMessage(const identifier::Catalog& identifier)
190
192
{
191
193
  drizzled::error_t error;
192
 
  catalog::Instance::shared_ptr instance= catalog::Cache::singleton().find(identifier, error);
 
194
  catalog::Instance::shared_ptr instance= catalog::Cache::find(identifier, error);
193
195
  message::catalog::shared_ptr message;
194
196
 
195
197
  if (instance and instance->message())
200
202
  BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
201
203
  {
202
204
    if ((message= ref->getMessage(identifier)))
 
205
    {
203
206
      return message;
 
207
    }
204
208
  }
205
209
 
206
210
  return message;
207
211
}
208
212
 
209
 
catalog::Instance::shared_ptr plugin::Catalog::getInstance(identifier::Catalog::const_reference identifier)
 
213
catalog::Instance::shared_ptr plugin::Catalog::getInstance(const identifier::Catalog& identifier)
210
214
{
211
215
  drizzled::error_t error;
212
 
  catalog::Instance::shared_ptr instance= catalog::Cache::singleton().find(identifier, error);
 
216
  catalog::Instance::shared_ptr instance= catalog::Cache::find(identifier, error);
213
217
 
214
218
  if (instance)
 
219
  {
215
220
    return instance;
 
221
  }
216
222
 
217
223
  BOOST_FOREACH(catalog::Engine::vector::const_reference ref, Engines::singleton().catalogs())
218
224
  {
222
228
      instance= catalog::Instance::make_shared(message);
223
229
      // If this should fail inserting into the cache, we are in a world of
224
230
      // pain.
225
 
      catalog::Cache::singleton().insert(identifier, instance, error);
 
231
      catalog::Cache::insert(identifier, instance, error);
226
232
 
227
233
      return instance;
228
234
    }