diff options
author | sueloverso <sue@mongodb.com> | 2015-01-23 14:09:59 -0500 |
---|---|---|
committer | sueloverso <sue@mongodb.com> | 2015-01-23 14:09:59 -0500 |
commit | d324db82b021ed5385585047cbec783522bed1b6 (patch) | |
tree | cce3bd73a7f621b8f260a1fb3419ce4b3e4067fd | |
parent | 8da46ac273653b629623694a916ef27e5920d173 (diff) | |
parent | 014ef3fda7de90ea470ca686648f3fe5f38f2f81 (diff) | |
download | mongo-d324db82b021ed5385585047cbec783522bed1b6.tar.gz |
Merge pull request #1594 from wiredtiger/index-drop
Fixes related to indices.
-rw-r--r-- | src/schema/schema_open.c | 5 | ||||
-rw-r--r-- | test/suite/helper.py | 5 | ||||
-rw-r--r-- | test/suite/test_drop.py | 32 |
3 files changed, 32 insertions, 10 deletions
diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index d613ced00aa..fa655c7108b 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -269,6 +269,7 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, cursor = NULL; idx = NULL; + match = 0; /* Build a search key. */ tablename = table->name; @@ -343,6 +344,8 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, break; } WT_ERR_NOTFOUND_OK(ret); + if (idxname != NULL && !match) + ret = WT_NOTFOUND; /* If we did a full pass, we won't need to do it again. */ if (idxname == NULL) { @@ -557,6 +560,8 @@ __wt_schema_get_index(WT_SESSION_IMPL *session, /* Otherwise, open it. */ WT_ERR(__wt_schema_open_index( session, table, tend + 1, strlen(tend + 1), indexp)); + if (tablep != NULL) + *tablep = table; err: __wt_schema_release_table(session, table); WT_RET(ret); diff --git a/test/suite/helper.py b/test/suite/helper.py index 21eac2359b6..36792433cb7 100644 --- a/test/suite/helper.py +++ b/test/suite/helper.py @@ -81,7 +81,7 @@ def confirm_does_not_exist(self, uri): self.pr('confirm_does_not_exist: ' + uri) self.assertRaises(wiredtiger.WiredTigerError, lambda: self.session.open_cursor(uri, None)) - self.assertEqual(glob.glob('*' + uri.split(":")[1] + '*'), [], + self.assertEqual(glob.glob('*' + uri.split(":")[-1] + '*'), [], 'confirm_does_not_exist: URI exists, file name matching \"' + uri.split(":")[1] + '\" found') @@ -204,6 +204,9 @@ def complex_populate_type(self, uri, config, rows, type): cursor.insert() cursor.close() +def complex_populate_index_name(self, uri): + return 'index:' + uri.split(":")[1] + ':indx1' + def complex_populate_check_cursor(self, cursor, rows): i = 0 for key, s1, i2, s3, s4 in cursor: diff --git a/test/suite/test_drop.py b/test/suite/test_drop.py index 1daafb72db1..b87760f077e 100644 --- a/test/suite/test_drop.py +++ b/test/suite/test_drop.py @@ -28,7 +28,8 @@ import os, time import wiredtiger, wttest -from helper import confirm_does_not_exist, complex_populate, simple_populate +from helper import confirm_does_not_exist, complex_populate, \ + complex_populate_index_name, simple_populate # test_drop.py # session level drop operation @@ -44,7 +45,7 @@ class test_drop(wttest.WiredTigerTestCase): ] # Populate an object, remove it and confirm it no longer exists. - def drop(self, populate, with_cursor): + def drop(self, populate, with_cursor, close_session, drop_index): uri = self.uri + self.name populate(self, uri, 'key_format=S' + self.extra_config, 10) @@ -55,19 +56,33 @@ class test_drop(wttest.WiredTigerTestCase): lambda: self.session.drop(uri, None)) cursor.close() - self.session.drop(uri, None) - confirm_does_not_exist(self, uri) + if close_session: + self.reopen_conn() + + if drop_index: + drop_uri = complex_populate_index_name(self, uri) + else: + drop_uri = uri + self.session.drop(drop_uri, None) + confirm_does_not_exist(self, drop_uri) # Test drop of an object. def test_drop(self): # Simple file or table object. - self.drop(simple_populate, False) - self.drop(simple_populate, True) + # Try all combinations except dropping the index, the simple + # case has no indices. + for with_cursor in [False, True]: + for close_session in [False, True]: + self.drop(simple_populate, with_cursor, close_session, False) # A complex, multi-file table object. + # Try all test combinations. if self.uri == "table:": - self.drop(complex_populate, False) - self.drop(complex_populate, True) + for with_cursor in [False, True]: + for close_session in [False, True]: + for drop_index in [False, True]: + self.drop(complex_populate, with_cursor, + close_session, drop_index) # Test drop of a non-existent object: force succeeds, without force fails. def test_drop_dne(self): @@ -89,6 +104,5 @@ class test_drop(wttest.WiredTigerTestCase): self.assertRaises( wiredtiger.WiredTigerError, lambda: self.session.drop(lsmuri, None)) - if __name__ == '__main__': wttest.run() |