SERVER-117854 Add assert on inf numberfor GranularityRounderPowersOfTwo (#47606)
GitOrigin-RevId: 1bdac3ba9f86f936d16cef4296e2e58d6e228138
This commit is contained in:
parent
aea6ff0e69
commit
c03686cacb
@ -0,0 +1,25 @@
|
||||
// @tags: [requires_fcv_82, requires_sbe]
|
||||
|
||||
const coll = db.bucket_auto_pow2_inf;
|
||||
coll.drop();
|
||||
|
||||
assert.commandWorked(coll.insert({_id: 0}));
|
||||
|
||||
// Construct a groupBy expression that overflows to +Infinity on the server.
|
||||
//
|
||||
// 1e308 is a large but finite double. The $add is evaluated by the server, not
|
||||
// by the shell, so the server will see two finite doubles and add them in
|
||||
// C++ as `double`, overflowing to +Infinity (IEEE-754).
|
||||
const pipeline = [
|
||||
{
|
||||
$bucketAuto: {
|
||||
groupBy: {$add: [1e308, 1e308]},
|
||||
buckets: 2,
|
||||
granularity: "POWERSOF2",
|
||||
output: {count: {$sum: 1}},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
assert.commandFailedWithCode(coll.runCommand("aggregate", {pipeline: pipeline, cursor: {}}),
|
||||
11785400);
|
||||
@ -66,6 +66,7 @@ void uassertNonNegativeNumber(Value value) {
|
||||
double number = value.coerceToDouble();
|
||||
uassert(40266, "A granularity rounder cannot round NaN", !std::isnan(number));
|
||||
uassert(40267, "A granularity rounder can only round non-negative numbers", number >= 0.0);
|
||||
uassert(11785400, "A granularity rounder can only round finite numbers", std::isfinite(number));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user