summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/sbe/values/value.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/sbe/values/value.h')
-rw-r--r--src/mongo/db/exec/sbe/values/value.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/exec/sbe/values/value.h b/src/mongo/db/exec/sbe/values/value.h
index 728a0c16634..d0202b0f1c0 100644
--- a/src/mongo/db/exec/sbe/values/value.h
+++ b/src/mongo/db/exec/sbe/values/value.h
@@ -154,6 +154,9 @@ enum class TypeTags : uint8_t {
// Pointer to a IndexBounds object.
indexBounds,
+
+ // Pointer to a classic engine match expression.
+ classicMatchExpresion,
};
inline constexpr bool isNumber(TypeTags tag) noexcept {
@@ -1249,6 +1252,10 @@ inline IndexBounds* getIndexBoundsView(Value val) noexcept {
return reinterpret_cast<IndexBounds*>(val);
}
+inline MatchExpression* getClassicMatchExpressionView(Value val) noexcept {
+ return reinterpret_cast<MatchExpression*>(val);
+}
+
/**
* Pattern and flags of Regex are stored in BSON as two C strings written one after another.
*
@@ -1450,6 +1457,12 @@ inline std::pair<TypeTags, Value> copyValue(TypeTags tag, Value val) {
return makeCopyCollator(*getCollatorView(val));
case TypeTags::indexBounds:
return makeCopyIndexBounds(*getIndexBoundsView(val));
+ case TypeTags::classicMatchExpresion:
+ // Beware: "shallow cloning" a match expression does not copy the underlying BSON. The
+ // original BSON must remain alive for both the original MatchExpression and the clone.
+ return {TypeTags::classicMatchExpresion,
+ bitcastFrom<const MatchExpression*>(
+ getClassicMatchExpressionView(val)->shallowClone().release())};
default:
break;
}