From f2dc89bcbbd4d51ab059eb109042fd2cf3f4e330 Mon Sep 17 00:00:00 2001 From: Alex Li <98560274+lia394126@users.noreply.github.com> Date: Thu, 22 Jan 2026 10:57:19 -0500 Subject: [PATCH] SERVER-115662 Change safe_num.h to be a part of the "core" module (#46460) GitOrigin-RevId: c1949a6554e45b30c71c6949126c32849983034f --- modules_poc/modules.yaml | 1 - src/mongo/db/commands.cpp | 1 - src/mongo/db/commands/query_cmd/write_commands.cpp | 1 - src/mongo/db/exec/classic/upsert_stage.cpp | 1 - src/mongo/db/exec/mutable_bson/mutable_bson_algo_test.cpp | 2 -- src/mongo/db/pipeline/expression_from_accumulator_quantile.h | 1 - src/mongo/db/repl/repl_set_config_test.cpp | 1 - src/mongo/db/update/pop_node_test.cpp | 1 - src/mongo/db/update/update_util.h | 1 - src/mongo/db/update/v2_log_builder_test.cpp | 1 - src/mongo/util/safe_num.h | 5 +++-- 11 files changed, 3 insertions(+), 13 deletions(-) diff --git a/modules_poc/modules.yaml b/modules_poc/modules.yaml index 66202ad26c9..b0d24a89341 100644 --- a/modules_poc/modules.yaml +++ b/modules_poc/modules.yaml @@ -241,7 +241,6 @@ query: - src/mongo/s/query/shard_targeting_helpers* - src/mongo/db/namespace_spec.idl # only used by query - src/mongo/s/commands/*document_shard_key_* - - src/mongo/util/safe_num* - src/mongo/db/s/*analyze_shard_key* - src/mongo/s/*analyze_shard_key* - src/mongo/s/*query_analyze* diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 6ba1ca8f717..8cd61fadfd9 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -63,7 +63,6 @@ #include "mongo/util/duration.h" #include "mongo/util/fail_point.h" #include "mongo/util/namespace_string_util.h" -#include "mongo/util/safe_num.h" #include "mongo/util/static_immortal.h" #include "mongo/util/str.h" #include "mongo/util/string_map.h" diff --git a/src/mongo/db/commands/query_cmd/write_commands.cpp b/src/mongo/db/commands/query_cmd/write_commands.cpp index 06bef688dc1..d782afd9cb9 100644 --- a/src/mongo/db/commands/query_cmd/write_commands.cpp +++ b/src/mongo/db/commands/query_cmd/write_commands.cpp @@ -91,7 +91,6 @@ #include "mongo/util/decorable.h" #include "mongo/util/fail_point.h" #include "mongo/util/namespace_string_util.h" -#include "mongo/util/safe_num.h" #include "mongo/util/serialization_context.h" #include "mongo/util/str.h" diff --git a/src/mongo/db/exec/classic/upsert_stage.cpp b/src/mongo/db/exec/classic/upsert_stage.cpp index d5979c13976..7a6c31b39b1 100644 --- a/src/mongo/db/exec/classic/upsert_stage.cpp +++ b/src/mongo/db/exec/classic/upsert_stage.cpp @@ -65,7 +65,6 @@ #include "mongo/util/assert_util.h" #include "mongo/util/decorable.h" #include "mongo/util/fail_point.h" -#include "mongo/util/safe_num.h" #include "mongo/util/str.h" #include diff --git a/src/mongo/db/exec/mutable_bson/mutable_bson_algo_test.cpp b/src/mongo/db/exec/mutable_bson/mutable_bson_algo_test.cpp index aab541e3f1a..d28b566c221 100644 --- a/src/mongo/db/exec/mutable_bson/mutable_bson_algo_test.cpp +++ b/src/mongo/db/exec/mutable_bson/mutable_bson_algo_test.cpp @@ -37,8 +37,6 @@ #include "mongo/db/exec/mutable_bson/mutable_bson_test_utils.h" #include "mongo/db/query/collation/collator_interface_mock.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/safe_num.h" - namespace { diff --git a/src/mongo/db/pipeline/expression_from_accumulator_quantile.h b/src/mongo/db/pipeline/expression_from_accumulator_quantile.h index 2eb9ced1c28..c376dc916a0 100644 --- a/src/mongo/db/pipeline/expression_from_accumulator_quantile.h +++ b/src/mongo/db/pipeline/expression_from_accumulator_quantile.h @@ -41,7 +41,6 @@ #include "mongo/db/pipeline/variables.h" #include "mongo/db/query/query_shape/serialization_options.h" #include "mongo/util/modules.h" -#include "mongo/util/safe_num.h" #include diff --git a/src/mongo/db/repl/repl_set_config_test.cpp b/src/mongo/db/repl/repl_set_config_test.cpp index f4ab19c3c94..81a553e6149 100644 --- a/src/mongo/db/repl/repl_set_config_test.cpp +++ b/src/mongo/db/repl/repl_set_config_test.cpp @@ -43,7 +43,6 @@ #include "mongo/idl/server_parameter_test_controller.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" -#include "mongo/util/safe_num.h" #include "mongo/util/scopeguard.h" #include diff --git a/src/mongo/db/update/pop_node_test.cpp b/src/mongo/db/update/pop_node_test.cpp index e1624b20780..1c49dee2bcc 100644 --- a/src/mongo/db/update/pop_node_test.cpp +++ b/src/mongo/db/update/pop_node_test.cpp @@ -38,7 +38,6 @@ #include "mongo/unittest/death_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" -#include "mongo/util/safe_num.h" #include diff --git a/src/mongo/db/update/update_util.h b/src/mongo/db/update/update_util.h index b26fbac09b3..21e4b43b184 100644 --- a/src/mongo/db/update/update_util.h +++ b/src/mongo/db/update/update_util.h @@ -38,7 +38,6 @@ #include "mongo/db/query/write_ops/write_ops_gen.h" #include "mongo/db/update/update_driver.h" #include "mongo/util/modules.h" -#include "mongo/util/safe_num.h" #include diff --git a/src/mongo/db/update/v2_log_builder_test.cpp b/src/mongo/db/update/v2_log_builder_test.cpp index 70a9f75dd8f..b15e9d919d2 100644 --- a/src/mongo/db/update/v2_log_builder_test.cpp +++ b/src/mongo/db/update/v2_log_builder_test.cpp @@ -37,7 +37,6 @@ #include "mongo/db/field_ref.h" #include "mongo/unittest/death_test.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/safe_num.h" #include #include diff --git a/src/mongo/util/safe_num.h b/src/mongo/util/safe_num.h index 020fbcaf8f2..aa52aebe0fd 100644 --- a/src/mongo/util/safe_num.h +++ b/src/mongo/util/safe_num.h @@ -34,6 +34,7 @@ #include "mongo/bson/bsonobjbuilder.h" #include "mongo/bson/bsontypes.h" #include "mongo/platform/decimal128.h" +#include "mongo/util/modules.h" #include #include @@ -73,7 +74,7 @@ class Value; * newValue.toBSON(fieldName, &bsonObjBuilder); * */ -class SafeNum { +class MONGO_MOD_PUBLIC SafeNum { public: SafeNum(); ~SafeNum(); @@ -189,7 +190,7 @@ private: BSONType _type; // Value of the safe num. Indeterminate if _type is EOO. - union { + MONGO_MOD_NEEDS_REPLACEMENT union { int32_t int32Val; int64_t int64Val; double doubleVal;