MySQL 9.1.0
Source Code Documentation
Json_path_cache Class Reference

Path cache for JSON functions. More...

#include <item_json_func.h>

Classes

struct  Path_cell
 Struct that points to a cell in m_paths and tells its status. More...
 

Public Member Functions

 Json_path_cache (THD *thd, uint size)
 Json_path_cache. More...
 
 ~Json_path_cache ()
 
bool parse_and_cache_path (const THD *thd, Item **args, uint arg_idx, bool forbid_wildcards)
 Parse a path expression if necessary. More...
 
const Json_pathget_path (uint arg_idx) const
 Return an already parsed path expression. More...
 
void reset_cache ()
 Reset the cache for re-use when a statement is re-executed. More...
 

Private Types

enum class  enum_path_status : uint8 { UNINITIALIZED , OK_NOT_NULL , OK_NULL }
 Enum that tells the status of a cell in m_paths. More...
 

Private Attributes

String m_path_value
 Holder for path strings. More...
 
Prealloced_array< Json_path, 8 > m_paths
 List of paths. More...
 
Mem_root_array< Path_cellm_arg_idx_to_vector_idx
 Map argument indexes to indexes into m_paths. More...
 

Detailed Description

Path cache for JSON functions.

Caches parsed path objects for arguments which are string literals. Maintains a vector of path objects and an array of ints which map path argument numbers to slots in the array.

Member Enumeration Documentation

◆ enum_path_status

enum class Json_path_cache::enum_path_status : uint8
strongprivate

Enum that tells the status of a cell in m_paths.

Enumerator
UNINITIALIZED 
OK_NOT_NULL 
OK_NULL 

Constructor & Destructor Documentation

◆ Json_path_cache()

Json_path_cache::Json_path_cache ( THD thd,
uint  size 
)

Json_path_cache.

◆ ~Json_path_cache()

Json_path_cache::~Json_path_cache ( )
default

Member Function Documentation

◆ get_path()

const Json_path * Json_path_cache::get_path ( uint  arg_idx) const

Return an already parsed path expression.

Parameters
[in]arg_idxIndex of the path_expression in the JSON function args
Returns
the already parsed path, possibly NULL

◆ parse_and_cache_path()

bool Json_path_cache::parse_and_cache_path ( const THD thd,
Item **  args,
uint  arg_idx,
bool  forbid_wildcards 
)

Parse a path expression if necessary.

Does nothing if the path expression is constant and it has already been parsed. Assumes that we've already verified that the path expression is not null. Raises an error if the path expression is syntactically incorrect. Raises an error if the path expression contains wildcard tokens but is not supposed to. Otherwise puts the parsed path onto the path vector.

Parameters
[in]thdTHD handle
[in]argsArray of args to a JSON function
[in]arg_idxIndex of the path_expression in args
[in]forbid_wildcardsTrue if the path shouldn't contain * or **
Returns
false on success (valid path or NULL), true on error

◆ reset_cache()

void Json_path_cache::reset_cache ( )

Reset the cache for re-use when a statement is re-executed.

Member Data Documentation

◆ m_arg_idx_to_vector_idx

Mem_root_array<Path_cell> Json_path_cache::m_arg_idx_to_vector_idx
private

Map argument indexes to indexes into m_paths.

◆ m_path_value

String Json_path_cache::m_path_value
private

Holder for path strings.

◆ m_paths

Prealloced_array<Json_path, 8> Json_path_cache::m_paths
private

List of paths.


The documentation for this class was generated from the following files: