~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.cc

  • Committer: Brian Aker
  • Date: 2010-02-25 07:52:23 UTC
  • mto: (1273.13.101 build)
  • mto: This revision was merged to the branch mainline in revision 1309.
  • Revision ID: brian@gaz-20100225075223-125dkr0n8kpmobkj
Fix dropSchema().

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
using namespace std;
35
35
using namespace drizzled;
36
36
 
 
37
#define MY_DB_OPT_FILE "db.opt"
 
38
 
37
39
Schema::Schema():
38
40
  drizzled::plugin::StorageEngine("schema",
39
41
                                  HTON_ALTER_NOT_SUPPORTED |
85
87
      return true;
86
88
    }
87
89
  }
 
90
  else
 
91
  {
 
92
    perror(db_opt_path);
 
93
  }
88
94
 
89
95
  return false;
90
96
}
111
117
  return true;
112
118
}
113
119
 
 
120
bool Schema::doDropSchema(const std::string &schema_name)
 
121
{
 
122
  char   path[FN_REFLEN+16];
 
123
  uint32_t path_len;
 
124
  message::Schema schema_message;
 
125
 
 
126
  path_len= drizzled::build_table_filename(path, sizeof(path), schema_name.c_str(), "", false);
 
127
  path[path_len-1]= 0;                    // remove last '/' from path
 
128
 
 
129
  string schema_file(path);
 
130
  schema_file.append(1, FN_LIBCHAR);
 
131
  schema_file.append(MY_DB_OPT_FILE);
 
132
 
 
133
  if (not doGetSchemaDefinition(schema_name, schema_message))
 
134
    return false;
 
135
 
 
136
  // No db.opt file, no love from us.
 
137
  if (access(schema_file.c_str(), F_OK))
 
138
  {
 
139
    perror(schema_file.c_str());
 
140
    return false;
 
141
  }
 
142
 
 
143
  if (unlink(schema_file.c_str()))
 
144
    perror(schema_file.c_str());
 
145
 
 
146
  if (rmdir(path))
 
147
    perror(path);
 
148
 
 
149
  return true;
 
150
}
 
151
 
114
152
bool Schema::doAlterSchema(const drizzled::message::Schema &schema_message)
115
153
{
116
154
  char   path[FN_REFLEN+16];