diff options
author | Alex Gorrod <alexg@wiredtiger.com> | 2014-12-10 10:28:14 +1100 |
---|---|---|
committer | Alex Gorrod <alexg@wiredtiger.com> | 2014-12-10 10:28:14 +1100 |
commit | 8eadc747bc02f04665d3f34facdffa2ea41490b3 (patch) | |
tree | a9a4e9477735acc7ff59e93702ed2c0d6c398e27 /src/schema | |
parent | a4ea1148106f4fa1a705635c073b113760d3c708 (diff) | |
parent | c09a9b4ab4b9b3c3e9d37ea261e26fae15d96cf2 (diff) | |
download | mongo-8eadc747bc02f04665d3f34facdffa2ea41490b3.tar.gz |
Merge branch 'develop' into force-drop
Diffstat (limited to 'src/schema')
-rw-r--r-- | src/schema/schema_drop.c | 31 | ||||
-rw-r--r-- | src/schema/schema_list.c | 17 | ||||
-rw-r--r-- | src/schema/schema_open.c | 1 |
3 files changed, 23 insertions, 26 deletions
diff --git a/src/schema/schema_drop.c b/src/schema/schema_drop.c index 4ae3ee454c3..a1baf8f27f3 100644 --- a/src/schema/schema_drop.c +++ b/src/schema/schema_drop.c @@ -34,9 +34,6 @@ __drop_file( /* Remove the metadata entry (ignore missing items). */ WT_TRET(__wt_metadata_remove(session, uri)); - if (force && ret == WT_NOTFOUND) - ret = 0; - if (!remove_files) return (ret); @@ -60,7 +57,7 @@ __drop_file( */ static int __drop_colgroup( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -76,9 +73,6 @@ __drop_colgroup( } WT_TRET(__wt_metadata_remove(session, uri)); - - if (force && ret == ENOENT) - ret = 0; return (ret); } @@ -88,7 +82,7 @@ __drop_colgroup( */ static int __drop_index( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) { WT_INDEX *idx; WT_DECL_RET; @@ -102,9 +96,6 @@ __drop_index( } WT_TRET(__wt_metadata_remove(session, uri)); - - if (force && ret == ENOENT) - ret = 0; return (ret); } @@ -114,7 +105,7 @@ __drop_index( */ static int __drop_table( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -152,9 +143,7 @@ __drop_table( /* Remove the metadata entry (ignore missing items). */ WT_ERR(__wt_metadata_remove(session, uri)); -err: if (force && ret == WT_NOTFOUND) - ret = 0; - if (table != NULL) +err: if (table != NULL) __wt_schema_release_table(session, table); return (ret); } @@ -180,15 +169,15 @@ __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, force, cfg); + ret = __drop_colgroup(session, uri, 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, force, cfg); + ret = __drop_index(session, uri, cfg); else if (WT_PREFIX_MATCH(uri, "lsm:")) ret = __wt_lsm_tree_drop(session, uri, cfg); else if (WT_PREFIX_MATCH(uri, "table:")) - ret = __drop_table(session, uri, force, cfg); + ret = __drop_table(session, uri, cfg); else if ((dsrc = __wt_schema_get_source(session, uri)) != NULL) ret = dsrc->drop == NULL ? __wt_object_unsupported(session, uri) : @@ -198,10 +187,8 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) ret = __wt_bad_object_type(session, uri); /* - * Map WT_NOTFOUND to ENOENT (or to 0 if "force" is set), based on the - * assumption WT_NOTFOUND means there was no metadata entry. The - * underlying drop functions should handle this case (we passed them - * the "force" value), but better safe than sorry. + * Map WT_NOTFOUND to ENOENT, based on the assumption WT_NOTFOUND means + * there was no metadata entry. Map ENOENT to zero if force is set. */ if (ret == WT_NOTFOUND || ret == ENOENT) ret = force ? 0 : ENOENT; diff --git a/src/schema/schema_list.c b/src/schema/schema_list.c index f2c5f8b5617..02556eb942c 100644 --- a/src/schema/schema_list.c +++ b/src/schema/schema_list.c @@ -17,6 +17,7 @@ __schema_add_table(WT_SESSION_IMPL *session, { WT_DECL_RET; WT_TABLE *table; + uint64_t bucket; /* Make sure the metadata is open before getting other locks. */ WT_RET(__wt_metadata_open(session)); @@ -26,7 +27,9 @@ __schema_add_table(WT_SESSION_IMPL *session, session, name, namelen, ok_incomplete, &table)); WT_RET(ret); - TAILQ_INSERT_HEAD(&session->tables, table, q); + bucket = table->name_hash % WT_HASH_ARRAY_SIZE; + SLIST_INSERT_HEAD(&session->tables, table, l); + SLIST_INSERT_HEAD(&session->tablehash[bucket], table, hashl); *tablep = table; return (0); @@ -42,9 +45,12 @@ __schema_find_table(WT_SESSION_IMPL *session, { WT_TABLE *table; const char *tablename; + uint64_t bucket; + + bucket = __wt_hash_city64(name, namelen) % WT_HASH_ARRAY_SIZE; restart: - TAILQ_FOREACH(table, &session->tables, q) { + SLIST_FOREACH(table, &session->tablehash[bucket], hashl) { tablename = table->name; (void)WT_PREFIX_SKIP(tablename, "table:"); if (WT_STRING_MATCH(tablename, name, namelen)) { @@ -194,9 +200,12 @@ __wt_schema_destroy_table(WT_SESSION_IMPL *session, WT_TABLE *table) int __wt_schema_remove_table(WT_SESSION_IMPL *session, WT_TABLE *table) { + uint64_t bucket; WT_ASSERT(session, table->refcnt <= 1); - TAILQ_REMOVE(&session->tables, table, q); + bucket = table->name_hash % WT_HASH_ARRAY_SIZE; + SLIST_REMOVE(&session->tables, table, __wt_table, l); + SLIST_REMOVE(&session->tablehash[bucket], table, __wt_table, hashl); return (__wt_schema_destroy_table(session, table)); } @@ -210,7 +219,7 @@ __wt_schema_close_tables(WT_SESSION_IMPL *session) WT_DECL_RET; WT_TABLE *table; - while ((table = TAILQ_FIRST(&session->tables)) != NULL) + while ((table = SLIST_FIRST(&session->tables)) != NULL) WT_TRET(__wt_schema_remove_table(session, table)); return (ret); } diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index 3ae15973d96..f5937381cbb 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -395,6 +395,7 @@ __wt_schema_open_table(WT_SESSION_IMPL *session, WT_ERR(__wt_calloc_def(session, 1, &table)); table->name = tablename; tablename = NULL; + table->name_hash = __wt_hash_city64(name, namelen); WT_ERR(__wt_config_getones(session, tconfig, "columns", &cval)); |