@@ -836,6 +836,8 @@ _mongoc_write_command_execute (
836
836
mongoc_client_session_t * cs , /* IN */
837
837
mongoc_write_result_t * result ) /* OUT */
838
838
{
839
+ mongoc_crud_opts_t crud = {0 };
840
+
839
841
ENTRY ;
840
842
841
843
BSON_ASSERT (command );
@@ -858,83 +860,17 @@ _mongoc_write_command_execute (
858
860
EXIT ;
859
861
}
860
862
861
- if (command -> flags .has_collation ) {
862
- if (!mongoc_write_concern_is_acknowledged (write_concern )) {
863
- result -> failed = true;
864
- bson_set_error (& result -> error ,
865
- MONGOC_ERROR_COMMAND ,
866
- MONGOC_ERROR_COMMAND_INVALID_ARG ,
867
- "Cannot set collation for unacknowledged writes" );
868
- EXIT ;
869
- }
870
- if (server_stream -> sd -> max_wire_version < WIRE_VERSION_COLLATION ) {
871
- bson_set_error (& result -> error ,
872
- MONGOC_ERROR_COMMAND ,
873
- MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION ,
874
- "Collation is not supported by the selected server" );
875
- result -> failed = true;
876
- EXIT ;
877
- }
878
- }
879
- if (command -> flags .bypass_document_validation !=
880
- MONGOC_BYPASS_DOCUMENT_VALIDATION_DEFAULT ) {
881
- if (!mongoc_write_concern_is_acknowledged (write_concern )) {
882
- result -> failed = true;
883
- bson_set_error (
884
- & result -> error ,
885
- MONGOC_ERROR_COMMAND ,
886
- MONGOC_ERROR_COMMAND_INVALID_ARG ,
887
- "Cannot set bypassDocumentValidation for unacknowledged writes" );
888
- EXIT ;
889
- }
890
- }
891
- if (command -> payload .len == 0 ) {
892
- _empty_error (command , & result -> error );
893
- EXIT ;
894
- }
895
-
896
- if (server_stream -> sd -> max_wire_version >= WIRE_VERSION_OP_MSG ) {
897
- if (cs && !mongoc_write_concern_is_acknowledged (write_concern )) {
898
- bson_set_error (
899
- & result -> error ,
900
- MONGOC_ERROR_COMMAND ,
901
- MONGOC_ERROR_COMMAND_INVALID_ARG ,
902
- "Cannot use client session with unacknowledged writes" );
903
- EXIT ;
904
- }
905
- _mongoc_write_opmsg (command ,
906
- client ,
907
- server_stream ,
908
- database ,
909
- collection ,
910
- write_concern ,
911
- offset ,
912
- cs ,
913
- result ,
914
- & result -> error );
915
- } else {
916
- if (mongoc_write_concern_is_acknowledged (write_concern )) {
917
- _mongoc_write_opquery (command ,
918
- client ,
919
- server_stream ,
920
- database ,
921
- collection ,
922
- write_concern ,
923
- offset ,
924
- result ,
925
- & result -> error );
926
- } else {
927
- gLegacyWriteOps [command -> type ](command ,
928
- client ,
929
- server_stream ,
930
- database ,
931
- collection ,
932
- offset ,
933
- result ,
934
- & result -> error );
935
- }
936
- }
937
-
863
+ crud .client_session = cs ;
864
+ crud .writeConcern = (mongoc_write_concern_t * ) write_concern ;
865
+
866
+ _mongoc_write_command_execute_idl (command ,
867
+ client ,
868
+ server_stream ,
869
+ database ,
870
+ collection ,
871
+ offset ,
872
+ & crud ,
873
+ result );
938
874
EXIT ;
939
875
}
940
876
0 commit comments