~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.cc

  • Committer: Brian Aker
  • Date: 2010-10-07 20:00:40 UTC
  • mto: (1822.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1823.
  • Revision ID: brian@tangent.org-20101007200040-st5l46s5i445vxoz
We no longer needed to look at the share when removing tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
  schema_cache_filled(false)
59
59
{
60
60
  table_definition_ext= DEFAULT_FILE_EXTENSION;
 
61
  prime();
61
62
}
62
63
 
63
64
Schema::~Schema()
66
67
 
67
68
void Schema::prime()
68
69
{
69
 
  CachedDirectory directory(getDataHomeCatalog().file_string(), CachedDirectory::DIRECTORY);
 
70
  CachedDirectory directory(getDataHomeCatalog(), CachedDirectory::DIRECTORY);
70
71
  CachedDirectory::Entries files= directory.getEntries();
71
72
 
72
73
  mutex.lock();
86
87
      SchemaIdentifier schema_identifier(schema_message.name());
87
88
 
88
89
      pair<SchemaCache::iterator, bool> ret=
89
 
        schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
 
90
        schema_cache.insert(make_pair(schema_identifier.getPath(), schema_message));
90
91
 
91
92
      if (ret.second == false)
92
93
     {
97
98
  mutex.unlock();
98
99
}
99
100
 
100
 
void Schema::doGetSchemaIdentifiers(SchemaIdentifier::vector &set_of_names)
 
101
void Schema::doGetSchemaIdentifiers(SchemaIdentifiers &set_of_names)
101
102
{
102
103
  mutex.lock_shared();
103
104
  {
105
106
         iter != schema_cache.end();
106
107
         iter++)
107
108
    {
108
 
      set_of_names.push_back(SchemaIdentifier((*iter).second->name()));
 
109
      set_of_names.push_back(SchemaIdentifier((*iter).second.name()));
109
110
    }
110
111
  }
111
112
  mutex.unlock_shared();
112
113
}
113
114
 
114
 
bool Schema::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::schema::shared_ptr &schema_message)
 
115
bool Schema::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::Schema &schema_message)
115
116
{
116
117
  mutex.lock_shared();
117
118
  SchemaCache::iterator iter= schema_cache.find(schema_identifier.getPath());
118
119
 
119
120
  if (iter != schema_cache.end())
120
121
  {
121
 
    schema_message= (*iter).second;
 
122
    schema_message.CopyFrom(((*iter).second));
122
123
    mutex.unlock_shared();
123
124
    return true;
124
125
  }
145
146
  mutex.lock();
146
147
  {
147
148
    pair<SchemaCache::iterator, bool> ret=
148
 
      schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
 
149
      schema_cache.insert(make_pair(schema_identifier.getPath(), schema_message));
149
150
 
150
151
 
151
152
    if (ret.second == false)
160
161
 
161
162
bool Schema::doDropSchema(const SchemaIdentifier &schema_identifier)
162
163
{
163
 
  message::schema::shared_ptr schema_message;
 
164
  message::Schema schema_message;
164
165
 
165
166
  string schema_file(schema_identifier.getPath());
166
167
  schema_file.append(1, FN_LIBCHAR);
212
213
      schema_cache.erase(schema_identifier.getPath());
213
214
 
214
215
      pair<SchemaCache::iterator, bool> ret=
215
 
        schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
 
216
        schema_cache.insert(make_pair(schema_identifier.getPath(), schema_message));
216
217
 
217
218
      if (ret.second == false)
218
219
      {
332
333
  return false;
333
334
}
334
335
 
 
336
bool Schema::doCanCreateTable(const drizzled::TableIdentifier &identifier)
 
337
{
 
338
 
 
339
  // This should always be the same value as GLOBAL_TEMPORARY_EXT but be
 
340
  // CASE_UP. --Brian 
 
341
  //
 
342
  // This needs to be done static in here for ordering reasons
 
343
  static SchemaIdentifier TEMPORARY_IDENTIFIER(".TEMPORARY");
 
344
  if (static_cast<const SchemaIdentifier&>(identifier) == TEMPORARY_IDENTIFIER)
 
345
  {
 
346
    return false;
 
347
  }
 
348
 
 
349
  return true;
 
350
}
 
351
 
335
352
void Schema::doGetTableIdentifiers(drizzled::CachedDirectory&,
336
353
                                   const drizzled::SchemaIdentifier&,
337
 
                                   drizzled::TableIdentifier::vector&)
 
354
                                   drizzled::TableIdentifiers&)
338
355
{
339
356
}