Skip to content

Commit 7deb768

Browse files
authored
CDRIVER-5948 remove deprecated cursor API (#1959)
* remove `mongoc_cursor_get_hint` * remove `mongoc_cursor_set_hint` * remove `mongoc_cursor_new_from_command_reply` * reword NEWS for consistency
1 parent a48eb43 commit 7deb768

9 files changed

+26
-198
lines changed

NEWS

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@ Unreleased (2.0.0)
5151
* `mongoc_server_description_ismaster` is removed. Use the equivalent `mongoc_server_description_hello` instead.
5252
* `MONGOC_QUERY_SLAVE_OK` is removed. Use the equivalent `MONGOC_QUERY_SECONDARY_OK` instead.
5353
* `MONGOC_URI_SLAVEOK` is removed. It was unused.
54-
* `mongoc_collection_save` is removed. Use `mongoc_collection_insert_one` or `mongoc_collection_replace_one` instead.
5554
* `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.
5655
* `MONGOC_URI_MAXIDLETIMEMS` and `MONGOC_URI_WAITQUEUEMULTIPLE` are removed. They were unused.
5756
* `bson_string_t` and associated functions are removed.
58-
* `mongoc_cursor_is_alive` is removed. Use the equivalent `mongoc_cursor_more` instead.
59-
* `mongoc_collection_delete` is removed. Use `mongoc_collection_delete_one` or `mongoc_collection_delete_many` instead.
60-
* `mongoc_delete_flags_t` and `mongoc_reply_flags_t` are removed.
6157
* Support for `ENABLE_SASL=CYRUS` on Windows is removed. Use `ENABLE_SASL=SSPI` or `ENABLE_SASL=OFF` instead.
6258
* The associated Windows-only option `CYRUS_PLUGIN_PATH_PREFIX` is removed.
6359
* Support for the deprecated `minPoolSize` URI option is removed along with associated API: `MONGOC_URI_MINPOOLSIZE` and `mongoc_client_pool_min_size`.
@@ -74,24 +70,33 @@ Unreleased (2.0.0)
7470
* `mongoc_bulk_operation_get_hint` is removed. Use `mongoc_bulk_operation_get_server_id` instead.
7571
* `mongoc_bulk_operation_set_hint` is removed. Use `mongoc_bulk_operation_set_server_id` instead.
7672
* Deprecated `mongoc_apm_command_*_get_server_connection_id` functions are removed. Use `mongoc_apm_command_*_get_server_connection_id_int64` instead.
77-
* Deprecated index management API has been removed:
73+
* Deprecated index management API is removed:
7874
* `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.
7975
* `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.
8076
* `mongoc_collection_find_indexes` is removed. Use `mongoc_collection_find_indexes_with_opts` instead.
8177
* See [MongoDB documentation](https://www.mongodb.com/docs/languages/c/c-driver/current/indexes/) for working with indexes.
82-
* `mongoc_collection_find` is removed. Use `mongoc_collection_find_with_opts` instead.
83-
* `mongoc_collection_insert_bulk` is removed. Use `mongoc_collection_insert_many` instead.
84-
* `mongoc_collection_create_bulk_operation` is removed. Use `mongoc_collection_create_bulk_operation_with_opts` instead.
85-
* `mongoc_collection_get_last_error` is removed. To get results from write operations, instead use:
86-
- `mongoc_collection_update_one`
87-
- `mongoc_collection_update_many`
88-
- `mongoc_collection_replace_one`
89-
- `mongoc_collection_delete_one`
90-
- `mongoc_collection_delete_many`
91-
- `mongoc_collection_insert_one`
92-
- `mongoc_collection_insert_many`
93-
- `mongoc_bulkwrite_t`
94-
- `mongoc_bulk_operation_t`
78+
* Deprecated cursor API is removed:
79+
* `mongoc_cursor_is_alive` is removed. Use the equivalent `mongoc_cursor_more` instead.
80+
* `mongoc_cursor_set_hint` is removed. Use the equivalent `mongoc_cursor_set_server_id` instead.
81+
* `mongoc_cursor_get_hint` is removed. Use the equivalent `mongoc_cursor_get_server_id` instead.
82+
* `mongoc_cursor_new_from_command_reply` is removed. Use `mongoc_cursor_new_from_command_reply_with_opts` instead.
83+
* Deprecated CRUD API is removed:
84+
* `mongoc_collection_save` is removed. Use `mongoc_collection_insert_one` or `mongoc_collection_replace_one` instead.
85+
* `mongoc_collection_delete` is removed. Use `mongoc_collection_delete_one` or `mongoc_collection_delete_many` instead.
86+
* `mongoc_delete_flags_t` and `mongoc_reply_flags_t` are removed.
87+
* `mongoc_collection_find` is removed. Use `mongoc_collection_find_with_opts` instead.
88+
* `mongoc_collection_insert_bulk` is removed. Use `mongoc_collection_insert_many` instead.
89+
* `mongoc_collection_create_bulk_operation` is removed. Use `mongoc_collection_create_bulk_operation_with_opts` instead.
90+
* `mongoc_collection_get_last_error` is removed. To get results from write operations, instead use:
91+
* `mongoc_collection_update_one`
92+
* `mongoc_collection_update_many`
93+
* `mongoc_collection_replace_one`
94+
* `mongoc_collection_delete_one`
95+
* `mongoc_collection_delete_many`
96+
* `mongoc_collection_insert_one`
97+
* `mongoc_collection_insert_many`
98+
* `mongoc_bulkwrite_t`
99+
* `mongoc_bulk_operation_t`
95100
* `mongoc_collection_stats` is removed. Use the [$collStats aggregation pipeline stage](https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/) with `mongoc_collection_aggregate` instead.
96101
* `mongoc_collection_validate` is removed. Run the [validate](https://www.mongodb.com/docs/manual/reference/command/validate/) command directly with `mongoc_client_read_command_with_opts` instead.
97102

src/libmongoc/doc/mongoc_cursor_get_hint.rst

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/libmongoc/doc/mongoc_cursor_new_from_command_reply.rst

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/libmongoc/doc/mongoc_cursor_set_hint.rst

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/libmongoc/doc/mongoc_cursor_t.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,15 @@ Example
5151
mongoc_cursor_error
5252
mongoc_cursor_error_document
5353
mongoc_cursor_get_batch_size
54-
mongoc_cursor_get_hint
5554
mongoc_cursor_get_server_id
5655
mongoc_cursor_get_host
5756
mongoc_cursor_get_id
5857
mongoc_cursor_get_limit
5958
mongoc_cursor_get_max_await_time_ms
6059
mongoc_cursor_more
61-
mongoc_cursor_new_from_command_reply
6260
mongoc_cursor_new_from_command_reply_with_opts
6361
mongoc_cursor_next
6462
mongoc_cursor_set_batch_size
65-
mongoc_cursor_set_hint
6663
mongoc_cursor_set_server_id
6764
mongoc_cursor_set_limit
6865
mongoc_cursor_set_max_await_time_ms

src/libmongoc/src/mongoc/mongoc-cursor.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,12 +1506,6 @@ mongoc_cursor_get_limit (const mongoc_cursor_t *cursor)
15061506
}
15071507

15081508

1509-
bool
1510-
mongoc_cursor_set_hint (mongoc_cursor_t *cursor, uint32_t server_id)
1511-
{
1512-
return mongoc_cursor_set_server_id (cursor, server_id);
1513-
}
1514-
15151509
bool
15161510
mongoc_cursor_set_server_id (mongoc_cursor_t *cursor, uint32_t server_id)
15171511
{
@@ -1533,12 +1527,6 @@ mongoc_cursor_set_server_id (mongoc_cursor_t *cursor, uint32_t server_id)
15331527
}
15341528

15351529

1536-
uint32_t
1537-
mongoc_cursor_get_hint (const mongoc_cursor_t *cursor)
1538-
{
1539-
return mongoc_cursor_get_server_id (cursor);
1540-
}
1541-
15421530
uint32_t
15431531
mongoc_cursor_get_server_id (const mongoc_cursor_t *cursor)
15441532
{
@@ -1583,31 +1571,6 @@ mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor)
15831571
}
15841572

15851573

1586-
/* deprecated for mongoc_cursor_new_from_command_reply_with_opts */
1587-
mongoc_cursor_t *
1588-
mongoc_cursor_new_from_command_reply (mongoc_client_t *client, bson_t *reply, uint32_t server_id)
1589-
{
1590-
mongoc_cursor_t *cursor;
1591-
bson_t cmd = BSON_INITIALIZER;
1592-
bson_t opts = BSON_INITIALIZER;
1593-
1594-
BSON_ASSERT_PARAM (client);
1595-
BSON_ASSERT (reply);
1596-
/* options are passed through by adding them to reply. */
1597-
bsonBuildAppend (*reply, insert (opts, not(key ("cursor", "ok", "operationTime", "$clusterTime", "$gleStats"))));
1598-
1599-
if (server_id) {
1600-
bson_append_int64 (&opts, "serverId", 8, server_id);
1601-
}
1602-
1603-
cursor = _mongoc_cursor_cmd_new_from_reply (client, &cmd, &opts, reply);
1604-
bson_destroy (&cmd);
1605-
bson_destroy (&opts);
1606-
1607-
return cursor;
1608-
}
1609-
1610-
16111574
mongoc_cursor_t *
16121575
mongoc_cursor_new_from_command_reply_with_opts (mongoc_client_t *client, bson_t *reply, const bson_t *opts)
16131576
{

src/libmongoc/src/mongoc/mongoc-cursor.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ mongoc_cursor_set_max_await_time_ms (mongoc_cursor_t *cursor, uint32_t max_await
9393
MONGOC_EXPORT (uint32_t)
9494
mongoc_cursor_get_max_await_time_ms (const mongoc_cursor_t *cursor);
9595

96-
BSON_DEPRECATED_FOR (mongoc_cursor_new_from_command_reply_with_opts)
97-
MONGOC_EXPORT (mongoc_cursor_t *)
98-
mongoc_cursor_new_from_command_reply (struct _mongoc_client_t *client, bson_t *reply, uint32_t server_id)
99-
BSON_GNUC_WARN_UNUSED_RESULT;
100-
10196
MONGOC_EXPORT (mongoc_cursor_t *)
10297
mongoc_cursor_new_from_command_reply_with_opts (struct _mongoc_client_t *client, bson_t *reply, const bson_t *opts)
10398
BSON_GNUC_WARN_UNUSED_RESULT;

src/libmongoc/tests/test-mongoc-command-monitoring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ test_reset_callbacks (void)
291291
/* reset callbacks */
292292
mongoc_client_set_apm_callbacks (client, NULL, NULL);
293293
/* destroys cmd_reply */
294-
cursor = mongoc_cursor_new_from_command_reply (client, &cmd_reply, sd->id);
294+
cursor = mongoc_cursor_new_from_command_reply_with_opts (
295+
client, &cmd_reply, tmp_bson ("{'serverId': %" PRIu32 "}", sd->id));
295296
ASSERT (mongoc_cursor_next (cursor, &b));
296297
ASSERT_CMPINT (incremented, ==, 1); /* same value as before */
297298

src/libmongoc/tests/test-mongoc-exhaust.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ test_cursor_server_hint_with_exhaust (void *unused)
465465
NULL /* read_prefs */);
466466

467467
// Set a bogus server ID.
468-
mongoc_cursor_set_hint (cursor, 123);
468+
mongoc_cursor_set_server_id (cursor, 123);
469469

470470
// Iterate the cursor.
471471
const bson_t *result;

0 commit comments

Comments
 (0)