Description
To illustrate the case, it is sufficient to pass an empty BSON as a command to mongoc_client_command_simple():
src/mongoc/mongoc-cluster.c:183 mongoc_cluster_run_command_internal(): precondition failed: command_name
|
Aborted
|
When something is appended to the command, the issue is gone. See the example below:
#include <stdio.h>
|
#include <mongoc.h>
|
|
|
int main() {
|
mongoc_client_t *client;
|
bson_t command, reply;
|
bson_error_t error;
|
bool status;
|
|
|
mongoc_init();
|
|
|
client = mongoc_client_new("mongodb://127.0.0.1");
|
BSON_ASSERT(client);
|
bson_init(&command);
|
|
// BSON_APPEND_BOOL(&command, "a", 1); // Issue is gone when uncommented
|
|
|
status = mongoc_client_command_simple(client, "test", &command, 0, &reply, &error);
|
if (!status) printf("Error: %s\n", error.message);
|
|
|
bson_destroy(&command);
|
bson_destroy(&reply);
|
mongoc_client_destroy(client);
|
mongoc_cleanup();
|
return 0;
|
}
|