~drizzle-trunk/drizzle/jenkins-Drizzle-Builder-187

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.cc

  • Committer: Stewart Smith
  • Date: 2012-07-11 14:06:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2574.
  • Revision ID: stewart@flamingspork.com-20120711140600-oxrs1cjabjuqpd05
force a identifier::Schema to be constructed with a identifier::Catalog. This is close to the final 'big' part for CATALOG support. We also have to modify all around the server that creates identifier::Schema so it does so properly. Since a single Session cannot span schemas, we get off a wee bit easy :) The big limitation in this patch is that INFORMATION_SCHEMA and DATA_DICTIONARY only appear in the LOCAL catalog (and this really needs to be fixed before CATALOGs other than LOCAL are supported).

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <drizzled/sql_table.h>
27
27
#include <drizzled/charset.h>
28
28
#include <drizzled/cursor.h>
29
 
#include <drizzled/catalog/local.h>
 
29
#include <drizzled/data_home.h>
 
30
#include <drizzled/message/catalog.h>
30
31
 
31
32
#include <drizzled/pthread_globals.h>
32
33
 
69
70
  table_definition_ext= DEFAULT_FILE_EXTENSION;
70
71
}
71
72
 
72
 
void Schema::prime()
 
73
void Schema::prime_catalog(identifier::Catalog &catalog_identifier)
73
74
{
74
 
  CachedDirectory directory(catalog::local_identifier().getPath(),
 
75
  CachedDirectory directory(catalog_identifier.getPath(),
75
76
                            CachedDirectory::DIRECTORY, true);
76
77
 
77
78
  CachedDirectory::Entries files= directory.getEntries();
83
84
      continue;
84
85
    message::Schema schema_message;
85
86
 
86
 
    std::string filename= catalog::local_identifier().getPath();
 
87
    std::string filename= catalog_identifier.getPath();
87
88
    filename+= FN_LIBCHAR;
88
89
    filename+= entry->filename;
89
90
 
90
91
    if (readSchemaFile(filename, schema_message))
91
92
    {
92
 
      identifier::Schema schema_identifier(schema_message.name());
 
93
 
 
94
      identifier::Schema schema_identifier(catalog_identifier,
 
95
                                           schema_message.name());
 
96
 
 
97
      if (! schema_message.has_catalog())
 
98
      {
 
99
        schema_message.set_catalog(catalog_identifier.name());
 
100
      }
93
101
 
94
102
      pair<SchemaCache::iterator, bool> ret=
95
103
        schema_cache.insert(make_pair(schema_identifier.getPath(), new message::Schema(schema_message)));
99
107
  }
100
108
}
101
109
 
 
110
void Schema::prime()
 
111
{
 
112
  drizzled::CachedDirectory directory(drizzled::getDataHome().file_string(),
 
113
                                      drizzled::CachedDirectory::DIRECTORY,
 
114
                                      true);
 
115
  drizzled::CachedDirectory::Entries files= directory.getEntries();
 
116
 
 
117
  for (drizzled::CachedDirectory::Entries::iterator fileIter= files.begin();
 
118
       fileIter != files.end(); fileIter++)
 
119
  {
 
120
    drizzled::CachedDirectory::Entry *entry= *fileIter;
 
121
    drizzled::message::catalog::shared_ptr message;
 
122
 
 
123
    if (not entry->filename.compare(GLOBAL_TEMPORARY_EXT))
 
124
      continue;
 
125
 
 
126
    drizzled::identifier::Catalog identifier(entry->filename);
 
127
 
 
128
    prime_catalog(identifier);
 
129
  }
 
130
}
 
131
 
102
132
void Schema::doGetSchemaIdentifiers(identifier::schema::vector &set_of_names)
103
133
{
104
134
  mutex.lock_shared();
105
135
  BOOST_FOREACH(SchemaCache::reference iter, schema_cache)
106
 
    set_of_names.push_back(identifier::Schema(iter.second->name()));
 
136
    set_of_names.push_back(identifier::Schema(identifier::Catalog(iter.second->catalog()),
 
137
                                              iter.second->name()));
107
138
  mutex.unlock_shared();
108
139
}
109
140
 
124
155
 
125
156
bool Schema::doCreateSchema(const drizzled::message::Schema &schema_message)
126
157
{
127
 
  identifier::Schema schema_identifier(schema_message.name());
 
158
  identifier::Schema schema_identifier(identifier::Catalog(schema_message.catalog()),
 
159
                                       schema_message.name());
128
160
 
129
161
  if (mkdir(schema_identifier.getPath().c_str(), 0777) == -1)
130
162
  {
186
218
 
187
219
bool Schema::doAlterSchema(const drizzled::message::Schema &schema_message)
188
220
{
189
 
  identifier::Schema schema_identifier(schema_message.name());
 
221
  identifier::Schema schema_identifier(identifier::Catalog(schema_message.catalog()),
 
222
                                       schema_message.name());
190
223
 
191
224
  if (access(schema_identifier.getPath().c_str(), F_OK))
192
225
    return false;