MySQL 8.3.0
Source Code Documentation
walk_access_paths.h File Reference
#include <type_traits>
#include "sql/join_optimizer/access_path.h"
#include "sql/range_optimizer/range_optimizer.h"

Go to the source code of this file.

Enumerations

enum class  WalkAccessPathPolicy { STOP_AT_MATERIALIZATION , ENTIRE_QUERY_BLOCK , ENTIRE_TREE }
 

Functions

template<class AccessPathPtr , class Func , class JoinPtr >
void WalkAccessPaths (AccessPathPtr path, JoinPtr join, WalkAccessPathPolicy cross_query_blocks, Func &&func, bool post_order_traversal=false)
 Traverse every access path below path (possibly limited to the current query block with the cross_query_blocks parameter), calling func() for each one with pre- or post-order traversal. More...
 
template<class Func >
void WalkTablesUnderAccessPath (AccessPath *root_path, Func &&func, bool include_pruned_tables)
 A wrapper around WalkAccessPaths() that collects all tables under “root_path” and calls the given functor, stopping at materializations. More...
 

Enumeration Type Documentation

◆ WalkAccessPathPolicy

enum class WalkAccessPathPolicy
strong
Enumerator
STOP_AT_MATERIALIZATION 
ENTIRE_QUERY_BLOCK 
ENTIRE_TREE 

Function Documentation

◆ WalkAccessPaths()

template<class AccessPathPtr , class Func , class JoinPtr >
void WalkAccessPaths ( AccessPathPtr  path,
JoinPtr  join,
WalkAccessPathPolicy  cross_query_blocks,
Func &&  func,
bool  post_order_traversal = false 
)

Traverse every access path below path (possibly limited to the current query block with the cross_query_blocks parameter), calling func() for each one with pre- or post-order traversal.

If func() returns true, the traversal does not descend into the children of the current path. For post-order traversal, the children have already been traversed when func() is called, so it is too late to skip them, and the return value of func() is effectively ignored.

The join parameter signifies what query block path is part of, since that is not implicit from the path itself. The function will track this as it changes throughout the tree (in MATERIALIZE or STREAM access paths), and will give the correct value to the func() callback. It is only used by WalkAccessPaths() itself if the policy is ENTIRE_QUERY_BLOCK; if not, it is only used for the func() callback, and you can set it to nullptr if you wish. func() must have signature func(AccessPath *, const JOIN *), or it could be JOIN * if a non-const JOIN is given in.

◆ WalkTablesUnderAccessPath()

template<class Func >
void WalkTablesUnderAccessPath ( AccessPath root_path,
Func &&  func,
bool  include_pruned_tables 
)

A wrapper around WalkAccessPaths() that collects all tables under “root_path” and calls the given functor, stopping at materializations.

This is typically used to know which tables to sort or the like.

func() must have signature func(TABLE *), and return true upon error.