Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDRIVER-5948 remove deprecated cursor API #1959

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Unreleased (2.0.0)
* `mongoc_client_command`, `mongoc_database_command`, and `mongoc_collection_command` are removed. Use `mongoc_client_command_simple`, `mongoc_database_command_simple`, and `mongoc_collection_command_simple` instead.
* `MONGOC_URI_MAXIDLETIMEMS` and `MONGOC_URI_WAITQUEUEMULTIPLE` are removed. They were unused.
* `bson_string_t` and associated functions are removed.
* `mongoc_cursor_is_alive` is removed. Use the equivalent `mongoc_cursor_more` instead.
* `mongoc_collection_delete` is removed. Use `mongoc_collection_delete_one` or `mongoc_collection_delete_many` instead.
* `mongoc_delete_flags_t` and `mongoc_reply_flags_t` are removed.
* Support for `ENABLE_SASL=CYRUS` on Windows is removed. Use `ENABLE_SASL=SSPI` or `ENABLE_SASL=OFF` instead.
Expand All @@ -51,11 +50,17 @@ Unreleased (2.0.0)
* `mongoc_bulk_operation_delete_one` is removed. Use `mongoc_bulk_operation_remove_one` instead.
* `mongoc_bulk_operation_get_hint` is removed. Use `mongoc_bulk_operation_get_server_id` instead.
* `mongoc_bulk_operation_set_hint` is removed. Use `mongoc_bulk_operation_set_server_id` instead.
* Deprecated index management API has been removed:
* Deprecated index management API is removed:
* `mongoc_collection_create_index_with_opts`, `mongoc_collection_create_index`, and `mongoc_collection_ensure_index` are removed. Use `mongoc_collection_create_indexes_with_opts` instead.
* `mongoc_index_opt_t`, `mongoc_index_opt_geo_t` `mongoc_index_opt_wt_t` are removed. Pass options using `bson_t` to `mongoc_collection_create_indexes_with_opts` instead.
* `mongoc_collection_find_indexes` is removed. Use `mongoc_collection_find_indexes_with_opts` instead.
* See [MongoDB documentation](https://www.mongodb.com/docs/languages/c/c-driver/current/indexes/) for working with indexes.
* Deprecated cursor API is removed:
* `mongoc_cursor_is_alive` is removed. Use the equivalent `mongoc_cursor_more` instead.
* `mongoc_cursor_set_hint` is removed. Use the equivalent `mongoc_cursor_set_server_id` instead.
* `mongoc_cursor_get_hint` is removed. Use the equivalent `mongoc_cursor_get_server_id` instead.
* `mongoc_cursor_new_from_command_reply` is removed. Use `mongoc_cursor_new_from_command_reply_with_opts` instead.


### Forwarding headers (`#include <bson.h>` and `#include <mongoc.h>`)

Expand Down
32 changes: 0 additions & 32 deletions src/libmongoc/doc/mongoc_cursor_get_hint.rst

This file was deleted.

63 changes: 0 additions & 63 deletions src/libmongoc/doc/mongoc_cursor_new_from_command_reply.rst

This file was deleted.

38 changes: 0 additions & 38 deletions src/libmongoc/doc/mongoc_cursor_set_hint.rst

This file was deleted.

3 changes: 0 additions & 3 deletions src/libmongoc/doc/mongoc_cursor_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ Example
mongoc_cursor_error
mongoc_cursor_error_document
mongoc_cursor_get_batch_size
mongoc_cursor_get_hint
mongoc_cursor_get_server_id
mongoc_cursor_get_host
mongoc_cursor_get_id
mongoc_cursor_get_limit
mongoc_cursor_get_max_await_time_ms
mongoc_cursor_more
mongoc_cursor_new_from_command_reply
mongoc_cursor_new_from_command_reply_with_opts
mongoc_cursor_next
mongoc_cursor_set_batch_size
mongoc_cursor_set_hint
mongoc_cursor_set_server_id
mongoc_cursor_set_limit
mongoc_cursor_set_max_await_time_ms
Expand Down
37 changes: 0 additions & 37 deletions src/libmongoc/src/mongoc/mongoc-cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,12 +1506,6 @@ mongoc_cursor_get_limit (const mongoc_cursor_t *cursor)
}


bool
mongoc_cursor_set_hint (mongoc_cursor_t *cursor, uint32_t server_id)
{
return mongoc_cursor_set_server_id (cursor, server_id);
}

bool
mongoc_cursor_set_server_id (mongoc_cursor_t *cursor, uint32_t server_id)
{
Expand All @@ -1533,12 +1527,6 @@ mongoc_cursor_set_server_id (mongoc_cursor_t *cursor, uint32_t server_id)
}


uint32_t
mongoc_cursor_get_hint (const mongoc_cursor_t *cursor)
{
return mongoc_cursor_get_server_id (cursor);
}

uint32_t
mongoc_cursor_get_server_id (const mongoc_cursor_t *cursor)
{
Expand Down Expand Up @@ -1583,31 +1571,6 @@ mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor)
}


/* deprecated for mongoc_cursor_new_from_command_reply_with_opts */
mongoc_cursor_t *
mongoc_cursor_new_from_command_reply (mongoc_client_t *client, bson_t *reply, uint32_t server_id)
{
mongoc_cursor_t *cursor;
bson_t cmd = BSON_INITIALIZER;
bson_t opts = BSON_INITIALIZER;

BSON_ASSERT_PARAM (client);
BSON_ASSERT (reply);
/* options are passed through by adding them to reply. */
bsonBuildAppend (*reply, insert (opts, not(key ("cursor", "ok", "operationTime", "$clusterTime", "$gleStats"))));

if (server_id) {
bson_append_int64 (&opts, "serverId", 8, server_id);
}

cursor = _mongoc_cursor_cmd_new_from_reply (client, &cmd, &opts, reply);
bson_destroy (&cmd);
bson_destroy (&opts);

return cursor;
}


mongoc_cursor_t *
mongoc_cursor_new_from_command_reply_with_opts (mongoc_client_t *client, bson_t *reply, const bson_t *opts)
{
Expand Down
5 changes: 0 additions & 5 deletions src/libmongoc/src/mongoc/mongoc-cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ mongoc_cursor_set_max_await_time_ms (mongoc_cursor_t *cursor, uint32_t max_await
MONGOC_EXPORT (uint32_t)
mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor);

BSON_DEPRECATED_FOR (mongoc_cursor_new_from_command_reply_with_opts)
MONGOC_EXPORT (mongoc_cursor_t *)
mongoc_cursor_new_from_command_reply (struct _mongoc_client_t *client, bson_t *reply, uint32_t server_id)
BSON_GNUC_WARN_UNUSED_RESULT;

MONGOC_EXPORT (mongoc_cursor_t *)
mongoc_cursor_new_from_command_reply_with_opts (struct _mongoc_client_t *client, bson_t *reply, const bson_t *opts)
BSON_GNUC_WARN_UNUSED_RESULT;
Expand Down
3 changes: 2 additions & 1 deletion src/libmongoc/tests/test-mongoc-command-monitoring.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ test_reset_callbacks (void)
/* reset callbacks */
mongoc_client_set_apm_callbacks (client, NULL, NULL);
/* destroys cmd_reply */
cursor = mongoc_cursor_new_from_command_reply (client, &cmd_reply, sd->id);
cursor = mongoc_cursor_new_from_command_reply_with_opts (
client, &cmd_reply, tmp_bson ("{'serverId': %" PRIu32 "}", sd->id));
ASSERT (mongoc_cursor_next (cursor, &b));
ASSERT_CMPINT (incremented, ==, 1); /* same value as before */

Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/tests/test-mongoc-exhaust.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ test_cursor_server_hint_with_exhaust (void *unused)
NULL /* read_prefs */);

// Set a bogus server ID.
mongoc_cursor_set_hint (cursor, 123);
mongoc_cursor_set_server_id (cursor, 123);

// Iterate the cursor.
const bson_t *result;
Expand Down