diff options
author | Svilen Mihaylov <svilen.mihaylov@mongodb.com> | 2022-06-21 15:11:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-21 15:56:45 +0000 |
commit | 14e4a3f0521a6a7c1d65b549c013a9cd1c87bfed (patch) | |
tree | d8406c833e43d3fa4bcda5ac1e12d03882f894ce /src | |
parent | 700a1254e2fbd1f5df74d010d214503f24dbbf3a (diff) | |
download | mongo-14e4a3f0521a6a7c1d65b549c013a9cd1c87bfed.tar.gz |
SERVER-67381 Fix lowering of IndexScan
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/exec/sbe/abt/abt_lower.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/db/exec/sbe/abt/abt_lower.cpp b/src/mongo/db/exec/sbe/abt/abt_lower.cpp index f32fe8da661..fc3b4982aa7 100644 --- a/src/mongo/db/exec/sbe/abt/abt_lower.cpp +++ b/src/mongo/db/exec/sbe/abt/abt_lower.cpp @@ -990,9 +990,20 @@ std::unique_ptr<sbe::PlanStage> SBENodeLowering::walk(const IndexScanNode& n, co generateSlots(fieldProjectionMap, ridSlot, rootSlot, fields, vars); uassert(6624233, "Cannot deliver root projection in this context", !rootSlot.has_value()); + std::vector<std::pair<size_t, sbe::value::SlotId>> indexVars; sbe::IndexKeysInclusionSet indexKeysToInclude; - for (const std::string& fieldName : fields) { - indexKeysToInclude.set(decodeIndexKeyName(fieldName), true); + + for (size_t index = 0; index < fields.size(); index++) { + const size_t indexFieldPos = decodeIndexKeyName(fields.at(index)); + indexVars.emplace_back(indexFieldPos, vars.at(index)); + indexKeysToInclude.set(indexFieldPos, true); + } + + // Make sure vars are in sorted order on index field position. + std::sort(indexVars.begin(), indexVars.end()); + vars.clear(); + for (const auto& [indexFieldPos, slot] : indexVars) { + vars.push_back(slot); } auto lowerBoundExpr = convertBoundsToExpr(true /*isLower*/, indexDef, interval); |