diff options
author | Militsa Sotirova <militsa.sotirova@mongodb.com> | 2023-04-20 15:01:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-20 16:55:18 +0000 |
commit | 504791ab80450817064977dcb11c524e977ebd18 (patch) | |
tree | 893a93a97d9e7bb6ea7b3fbafc445352180d74da /src/mongo/db/commands/run_aggregate.cpp | |
parent | 6b1dcfe922d995648083b032f7c75bf03035879f (diff) | |
download | mongo-504791ab80450817064977dcb11c524e977ebd18.tar.gz |
SERVER-76126 Set user roles system variable only if referenced in query
Diffstat (limited to 'src/mongo/db/commands/run_aggregate.cpp')
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 56c1166506c..9d67caf2df3 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -460,9 +460,6 @@ boost::intrusive_ptr<ExpressionContext> makeExpressionContext( expCtx->changeStreamTokenVersion = 1; } - // Set the value of $$USER_ROLES for the aggregation. - expCtx->setUserRoles(); - return expCtx; } @@ -1022,6 +1019,10 @@ Status runAggregate(OperationContext* opCtx, curOp->beginQueryPlanningTimer(); expCtx->stopExpressionCounters(); + // After parsing to detect if $$USER_ROLES is referenced in the query, set the value of + // $$USER_ROLES for the aggregation. + expCtx->setUserRoles(); + if (!request.getAllowDiskUse().value_or(true)) { allowDiskUseFalseCounter.increment(); } |