@@ -4768,6 +4768,55 @@ test_bulk_write_set_client_updates_operation_id_when_client_changes (void)
4768
4768
mock_server_destroy (mock_server );
4769
4769
}
4770
4770
4771
+ // `test_bulk_big_let` tests a bulk operation with a large let document to reproduce CDRIVER-6112:
4772
+ static void
4773
+ test_bulk_big_let (void * unused )
4774
+ {
4775
+ BSON_UNUSED (unused );
4776
+
4777
+ mongoc_client_t * client = test_framework_new_default_client ();
4778
+ mongoc_collection_t * coll = get_test_collection (client , "test_big_let" );
4779
+ bson_error_t error ;
4780
+
4781
+ // Create bulk operation similar to PHP driver:
4782
+ mongoc_bulk_operation_t * bulk = mongoc_bulk_operation_new (true /* ordered */ );
4783
+
4784
+ // Set a large `let`: { "testDocument": { "a": "aaa..." } }
4785
+ {
4786
+ bson_t let = BSON_INITIALIZER , testDocument ;
4787
+ bson_append_document_begin (& let , "testDocument" , -1 , & testDocument );
4788
+
4789
+ // Append big string:
4790
+ {
4791
+ size_t num_chars = 79 ;
4792
+ char * big_string = bson_malloc0 (num_chars + 1 );
4793
+ memset (big_string , 'a' , num_chars );
4794
+ BSON_APPEND_UTF8 (& testDocument , "a" , big_string );
4795
+ bson_free (big_string );
4796
+ }
4797
+
4798
+ bson_append_document_end (& let , & testDocument );
4799
+ mongoc_bulk_operation_set_let (bulk , & let );
4800
+ bson_destroy (& let );
4801
+ }
4802
+
4803
+
4804
+ mongoc_bulk_operation_set_client (bulk , client );
4805
+ mongoc_bulk_operation_set_database (bulk , "db" );
4806
+ mongoc_bulk_operation_set_collection (bulk , "coll" );
4807
+
4808
+ mongoc_bulk_operation_update (
4809
+ bulk , tmp_bson ("{'_id': 1}" ), tmp_bson ("{'$set': {'document': '$$testDocument'}}" ), true);
4810
+
4811
+
4812
+ ASSERT_OR_PRINT (mongoc_bulk_operation_execute (bulk , NULL , & error ), error );
4813
+
4814
+ mongoc_bulk_operation_destroy (bulk );
4815
+ mongoc_collection_destroy (coll );
4816
+ mongoc_client_destroy (client );
4817
+ }
4818
+
4819
+
4771
4820
void
4772
4821
test_bulk_install (TestSuite * suite )
4773
4822
{
@@ -4946,4 +4995,11 @@ test_bulk_install (TestSuite *suite)
4946
4995
TestSuite_AddMockServerTest (suite ,
4947
4996
"/BulkOperation/set_client_updates_operation_id_when_client_changes" ,
4948
4997
test_bulk_write_set_client_updates_operation_id_when_client_changes );
4998
+ TestSuite_AddFull (
4999
+ suite ,
5000
+ "/BulkOperation/big_let" ,
5001
+ test_bulk_big_let ,
5002
+ NULL ,
5003
+ NULL ,
5004
+ test_framework_skip_if_max_wire_version_less_than_13 /* 5.0+ for 'let' support in CRUD commands */ );
4949
5005
}
0 commit comments