MCPcopy Create free account
hub / github.com/MariaDB/server / drop

Method drop

storage/mroonga/lib/mrn_database_manager.cpp:183–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181 }
182
183 bool DatabaseManager::drop(const char *path) {
184 MRN_DBUG_ENTER_METHOD();
185
186 mrn::PathMapper mapper(path);
187 mrn::Lock lock(mutex_);
188
189 grn_id id;
190 void *db_address;
191 id = grn_hash_get(ctx_, cache_,
192 mapper.db_name(), strlen(mapper.db_name()),
193 &db_address);
194
195 Database *db = NULL;
196 if (id == GRN_ID_NIL) {
197 struct stat dummy;
198 if (stat(mapper.db_path(), &dummy) == 0) {
199 grn_obj *grn_db = grn_db_open(ctx_, mapper.db_path());
200 db = new Database(ctx_, grn_db);
201 }
202 } else {
203 memcpy(&db, db_address, sizeof(Database *));
204 grn_ctx_use(ctx_, db->get());
205 }
206
207 if (!db) {
208 DBUG_RETURN(false);
209 }
210
211 if (db->remove() == GRN_SUCCESS) {
212 if (id != GRN_ID_NIL) {
213 grn_hash_delete_by_id(ctx_, cache_, id, NULL);
214 }
215 delete db;
216 DBUG_RETURN(true);
217 } else {
218 GRN_LOG(ctx_, GRN_LOG_ERROR,
219 "failed to drop database: <%s>: <%s>",
220 mapper.db_path(), ctx_->errbuf);
221 if (id == GRN_ID_NIL) {
222 delete db;
223 }
224 DBUG_RETURN(false);
225 }
226 }
227
228 int DatabaseManager::clear(void) {
229 MRN_DBUG_ENTER_METHOD();

Callers 1

mrn_drop_databaseFunction · 0.45

Calls 5

db_pathMethod · 0.80
statClass · 0.70
db_nameMethod · 0.45
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected