diff options
author | Don Anderson <dda@ddanderson.com> | 2014-12-08 10:45:13 -0500 |
---|---|---|
committer | Don Anderson <dda@ddanderson.com> | 2014-12-08 10:45:13 -0500 |
commit | 4957aea23978676acbef864501c7f79b51a90b9a (patch) | |
tree | 4ef3b5f3748320d9022d3e5dcefa59d748463d1e | |
parent | bbe9ab35663fba23e070b9a50fb444de83cc5b47 (diff) | |
download | mongo-4957aea23978676acbef864501c7f79b51a90b9a.tar.gz |
Handle nonexistent objects for drops of indices/colgroups/lsm with 'force'.
refs #1436.
-rw-r--r-- | src/schema/schema_drop.c | 18 | ||||
-rw-r--r-- | src/schema/schema_open.c | 2 | ||||
-rw-r--r-- | test/suite/test_drop.py | 12 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/schema/schema_drop.c b/src/schema/schema_drop.c index 673a67e641b..3455360f047 100644 --- a/src/schema/schema_drop.c +++ b/src/schema/schema_drop.c @@ -60,7 +60,7 @@ __drop_file( */ static int __drop_colgroup( - WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -76,6 +76,9 @@ __drop_colgroup( } WT_TRET(__wt_metadata_remove(session, uri)); + + if (force && ret == ENOENT) + ret = 0; return (ret); } @@ -85,9 +88,11 @@ __drop_colgroup( */ static int __drop_index( - WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) { WT_INDEX *idx; + + WT_DECL_RET; WT_TABLE *table; @@ -98,6 +103,9 @@ __drop_index( } WT_TRET(__wt_metadata_remove(session, uri)); + + if (force && ret == ENOENT) + ret = 0; return (ret); } @@ -173,11 +181,11 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) WT_CLEAR_BTREE_IN_SESSION(session); if (WT_PREFIX_MATCH(uri, "colgroup:")) - ret = __drop_colgroup(session, uri, cfg); + ret = __drop_colgroup(session, uri, force, cfg); else if (WT_PREFIX_MATCH(uri, "file:")) ret = __drop_file(session, uri, force, cfg); else if (WT_PREFIX_MATCH(uri, "index:")) - ret = __drop_index(session, uri, cfg); + ret = __drop_index(session, uri, force, cfg); else if (WT_PREFIX_MATCH(uri, "lsm:")) ret = __wt_lsm_tree_drop(session, uri, cfg); else if (WT_PREFIX_MATCH(uri, "table:")) @@ -196,7 +204,7 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) * underlying drop functions should handle this case (we passed them * the "force" value), but better safe than sorry. */ - if (ret == WT_NOTFOUND) + if (ret == WT_NOTFOUND || ret == ENOENT) ret = force ? 0 : ENOENT; /* Bump the schema generation so that stale data is ignored. */ diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index 81f5161d03e..cee51af5742 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -508,7 +508,7 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session, /* * __wt_schema_get_index -- - * Find a column group by URI. + * Find an index by URI. */ int __wt_schema_get_index(WT_SESSION_IMPL *session, diff --git a/test/suite/test_drop.py b/test/suite/test_drop.py index 11d69b159c7..dcda3998436 100644 --- a/test/suite/test_drop.py +++ b/test/suite/test_drop.py @@ -71,10 +71,22 @@ class test_drop(wttest.WiredTigerTestCase): # Test drop of a non-existent object: force succeeds, without force fails. def test_drop_dne(self): uri = self.uri + self.name + cguri = 'colgroup:' + self.name + idxuri = 'index:' + self.name + ':indexname' + lsmuri = 'lsm:' + self.name confirm_does_not_exist(self, uri) self.session.drop(uri, 'force') self.assertRaises( wiredtiger.WiredTigerError, lambda: self.session.drop(uri, None)) + self.session.drop(cguri, 'force') + self.assertRaises( + wiredtiger.WiredTigerError, lambda: self.session.drop(cguri, None)) + self.session.drop(idxuri, 'force') + self.assertRaises( + wiredtiger.WiredTigerError, lambda: self.session.drop(idxuri, None)) + self.session.drop(lsmuri, 'force') + self.assertRaises( + wiredtiger.WiredTigerError, lambda: self.session.drop(lsmuri, None)) if __name__ == '__main__': |