@@ -4800,6 +4800,54 @@ test_multiple_execution(void)
4800
4800
mongoc_client_destroy (client );
4801
4801
}
4802
4802
4803
+ // `test_bulk_big_let` tests a bulk operation with a large let document to reproduce CDRIVER-6112:
4804
+ static void
4805
+ test_bulk_big_let (void * unused )
4806
+ {
4807
+ BSON_UNUSED (unused );
4808
+
4809
+ mongoc_client_t * client = test_framework_new_default_client ();
4810
+ mongoc_collection_t * coll = get_test_collection (client , "test_big_let" );
4811
+ bson_error_t error ;
4812
+
4813
+ // Create bulk operation similar to PHP driver:
4814
+ mongoc_bulk_operation_t * bulk = mongoc_bulk_operation_new (true /* ordered */ );
4815
+
4816
+ // Set a large `let`: { "testDocument": { "a": "aaa..." } }
4817
+ {
4818
+ bson_t let = BSON_INITIALIZER , testDocument ;
4819
+ bson_append_document_begin (& let , "testDocument" , -1 , & testDocument );
4820
+
4821
+ // Append big string:
4822
+ {
4823
+ size_t num_chars = 79 ;
4824
+ char * big_string = bson_malloc0 (num_chars + 1 );
4825
+ memset (big_string , 'a' , num_chars );
4826
+ BSON_APPEND_UTF8 (& testDocument , "a" , big_string );
4827
+ bson_free (big_string );
4828
+ }
4829
+
4830
+ bson_append_document_end (& let , & testDocument );
4831
+ mongoc_bulk_operation_set_let (bulk , & let );
4832
+ bson_destroy (& let );
4833
+ }
4834
+
4835
+
4836
+ mongoc_bulk_operation_set_client (bulk , client );
4837
+ mongoc_bulk_operation_set_database (bulk , "db" );
4838
+ mongoc_bulk_operation_set_collection (bulk , "coll" );
4839
+
4840
+ mongoc_bulk_operation_update (
4841
+ bulk , tmp_bson ("{'_id': 1}" ), tmp_bson ("{'$set': {'document': '$$testDocument'}}" ), true);
4842
+
4843
+
4844
+ ASSERT_OR_PRINT (mongoc_bulk_operation_execute (bulk , NULL , & error ), error );
4845
+
4846
+ mongoc_bulk_operation_destroy (bulk );
4847
+ mongoc_collection_destroy (coll );
4848
+ mongoc_client_destroy (client );
4849
+ }
4850
+
4803
4851
4804
4852
void
4805
4853
test_bulk_install (TestSuite * suite )
@@ -4978,4 +5026,11 @@ test_bulk_install(TestSuite *suite)
4978
5026
"/BulkOperation/set_client_updates_operation_id_when_client_changes" ,
4979
5027
test_bulk_write_set_client_updates_operation_id_when_client_changes );
4980
5028
TestSuite_AddLive (suite , "/BulkOperation/multiple_execution" , test_multiple_execution );
5029
+ TestSuite_AddFull (
5030
+ suite ,
5031
+ "/BulkOperation/big_let" ,
5032
+ test_bulk_big_let ,
5033
+ NULL ,
5034
+ NULL ,
5035
+ test_framework_skip_if_max_wire_version_less_than_13 /* 5.0+ for 'let' support in CRUD commands */ );
4981
5036
}
0 commit comments