summaryrefslogtreecommitdiff
path: root/jstests/aggregation/sources/group/group_by_system_variable.js
blob: 1a455877244926864ed7c91758bae386464737d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * Tests that the server doesn't crash when you group by a system variable.
 * Reproduces SERVER-57164.
 */
(function() {
"use strict";

function testAggWithSystemVariable(varName, explain) {
    try {
        // This query might or might not throw depending on the engine used
        // and whether the variable is defined.
        if (explain)
            call.explain().aggregate({$group: {_id: varName}});
        else
            call.aggregate({$group: {_id: varName}});
    } catch (e) {
    } finally {
        // Make sure the server didn't crash.
        db.hello();
    }
}

testAggWithSystemVariable("$$IS_MR", true);
testAggWithSystemVariable("$$JS_SCOPE", true);
testAggWithSystemVariable("$$CLUSTER_TIME", true);
testAggWithSystemVariable("$$IS_MR");
testAggWithSystemVariable("$$JS_SCOPE");
testAggWithSystemVariable("$$CLUSTER_TIME");
})();