Skip to content

Commit

Permalink
Add the primary index information into the list of index infos return… (
Browse files Browse the repository at this point in the history
#100)

* Add the primary index information into the list of index infos returned in the response of listIndex command.

* Resolve review comments.

* Resolve review comments.

* Use the correct single quote.
  • Loading branch information
dongxinEric authored and apkar committed Mar 3, 2019
1 parent 2c778f5 commit 878f604
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ deploy/bin/
.dist/
.out/
.extdep/
test/correctness/dist/
test/correctness/local/
certs/
upsert_test.csv

packages/
Expand Down
43 changes: 25 additions & 18 deletions src/ExtCmd.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,23 +697,23 @@ struct BuildInfoCmd {
static Future<Reference<ExtMsgReply>> call(Reference<ExtConnection> ec,
Reference<ExtMsgQuery> query,
Reference<ExtMsgReply> reply) {
reply->addDocument(BSON("version"
<< EXT_SERVER_VERSION
<< "gitVersion"
<< "<string>"
<< "OpenSSLVersion"
<< ""
<< "sysInfo"
<< "<string>"
<< "loaderFlags"
<< "<string>"
<< "compilerFlags"
<< "<string>"
<< "allocator"
<< "<string>"
<< "versionArray" << BSON_ARRAY(2 << 4 << 10) << "javascriptEngine"
<< "<string>"
<< "bits" << 64 << "debug" << false << "maxBsonObjectSize" << 16777216 << "ok" << 1.0));
// clang-format off
reply->addDocument(BSON(
"version" << EXT_SERVER_VERSION <<
"gitVersion" << "<string>" <<
"OpenSSLVersion" << "" <<
"sysInfo" << "<string>" <<
"loaderFlags" << "<string>" <<
"compilerFlags" << "<string>" <<
"allocator" << "<string>" <<
"versionArray" << BSON_ARRAY(2 << 4 << 10) <<
"javascriptEngine" << "<string>" <<
"bits" << 64 <<
"debug" << false <<
"maxBsonObjectSize"<< 16777216 <<
"ok" << 1.0
));
// clang-format on
return reply;
}
};
Expand Down Expand Up @@ -1278,6 +1278,14 @@ struct ListIndexesCmd {
indexList << indexObj;
}

// Add the _id index here
indexList << BSON("name"
<< "_id_"
<< "ns" << (msg->ns.first + "." + msg->ns.second) << "key" << BSON("_id" << 1)
<< "metadata version" << 1 << "status"
<< "ready"
<< "unique" << true);

// FIXME: Not using cursors to return collection list.
reply->addDocument(BSON(
// clang-format off
Expand All @@ -1288,7 +1296,6 @@ struct ListIndexesCmd {
"ok" << 1.0
// clang-format on
));

return reply;
} catch (Error& e) {
if (e.code() != error_code_actor_cancelled) {
Expand Down
5 changes: 5 additions & 0 deletions test/correctness/smoke/test_basic_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def test_simple_coll_index(fixture_collection):
# Create an index
collection.create_index('a', name='idx_a')

# Check the returned index by listindex command contains the primay one
indexes = collection.index_information()

assert '_id_' in indexes, "Returned list of indexes by listIndex command does not contains the primary index _id_"

# Insert bunch of documents
docs = []
for i in range(1, 50):
Expand Down

0 comments on commit 878f604

Please sign in to comment.