diff options
-rw-r--r-- | buildscripts/gdb/mongo_printers.py | 101 | ||||
-rw-r--r-- | src/mongo/db/query/optimizer/syntax/syntax.h | 8 |
2 files changed, 94 insertions, 15 deletions
diff --git a/buildscripts/gdb/mongo_printers.py b/buildscripts/gdb/mongo_printers.py index c6230527678..76ac681c1aa 100644 --- a/buildscripts/gdb/mongo_printers.py +++ b/buildscripts/gdb/mongo_printers.py @@ -946,27 +946,98 @@ class MemoPrinter(OptimizerTypePrinter): def register_abt_printers(pp): """Registers a number of pretty printers related to the CQF optimizer.""" + # IntervalRequirement printer. + pp.add("Interval", "mongo::optimizer::IntervalRequirement", False, IntervalPrinter) + + # Memo printer. + pp.add("Memo", "mongo::optimizer::cascades::Memo", False, MemoPrinter) + + # PartialSchemaRequirements printer. + schema_req_type = """std::multimap<mongo::optimizer::PartialSchemaKey, + mongo::optimizer::PartialSchemaRequirement, + mongo::optimizer::PartialSchemaKeyLessComparator, + std::allocator<std::pair<mongo::optimizer::PartialSchemaKey const, + mongo::optimizer::PartialSchemaRequirement> + > >""" + pp.add("PartialSchemaRequirements", schema_req_type, False, PartialSchemaReqMapPrinter) + + # Attempt to dynamically load the ABT type since it has a templated type set that is bound to + # change. This may fail on certain builds, such as those with dynamically linked libraries, so + # we catch the lookup error and fallback to registering the static type name which may be + # stale. try: # ABT printer. abt_type = gdb.lookup_type("mongo::optimizer::ABT").strip_typedefs() pp.add('ABT', abt_type.name, False, ABTPrinter) - abt_ref_type = gdb.lookup_type(abt_type.name + "::Reference").strip_typedefs() + abt_ref_type = abt_type.name + "::Reference" # We can re-use the same printer since an ABT is contructable from an ABT::Reference. - pp.add('ABT::Reference', abt_ref_type.name, False, ABTPrinter) - - # IntervalRequirement printer. - pp.add("Interval", "mongo::optimizer::IntervalRequirement", False, IntervalPrinter) - - # PartialSchemaRequirements printer. - schema_req_type = gdb.lookup_type( - "mongo::optimizer::PartialSchemaRequirements").strip_typedefs() - pp.add("PartialSchemaRequirements", schema_req_type.name, False, PartialSchemaReqMapPrinter) - - # Memo printer. - pp.add("Memo", "mongo::optimizer::cascades::Memo", False, MemoPrinter) - except gdb.error as gdberr: - print("Failed to add one or more ABT pretty printers, skipping: " + str(gdberr)) + pp.add('ABT::Reference', abt_ref_type, False, ABTPrinter) + except gdb.error: + # ABT printer. + abt_type_set = ["Blackhole", + "Constant", + "Variable", + "UnaryOp", + "BinaryOp", + "If", + "Let", + "LambdaAbstraction", + "LambdaApplication", + "FunctionCall", + "EvalPath", + "EvalFilter", + "Source", + "PathConstant", + "PathLambda", + "PathIdentity", + "PathDefault", + "PathCompare", + "PathDrop", + "PathKeep", + "PathObj", + "PathArr", + "PathTraverse", + "PathField", + "PathGet", + "PathComposeM", + "PathComposeA", + "ScanNode", + "PhysicalScanNode", + "ValueScanNode", + "CoScanNode", + "IndexScanNode", + "SeekNode", + "MemoLogicalDelegatorNode", + "MemoPhysicalDelegatorNode", + "FilterNode", + "EvaluationNode", + "SargableNode", + "RIDIntersectNode", + "BinaryJoinNode", + "HashJoinNode", + "MergeJoinNode", + "UnionNode", + "GroupByNode", + "UnwindNode", + "UniqueNode", + "CollationNode", + "LimitSkipNode", + "ExchangeNode", + "RootNode", + "References", + "ExpressionBinder"] + abt_type = "mongo::optimizer::algebra::PolyValue<" + for type_name in abt_type_set: + abt_type += "mongo::optimizer::" + type_name + if type_name != "ExpressionBinder": + abt_type += ", " + abt_type += ">" + pp.add('ABT', abt_type, False, ABTPrinter) + + abt_ref_type = abt_type + "::Reference" + # We can re-use the same printer since an ABT is contructable from an ABT::Reference. + pp.add('ABT::Reference', abt_ref_type, False, ABTPrinter) def build_pretty_printer(): diff --git a/src/mongo/db/query/optimizer/syntax/syntax.h b/src/mongo/db/query/optimizer/syntax/syntax.h index d44d32fbc00..03f35718871 100644 --- a/src/mongo/db/query/optimizer/syntax/syntax.h +++ b/src/mongo/db/query/optimizer/syntax/syntax.h @@ -39,6 +39,14 @@ namespace mongo::optimizer { +/** + * This is the core typedef that represents an abstract binding tree (ABT). The templated types + * represent all possible instances for a given ABT operator, each deriving from an Operator class + * that indicates the number of children nodes. + * + * NOTE: If the set of possible types in an ABT changes, please update the corresponding gdb + * pretty printer. + */ using ABT = algebra::PolyValue<Blackhole, Constant, // expressions Variable, |