~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.cc

  • Committer: Brian Aker
  • Date: 2011-01-24 00:14:21 UTC
  • mfrom: (2081.4.1 clean)
  • Revision ID: brian@tangent.org-20110124001421-eys9bolq0zng6fs2
Merge in trunk of bootstrap treee.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "drizzled/cursor.h"
30
30
#include "drizzled/data_home.h"
31
31
 
 
32
#include <drizzled/pthread_globals.h>
 
33
 
 
34
#include <drizzled/execute.h>
 
35
 
32
36
#include "drizzled/internal/my_sys.h"
33
37
 
34
38
#include <fcntl.h>
68
72
{
69
73
  CachedDirectory directory(getDataHomeCatalog().file_string(), CachedDirectory::DIRECTORY);
70
74
  CachedDirectory::Entries files= directory.getEntries();
71
 
 
72
 
  mutex.lock();
 
75
  boost::unique_lock<boost::shared_mutex> scopedLock(mutex);
73
76
 
74
77
  for (CachedDirectory::Entries::iterator fileIter= files.begin();
75
78
       fileIter != files.end(); fileIter++)
80
83
    if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
81
84
      continue;
82
85
 
 
86
 
83
87
    identifier::Schema filename(entry->filename);
84
88
    if (readSchemaFile(filename, schema_message))
85
89
    {
89
93
        schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
90
94
 
91
95
      if (ret.second == false)
92
 
     {
 
96
      {
93
97
        abort(); // If this has happened, something really bad is going down.
94
98
      }
95
99
    }
96
100
  }
97
 
  mutex.unlock();
 
101
}
 
102
 
 
103
void Schema::startup(drizzled::Session &)
 
104
{
98
105
}
99
106
 
100
107
void Schema::doGetSchemaIdentifiers(identifier::Schema::vector &set_of_names)
142
149
    return false;
143
150
  }
144
151
 
145
 
  mutex.lock();
146
152
  {
 
153
    boost::unique_lock<boost::shared_mutex> scopedLock(mutex);
147
154
    pair<SchemaCache::iterator, bool> ret=
148
155
      schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
149
156
 
153
160
      abort(); // If this has happened, something really bad is going down.
154
161
    }
155
162
  }
156
 
  mutex.unlock();
157
163
 
158
164
  return true;
159
165
}
191
197
    cerr << dir;
192
198
  }
193
199
 
194
 
  mutex.lock();
 
200
  boost::unique_lock<boost::shared_mutex> scopedLock(mutex);
195
201
  schema_cache.erase(schema_identifier.getPath());
196
 
  mutex.unlock();
197
202
 
198
203
  return true;
199
204
}
207
212
 
208
213
  if (writeSchemaFile(schema_identifier, schema_message))
209
214
  {
210
 
    mutex.lock();
 
215
    boost::unique_lock<boost::shared_mutex> scopedLock(mutex);
 
216
    schema_cache.erase(schema_identifier.getPath());
 
217
 
 
218
    pair<SchemaCache::iterator, bool> ret=
 
219
      schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
 
220
 
 
221
    if (ret.second == false)
211
222
    {
212
 
      schema_cache.erase(schema_identifier.getPath());
213
 
 
214
 
      pair<SchemaCache::iterator, bool> ret=
215
 
        schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
216
 
 
217
 
      if (ret.second == false)
218
 
      {
219
 
        abort(); // If this has happened, something really bad is going down.
220
 
      }
 
223
      abort(); // If this has happened, something really bad is going down.
221
224
    }
222
 
    mutex.unlock();
223
225
  }
224
226
 
225
227
  return true;