Skip to content

Commit 1ad5c28

Browse files
committed
CDRIVER-888: inprog, killop & unlock are commands now, not queries
We don't expose any helpers for these, but did use inprog in testing
1 parent 9fc7fc0 commit 1ad5c28

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/mongoc/mongoc-client.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,7 @@ mongoc_client_command (mongoc_client_t *client,
11141114
}
11151115

11161116
/*
1117-
* Allow a caller to provide a fully qualified namespace. Otherwise,
1118-
* querying something like "$cmd.sys.inprog" is not possible.
1117+
* Allow a caller to provide a fully qualified namespace
11191118
*/
11201119
if (NULL == strstr (db_name, "$cmd")) {
11211120
bson_snprintf (ns, sizeof ns, "%s.$cmd", db_name);

tests/test-mongoc-collection.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,33 +1829,36 @@ END_IGNORE_DEPRECATIONS;
18291829
static void
18301830
test_command_fq (void)
18311831
{
1832-
mongoc_collection_t *collection;
18331832
mongoc_client_t *client;
18341833
mongoc_cursor_t *cursor;
18351834
const bson_t *doc = NULL;
1835+
bson_iter_t iter;
18361836
bson_t *cmd;
18371837
bool r;
18381838

18391839
client = test_framework_client_new ();
18401840
ASSERT (client);
18411841

1842-
collection = mongoc_client_get_collection (client,
1843-
"admin", "$cmd.sys.inprog");
1844-
ASSERT (collection);
1842+
cmd = tmp_bson ("{ 'dbstats': 1}");
18451843

1846-
cmd = BCON_NEW ("query", "{", "}");
1847-
1848-
cursor = mongoc_collection_command (collection, MONGOC_QUERY_NONE, 0, 1, 0,
1849-
cmd, NULL, NULL);
1844+
cursor = mongoc_client_command (client, "sometest.$cmd", MONGOC_QUERY_NONE,
1845+
0, -1, 0, cmd, NULL, NULL);
18501846
r = mongoc_cursor_next (cursor, &doc);
18511847
assert (r);
18521848

1849+
if (bson_iter_init_find (&iter, doc, "db") &&
1850+
BSON_ITER_HOLDS_UTF8 (&iter)) {
1851+
ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "sometest");
1852+
} else {
1853+
fprintf(stderr, "dbstats didn't return 'db' key?");
1854+
abort();
1855+
}
1856+
1857+
18531858
r = mongoc_cursor_next (cursor, &doc);
18541859
assert (!r);
18551860

18561861
mongoc_cursor_destroy (cursor);
1857-
bson_destroy (cmd);
1858-
mongoc_collection_destroy (collection);
18591862
mongoc_client_destroy (client);
18601863
}
18611864

0 commit comments

Comments
 (0)