diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2016-11-07 13:13:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-07 13:13:00 -0500 |
commit | f8afbce1f26f5a6683594641279ad0c065145825 (patch) | |
tree | 476828786452654bdac5cff10083bfb4c94c4f65 | |
parent | 346180e79d0a9dd89644f63cfd8754723b6ecf60 (diff) | |
download | mongo-f8afbce1f26f5a6683594641279ad0c065145825.tar.gz |
WT-3011 __wt_curjoin_open() saves the wrong URI in the cursor. (#3135)
* WT-3011 __wt_curjoin_open() saves the wrong URI in the cursor.
Don't skip "uri" past "join:", we're going to call __wt_cursor_init()
with that value, and we want to copy the original uri into the cursor's
internal_uri field.
* Don't mix-and-match error/return handling in __wt_json_token(),
return immediately on any error.
* Set a join cursor's internal_uri to the join URI.
* Free internal_uri now that the cursor owns it.
-rw-r--r-- | src/cursor/cur_join.c | 11 | ||||
-rw-r--r-- | src/cursor/cur_json.c | 20 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/cursor/cur_join.c b/src/cursor/cur_join.c index 806436ebf38..ddf97bfbcdc 100644 --- a/src/cursor/cur_join.c +++ b/src/cursor/cur_join.c @@ -326,8 +326,7 @@ __curjoin_close(WT_CURSOR *cursor) JOINABLE_CURSOR_API_CALL(cursor, session, close, NULL); __wt_schema_release_table(session, cjoin->table); - /* These are owned by the table */ - cursor->internal_uri = NULL; + /* This is owned by the table */ cursor->key_format = NULL; if (cjoin->projection != NULL) { __wt_free(session, cjoin->projection); @@ -1310,11 +1309,10 @@ __wt_curjoin_open(WT_SESSION_IMPL *session, WT_RET_MSG(session, EINVAL, "unable to initialize a join cursor with existing owner"); - if (!WT_PREFIX_SKIP(uri, "join:")) - return (__wt_unexpected_object_type(session, uri, "join:")); tablename = uri; - if (!WT_PREFIX_SKIP(tablename, "table:")) - return (__wt_unexpected_object_type(session, uri, "table:")); + if (!WT_PREFIX_SKIP(tablename, "join:table:")) + return ( + __wt_unexpected_object_type(session, uri, "join:table:")); columns = strchr(tablename, '('); if (columns == NULL) @@ -1327,7 +1325,6 @@ __wt_curjoin_open(WT_SESSION_IMPL *session, cursor = &cjoin->iface; *cursor = iface; cursor->session = &session->iface; - cursor->internal_uri = table->name; cursor->key_format = table->key_format; cursor->value_format = table->value_format; cjoin->table = table; diff --git a/src/cursor/cur_json.c b/src/cursor/cur_json.c index 093ec3c59ac..4ba10ddabb0 100644 --- a/src/cursor/cur_json.c +++ b/src/cursor/cur_json.c @@ -420,7 +420,8 @@ __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, const char *_bad = in; \ while (__wt_isalnum((u_char)*in)) \ in++; \ - __wt_errx(session, "unknown keyword \"%.*s\" in JSON", \ + WT_RET_MSG(session, EINVAL, \ + "unknown keyword \"%.*s\" in JSON", \ (int)(in - _bad), _bad); \ } \ } while (0) @@ -501,9 +502,9 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, } src++; } - if (result != 's') - __wt_errx(session, "unterminated string in JSON"); - break; + if (result == 's') + break; + WT_RET_MSG(session, EINVAL, "unterminated string in JSON"); case '-': case '0': case '1': @@ -561,15 +562,14 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, if (isalph) while (*src != '\0' && __wt_isalnum((u_char)*src)) src++; - __wt_errx(session, "unknown token \"%.*s\" in JSON", - (int)(src - bad), bad); - break; + WT_RET_MSG(session, EINVAL, + "unknown token \"%.*s\" in JSON", (int)(src - bad), bad); + /* NOTREACHED */ } + WT_ASSERT(session, result != -1); + *toklen = (size_t)(src - *tokstart); *toktype = result; - - if (result < 0) - WT_RET_MSG(session, EINVAL, "illegal token in JSON"); return (0); } |