diff options
author | Martin Neupauer <xmaton@messengeruser.com> | 2021-02-22 13:58:45 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-24 01:12:15 +0000 |
commit | 429ce075068f3a011c7fd83f0b5aa95f34aaa308 (patch) | |
tree | 56b0f2f0252470030430e7e935f8e0cee24a02c9 /src/mongo/db | |
parent | dd395723139d3d04cb05c66136a670102be210f1 (diff) | |
download | mongo-429ce075068f3a011c7fd83f0b5aa95f34aaa308.tar.gz |
SERVER-54421 [SBE] Fix tests failing to match a document using {x: null}
predicate when 'x' is missing
This is a partial fix - only a simple cases are convered. The more
complex cases (arrays and traversals) will be covered in the next
commit.
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/query/sbe_stage_builder_filter.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/mongo/db/query/sbe_stage_builder_filter.cpp b/src/mongo/db/query/sbe_stage_builder_filter.cpp index 849f9348192..02a07f83e87 100644 --- a/src/mongo/db/query/sbe_stage_builder_filter.cpp +++ b/src/mongo/db/query/sbe_stage_builder_filter.cpp @@ -608,22 +608,19 @@ void generateComparison(MatchExpressionVisitorContext* context, case sbe::EPrimBinary::neq: break; case sbe::EPrimBinary::greater: { - return {makeFillEmptyFalse(makeNot( - makeFunction("isMinKey", sbe::makeE<sbe::EVariable>(inputSlot)))), + return {makeFillEmptyFalse( + makeNot(makeFunction("isMinKey", makeVariable(inputSlot)))), std::move(inputStage)}; } case sbe::EPrimBinary::greaterEq: { - return {makeFunction("exists", sbe::makeE<sbe::EVariable>(inputSlot)), - std::move(inputStage)}; + return {makeFunction("exists", makeVariable(inputSlot)), std::move(inputStage)}; } case sbe::EPrimBinary::less: { - return {sbe::makeE<sbe::EConstant>(sbe::value::TypeTags::Boolean, - sbe::value::bitcastFrom<bool>(false)), + return {makeConstant(sbe::value::TypeTags::Boolean, false), std::move(inputStage)}; } case sbe::EPrimBinary::lessEq: { - return {makeFillEmptyFalse( - makeFunction("isMinKey", sbe::makeE<sbe::EVariable>(inputSlot))), + return {makeFillEmptyFalse(makeFunction("isMinKey", makeVariable(inputSlot))), std::move(inputStage)}; } default: @@ -635,30 +632,39 @@ void generateComparison(MatchExpressionVisitorContext* context, case sbe::EPrimBinary::neq: break; case sbe::EPrimBinary::greater: { - return {sbe::makeE<sbe::EConstant>(sbe::value::TypeTags::Boolean, - sbe::value::bitcastFrom<bool>(false)), + return {makeConstant(sbe::value::TypeTags::Boolean, false), std::move(inputStage)}; } case sbe::EPrimBinary::greaterEq: { - return {makeFillEmptyFalse( - makeFunction("isMaxKey", sbe::makeE<sbe::EVariable>(inputSlot))), + return {makeFillEmptyFalse(makeFunction("isMaxKey", makeVariable(inputSlot))), std::move(inputStage)}; } case sbe::EPrimBinary::less: { - return {makeFillEmptyFalse(makeNot( - makeFunction("isMaxKey", sbe::makeE<sbe::EVariable>(inputSlot)))), + return {makeFillEmptyFalse( + makeNot(makeFunction("isMaxKey", makeVariable(inputSlot)))), std::move(inputStage)}; } case sbe::EPrimBinary::lessEq: { - return {makeFunction("exists", sbe::makeE<sbe::EVariable>(inputSlot)), - std::move(inputStage)}; + return {makeFunction("exists", makeVariable(inputSlot)), std::move(inputStage)}; } default: break; } + } else if (tag == sbe::value::TypeTags::Null) { + // When comparing to null we have to consider missing and undefined. + auto inputExpr = buildMultiBranchConditional( + CaseValuePair{generateNullOrMissing(sbe::EVariable(inputSlot)), + makeConstant(sbe::value::TypeTags::Null, 0)}, + makeVariable(inputSlot)); + + return {makeFillEmptyFalse(makeBinaryOp(binaryOp, + std::move(inputExpr), + sbe::makeE<sbe::EConstant>(tag, val), + context->env)), + std::move(inputStage)}; } return {makeFillEmptyFalse(makeBinaryOp(binaryOp, - sbe::makeE<sbe::EVariable>(inputSlot), + makeVariable(inputSlot), sbe::makeE<sbe::EConstant>(tag, val), context->env)), std::move(inputStage)}; |