diff options
author | Martin Neupauer <martin.neupauer@mongodb.com> | 2019-03-29 13:30:05 -0400 |
---|---|---|
committer | Martin Neupauer <martin.neupauer@mongodb.com> | 2019-04-02 15:29:04 -0400 |
commit | 7792dd86907d8731e9faefaaacc1eef296c44425 (patch) | |
tree | aa85e834c9343dadc5dc6c3653c60c637d6cb15f /src | |
parent | 0d524262b183781aa6efa44431bd815110d746d7 (diff) | |
download | mongo-7792dd86907d8731e9faefaaacc1eef296c44425.tar.gz |
SERVER-40213 Test upgrade/downgrade for $$NOW/$$CLUSTER_TIME in a view definition
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/pipeline/expression.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index f842c88c1c9..d61854b3ba3 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -1946,7 +1946,22 @@ intrusive_ptr<ExpressionFieldPath> ExpressionFieldPath::parse( const StringData fieldPath = rawSD.substr(2); // strip off $$ const StringData varName = fieldPath.substr(0, fieldPath.find('.')); Variables::uassertValidNameForUserRead(varName); - return new ExpressionFieldPath(expCtx, fieldPath.toString(), vps.getVariable(varName)); + auto varId = vps.getVariable(varName); + // $$NOW and $$CLUSTER_TIME are available only in 4.2 and up. + // The check should be removed when 4.2 becomes the last stable version. + if (varId == Variables::kNowId || varId == Variables::kClusterTimeId) { + uassert(ErrorCodes::QueryFeatureNotAllowed, + str::stream() + << "'$$" + << varName + << "' is not allowed in the current feature compatibility version. See " + << feature_compatibility_version_documentation::kCompatibilityLink + << " for more information.", + !expCtx->maxFeatureCompatibilityVersion || + (ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42 <= + *expCtx->maxFeatureCompatibilityVersion)); + } + return new ExpressionFieldPath(expCtx, fieldPath.toString(), varId); } else { return new ExpressionFieldPath(expCtx, "CURRENT." + raw.substr(1), // strip the "$" prefix |