Skip to content

Commit 64dc7a7

Browse files
authored
CDRIVER-2837 remove deprecated bson_oid_init_sequence (#1913)
1 parent 3a4c071 commit 64dc7a7

File tree

8 files changed

+8
-104
lines changed

8 files changed

+8
-104
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ Unreleased (2.0.0)
33

44
## Changes
55

6+
67
* Passing `batchSize:0` as an option to `mongoc_client_watch`, `mongoc_database_watch`, or `mongoc_collection_watch`
78
now applies `batchSize:0` to the `aggregate` command. Useful to request an immediate cursor. Previously the value
89
was ignored.
10+
* `bson_oid_init_sequence` is removed. Use `bson_oid_init` instead.
911

1012
## Removals
1113

src/libbson/doc/bson_oid_init_sequence.rst

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

src/libbson/doc/bson_oid_t.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ You can validate that a string containing a hex-encoded ObjectID is valid using
7070
bson_oid_init_from_data
7171
bson_oid_init_from_string
7272
bson_oid_init_from_string_unsafe
73-
bson_oid_init_sequence
7473
bson_oid_is_valid
7574
bson_oid_to_string
7675

src/libbson/src/bson/bson-context-private.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,6 @@ _bson_context_set_oid_rand (bson_context_t *context, bson_oid_t *oid);
6565
void
6666
_bson_context_set_oid_seq32 (bson_context_t *context, bson_oid_t *oid);
6767

68-
/**
69-
* @brief Write a 64-bit counter from the given context into the OID. Increments
70-
* the context's sequence counter.
71-
*
72-
* @param context The context with the counter to get+update
73-
* @param oid The OID to modify
74-
*
75-
* @note Only used by the deprecated @ref bson_oid_init_sequence
76-
*/
77-
void
78-
_bson_context_set_oid_seq64 (bson_context_t *context, bson_oid_t *oid);
79-
80-
8168
BSON_END_DECLS
8269

8370

src/libbson/src/bson/bson-context.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ _bson_context_set_oid_seq32 (bson_context_t *context, /* IN */
6868
memcpy (&oid->bytes[BSON_OID_SEQ32_OFFSET], ((uint8_t *) &seq) + 1, BSON_OID_SEQ32_SIZE);
6969
}
7070

71-
72-
void
73-
_bson_context_set_oid_seq64 (bson_context_t *context, /* IN */
74-
bson_oid_t *oid) /* OUT */
75-
{
76-
uint64_t seq =
77-
(uint64_t) mcommon_atomic_int64_fetch_add ((int64_t *) &context->seq64, 1, mcommon_memory_order_seq_cst);
78-
79-
seq = BSON_UINT64_TO_BE (seq);
80-
memcpy (&oid->bytes[BSON_OID_SEQ64_OFFSET], &seq, BSON_OID_SEQ64_SIZE);
81-
}
82-
8371
/*
8472
* --------------------------------------------------------------------------
8573
*

src/libbson/src/bson/bson-oid.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ BSON_MAYBE_UNUSED static const uint16_t gHexCharPairs[] = {
7676
#endif
7777
};
7878

79-
static BSON_INLINE void
80-
_oid_init (bson_oid_t *oid, bson_context_t *context, bool add_random)
79+
void
80+
bson_oid_init (bson_oid_t *oid, /* OUT */
81+
bson_context_t *context) /* IN */
8182
{
8283
BSON_ASSERT (oid);
8384
if (!context) {
@@ -90,27 +91,9 @@ _oid_init (bson_oid_t *oid, bson_context_t *context, bool add_random)
9091
oid->bytes[1] = (uint8_t) (now >> 16);
9192
oid->bytes[2] = (uint8_t) (now >> 8);
9293
oid->bytes[3] = (uint8_t) (now >> 0);
93-
// Maybe add randomness if the caller wants it
94-
if (add_random) {
95-
_bson_context_set_oid_rand (context, oid);
96-
_bson_context_set_oid_seq32 (context, oid);
97-
} else {
98-
_bson_context_set_oid_seq64 (context, oid);
99-
}
100-
}
101-
102-
void
103-
bson_oid_init_sequence (bson_oid_t *oid, /* OUT */
104-
bson_context_t *context) /* IN */
105-
{
106-
_oid_init (oid, context, false /* no randomness */);
107-
}
108-
109-
void
110-
bson_oid_init (bson_oid_t *oid, /* OUT */
111-
bson_context_t *context) /* IN */
112-
{
113-
_oid_init (oid, context, true /* add randomness */);
94+
// Add randomness
95+
_bson_context_set_oid_rand (context, oid);
96+
_bson_context_set_oid_seq32 (context, oid);
11497
}
11598

11699

src/libbson/src/bson/bson-oid.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ BSON_EXPORT (void)
5050
bson_oid_init_from_data (bson_oid_t *oid, const uint8_t *data);
5151
BSON_EXPORT (void)
5252
bson_oid_init_from_string (bson_oid_t *oid, const char *str);
53-
BSON_DEPRECATED_FOR (bson_oid_init)
54-
BSON_EXPORT (void) bson_oid_init_sequence (bson_oid_t *oid, bson_context_t *context);
5553
BSON_EXPORT (void)
5654
bson_oid_to_string (const bson_oid_t *oid, char str[25]);
5755

src/libbson/tests/test-oid.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -205,28 +205,6 @@ test_bson_oid_init (void)
205205
}
206206

207207

208-
static void
209-
test_bson_oid_init_sequence (void)
210-
{
211-
bson_context_t *context;
212-
bson_oid_t oid;
213-
bson_oid_t oid2;
214-
int i;
215-
216-
BEGIN_IGNORE_DEPRECATIONS
217-
context = bson_context_new (BSON_CONTEXT_NONE);
218-
bson_oid_init_sequence (&oid, context);
219-
for (i = 0; i < 10000; i++) {
220-
bson_oid_init_sequence (&oid2, context);
221-
BSON_ASSERT (false == bson_oid_equal (&oid, &oid2));
222-
BSON_ASSERT (0 > bson_oid_compare (&oid, &oid2));
223-
bson_oid_copy (&oid2, &oid);
224-
}
225-
bson_context_destroy (context);
226-
END_IGNORE_DEPRECATIONS
227-
}
228-
229-
230208
static char *
231209
get_time_as_string (const bson_oid_t *oid)
232210
{
@@ -476,7 +454,6 @@ test_oid_install (TestSuite *suite)
476454
{
477455
TestSuite_Add (suite, "/bson/oid/init", test_bson_oid_init);
478456
TestSuite_Add (suite, "/bson/oid/init_from_string", test_bson_oid_init_from_string);
479-
TestSuite_Add (suite, "/bson/oid/init_sequence", test_bson_oid_init_sequence);
480457
TestSuite_Add (suite, "/bson/oid/init_with_threads", test_bson_oid_init_with_threads);
481458
TestSuite_Add (suite, "/bson/oid/hash", test_bson_oid_hash);
482459
TestSuite_Add (suite, "/bson/oid/compare", test_bson_oid_compare);

0 commit comments

Comments
 (0)