Skip to content

Commit 35af0c2

Browse files
committed
Revert "CDRIVER-1322: mongoc_collection_aggregate_with_write_concern"
This reverts commit 2ba99c4. Conflicts: tests/test-mongoc-collection.c
1 parent af28608 commit 35af0c2

File tree

7 files changed

+1
-130
lines changed

7 files changed

+1
-130
lines changed

build/autotools/versions.ldscript

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ LIBMONGOC_1.4 {
334334
mongoc_client_set_apm_callbacks;
335335
mongoc_client_set_appname;
336336
mongoc_client_set_error_api;
337-
mongoc_collection_aggregate_with_write_concern;
338337
mongoc_cursor_get_limit;
339338
mongoc_cursor_new_from_command_reply;
340339
mongoc_cursor_set_hint;

build/cmake/libmongoc-experimental.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ mongoc_client_set_read_prefs
9090
mongoc_client_set_stream_initiator
9191
mongoc_client_set_write_concern
9292
mongoc_collection_aggregate
93-
mongoc_collection_aggregate_with_write_concern
9493
mongoc_collection_command
9594
mongoc_collection_command_simple
9695
mongoc_collection_copy

build/cmake/libmongoc-ssl-experimental.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ mongoc_client_set_ssl_opts
9292
mongoc_client_set_stream_initiator
9393
mongoc_client_set_write_concern
9494
mongoc_collection_aggregate
95-
mongoc_collection_aggregate_with_write_concern
9695
mongoc_collection_command
9796
mongoc_collection_command_simple
9897
mongoc_collection_copy

src/libmongoc.symbols

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ mongoc_client_set_ssl_opts
9494
mongoc_client_set_stream_initiator
9595
mongoc_client_set_write_concern
9696
mongoc_collection_aggregate
97-
mongoc_collection_aggregate_with_write_concern
9897
mongoc_collection_command
9998
mongoc_collection_command_simple
10099
mongoc_collection_copy

src/mongoc/mongoc-collection.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,12 @@ mongoc_collection_copy (mongoc_collection_t *collection) /* IN */
295295
*--------------------------------------------------------------------------
296296
*/
297297

298-
299298
mongoc_cursor_t *
300299
mongoc_collection_aggregate (mongoc_collection_t *collection, /* IN */
301300
mongoc_query_flags_t flags, /* IN */
302301
const bson_t *pipeline, /* IN */
303302
const bson_t *options, /* IN */
304303
const mongoc_read_prefs_t *read_prefs) /* IN */
305-
{
306-
return mongoc_collection_aggregate_with_write_concern (collection, flags,
307-
pipeline, options,
308-
read_prefs, NULL);
309-
}
310-
311-
312-
mongoc_cursor_t *
313-
mongoc_collection_aggregate_with_write_concern (
314-
mongoc_collection_t *collection, /* IN */
315-
mongoc_query_flags_t flags, /* IN */
316-
const bson_t *pipeline, /* IN */
317-
const bson_t *options, /* IN */
318-
const mongoc_read_prefs_t *read_prefs,
319-
mongoc_write_concern_t *write_concern) /* IN */
320304
{
321305
mongoc_server_description_t *selected_server = NULL;
322306
mongoc_cursor_t *cursor;
@@ -343,10 +327,6 @@ mongoc_collection_aggregate_with_write_concern (
343327
GOTO (done);
344328
}
345329

346-
if (!_mongoc_write_concern_validate (write_concern, &cursor->error)) {
347-
GOTO (done);
348-
}
349-
350330
selected_server = mongoc_topology_select(collection->client->topology,
351331
MONGOC_SS_READ,
352332
read_prefs,
@@ -427,13 +407,6 @@ mongoc_collection_aggregate_with_write_concern (
427407
BSON_APPEND_DOCUMENT (&command, "readConcern", read_concern_bson);
428408
}
429409

430-
if (write_concern &&
431-
!_mongoc_write_concern_is_default (write_concern) &&
432-
selected_server->max_wire_version >= WIRE_VERSION_CMD_WRITE_CONCERN) {
433-
bson_append_document (&command, "writeConcern", 12,
434-
_mongoc_write_concern_get_bson (write_concern));
435-
}
436-
437410
if (use_cursor) {
438411
_mongoc_cursor_cursorid_init (cursor, &command);
439412
} else {

src/mongoc/mongoc-collection.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ mongoc_cursor_t *mongoc_collection_aggregate (mongoc_col
4343
const bson_t *pipeline,
4444
const bson_t *options,
4545
const mongoc_read_prefs_t *read_prefs) BSON_GNUC_WARN_UNUSED_RESULT;
46-
mongoc_cursor_t *mongoc_collection_aggregate_with_write_concern
47-
(mongoc_collection_t *collection,
48-
mongoc_query_flags_t flags,
49-
const bson_t *pipeline,
50-
const bson_t *options,
51-
const mongoc_read_prefs_t *read_prefs,
52-
mongoc_write_concern_t *write_concern) BSON_GNUC_WARN_UNUSED_RESULT;
5346
void mongoc_collection_destroy (mongoc_collection_t *collection);
5447
mongoc_collection_t *mongoc_collection_copy (mongoc_collection_t *collection);
5548
mongoc_cursor_t *mongoc_collection_command (mongoc_collection_t *collection,

tests/test-mongoc-collection.c

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <mongoc-client-private.h>
44
#include <mongoc-cursor-private.h>
55
#include <mongoc-collection-private.h>
6-
#include <mongoc-write-concern-private.h>
76

87
#include "TestSuite.h"
98

@@ -13,93 +12,6 @@
1312
#include "mock_server/mock-server.h"
1413

1514

16-
static void
17-
test_aggregate_w_write_concern (void *context) {
18-
mongoc_cursor_t *cursor;
19-
mongoc_client_t *client;
20-
mongoc_collection_t *collection;
21-
mongoc_write_concern_t *good_wc;
22-
mongoc_write_concern_t *bad_wc;
23-
bson_t *pipeline;
24-
char *json;
25-
bool wire_version_5;
26-
const bson_t *doc;
27-
bson_error_t error;
28-
29-
/* set up */
30-
good_wc = mongoc_write_concern_new ();
31-
bad_wc = mongoc_write_concern_new ();
32-
33-
client = test_framework_client_new ();
34-
assert (client);
35-
ASSERT (mongoc_client_set_error_api (client, 2));
36-
37-
collection = mongoc_client_get_collection (client, "test", "test");
38-
39-
/* determine server config */
40-
wire_version_5 = test_framework_max_wire_version_at_least (5);
41-
42-
/* pipeline that writes to collection */
43-
json = bson_strdup_printf ("[{'$out': '%s'}]",
44-
collection->collection);
45-
pipeline = tmp_bson (json);
46-
47-
/* collection aggregate with valid writeConcern: no error */
48-
mongoc_write_concern_set_w (good_wc, 1);
49-
cursor = mongoc_collection_aggregate_with_write_concern (
50-
collection, MONGOC_QUERY_NONE,
51-
pipeline, NULL, NULL, good_wc);
52-
ASSERT (cursor);
53-
mongoc_cursor_next (cursor, &doc);
54-
55-
ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error);
56-
mongoc_cursor_destroy (cursor);
57-
58-
/* writeConcern that will not pass mongoc_write_concern_is_valid */
59-
bad_wc->wtimeout = -10;
60-
cursor = mongoc_collection_aggregate_with_write_concern (
61-
collection, MONGOC_QUERY_NONE,
62-
pipeline, NULL, NULL, bad_wc);
63-
ASSERT (cursor);
64-
ASSERT_ERROR_CONTAINS (
65-
cursor->error, MONGOC_ERROR_COMMAND,
66-
MONGOC_ERROR_COMMAND_INVALID_ARG,
67-
"Invalid mongoc_write_concern_t");
68-
bad_wc->wtimeout = 0;
69-
70-
/* collection aggregate with invalid writeConcern: skip mongos */
71-
if (!test_framework_is_mongos ()) {
72-
mongoc_cursor_destroy (cursor);
73-
74-
mongoc_write_concern_set_w (bad_wc, 99);
75-
cursor = mongoc_collection_aggregate_with_write_concern (
76-
collection, MONGOC_QUERY_NONE,
77-
pipeline, NULL, NULL, bad_wc);
78-
ASSERT (cursor);
79-
80-
mongoc_cursor_next (cursor, &doc);
81-
82-
if (wire_version_5) {
83-
if (test_framework_is_replset ()) { /* replica set */
84-
ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error);
85-
} else { /* standalone */
86-
ASSERT_CMPINT (cursor->error.domain, ==, MONGOC_ERROR_SERVER);
87-
ASSERT_CMPINT (cursor->error.code, ==, 2);
88-
}
89-
} else { /* if server wire version <= 4, no error */
90-
ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error);
91-
}
92-
}
93-
94-
mongoc_write_concern_destroy (good_wc);
95-
mongoc_write_concern_destroy (bad_wc);
96-
mongoc_collection_destroy (collection);
97-
mongoc_cursor_destroy (cursor);
98-
mongoc_client_destroy (client);
99-
bson_free (json);
100-
}
101-
102-
10315
static void
10416
test_read_prefs_is_valid (void) {
10517
mongoc_collection_t *collection;
@@ -3451,10 +3363,7 @@ test_collection_install (TestSuite *suite)
34513363
{
34523364
test_aggregate_install (suite);
34533365

3454-
TestSuite_AddFull (suite, "/Collection/aggregate/write_concern",
3455-
test_aggregate_w_write_concern, NULL, NULL,
3456-
test_framework_skip_if_max_version_version_less_than_2);
3457-
TestSuite_AddLive (suite, "/Collection/read_prefs_is_valid",
3366+
TestSuite_AddLive (suite, "/Collection/read_prefs_is_valid",
34583367
test_read_prefs_is_valid);
34593368
TestSuite_AddLive (suite, "/Collection/insert_bulk", test_insert_bulk);
34603369
TestSuite_AddLive (suite,

0 commit comments

Comments
 (0)