diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-05-13 13:40:28 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-05-13 13:40:28 +1000 |
commit | 1f050f5c38c49c4291eea9bc83ca0a58839fc8ac (patch) | |
tree | 79651299f4371ef389e35c4f3c0a67b69ded2c5b /src/schema | |
parent | 239421d7de7689d832ba4e55c686df938897bebe (diff) | |
download | mongo-1f050f5c38c49c4291eea9bc83ca0a58839fc8ac.tar.gz |
Check index creation by opening the index, as we do for other calls to WT_SESSION::create.
Diffstat (limited to 'src/schema')
-rw-r--r-- | src/schema/schema_create.c | 4 | ||||
-rw-r--r-- | src/schema/schema_open.c | 23 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/schema/schema_create.c b/src/schema/schema_create.c index c003ad90ca7..4624d82d727 100644 --- a/src/schema/schema_create.c +++ b/src/schema/schema_create.c @@ -477,6 +477,10 @@ __create_index(WT_SESSION_IMPL *session, goto err; } + /* Make sure that the configuration is valid. */ + WT_ERR(__wt_schema_open_index( + session, table, idxname, strlen(idxname), NULL)); + err: __wt_free(session, idxconf); __wt_free(session, sourceconf); __wt_buf_free(session, &confbuf); diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index 2b645d5c666..7470701e756 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -227,7 +227,14 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) WT_ERR(__wt_buf_catfmt( session, buf, "%.*s,", (int)ckey.len, ckey.str)); } - if (ret != 0 && ret != WT_NOTFOUND) + WT_ERR_NOTFOUND_OK(ret); + + /* + * If the table doesn't yet have its column groups, don't try to + * calculate a plan: we are just checking that the index creation is + * sane. + */ + if (!table->cg_complete) goto err; WT_ERR(__wt_scr_alloc(session, 0, &plan)); @@ -341,6 +348,20 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, WT_ERR(__wt_strdup(session, idxconf, &idx->config)); WT_ERR(__open_index(session, table, idx)); + /* + * If we're checking the creation of an index before a + * table is fully created, don't save the index: it + * will need to be reopened once the table is complete. + */ + if (!table->cg_complete) { + ret = __wt_schema_destroy_index(session, idx); + idx = NULL; + WT_ERR(ret); + if (idxname != NULL) + break; + continue; + } + table->indices[i] = idx; idx = NULL; |