MySQL 9.1.0
Source Code Documentation
|
This file contains interface support for the JSON path abstraction. More...
#include <assert.h>
#include <stddef.h>
#include <algorithm>
#include <new>
#include <string>
#include <string_view>
#include <utility>
#include "my_alloc.h"
#include "mysql/psi/psi_memory.h"
#include "prealloced_array.h"
Go to the source code of this file.
Classes | |
class | Json_array_index |
A class that represents the index of an element in a JSON array. More... | |
class | Json_path_leg |
One path leg in a JSON path expression. More... | |
struct | Json_path_leg::Array_range |
A structure that represents an array range. More... | |
class | Json_seekable_path |
A path expression which can be used to seek to a position inside a JSON value. More... | |
class | Json_path |
A JSON path expression. More... | |
class | Json_path_clone |
A lightweight path expression. More... | |
Typedefs | |
using | Json_path_leg_pointers = Prealloced_array< const Json_path_leg *, 8 > |
using | Json_path_iterator = Json_path_leg_pointers::const_iterator |
Enumerations | |
enum | enum_json_path_leg_type { jpl_member , jpl_array_cell , jpl_array_range , jpl_member_wildcard , jpl_array_cell_wildcard , jpl_ellipsis } |
The type of a Json_path_leg. More... | |
Functions | |
bool | parse_path (size_t path_length, const char *path_expression, Json_path *path, size_t *bad_index) |
Initialize a Json_path from a path expression. More... | |
bool | parse_path (const String &path_value, bool forbid_wildcards, Json_path *json_path) |
A helper function that uses the above one as workhorse. More... | |
bool | clone_without_autowrapping (const Json_path *source_path, Json_path_clone *target_path, Json_wrapper *doc, PSI_memory_key key) |
Clone a source path to a target path, stripping out legs which are made redundant by the auto-wrapping rule from the WL#7909 spec and further extended in the WL#9831 spec: More... | |
This file contains interface support for the JSON path abstraction.
The path abstraction is described by the functional spec attached to WL#7909.
using Json_path_leg_pointers = Prealloced_array<const Json_path_leg *, 8> |
The type of a Json_path_leg.
bool clone_without_autowrapping | ( | const Json_path * | source_path, |
Json_path_clone * | target_path, | ||
Json_wrapper * | doc, | ||
PSI_memory_key | key | ||
) |
Clone a source path to a target path, stripping out legs which are made redundant by the auto-wrapping rule from the WL#7909 spec and further extended in the WL#9831 spec:
"If an array cell path leg or an array range path leg is evaluated against a non-array value, the result of the evaluation is the same as if the non-array value had been wrapped in a single-element array."
[in] | source_path | The original path. |
[in,out] | target_path | The clone to be filled in. |
[in] | doc | The document to seek through. |
[in] | key | Instrumented memory key |
A helper function that uses the above one as workhorse.
Entry point for for JSON_TABLE (Table_function_json class) and Json_path_cache. 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 updates the supplied Json_path object with the parsed path.
[in] | path_value | A String to be interpreted as a path. |
[in] | forbid_wildcards | True if the path shouldn't contain * or ** |
[out] | json_path | The object that will hold the parsed path |
bool parse_path | ( | size_t | path_length, |
const char * | path_expression, | ||
Json_path * | path, | ||
size_t * | bad_index | ||
) |
Initialize a Json_path from a path expression.
Stops parsing on the first error. It initializes the Json_path and returns false if the path is parsed successfully. Otherwise, it returns false. In that case, the output bad_index argument will contain an index into the path expression. The parsing failed near that index.
[in] | path_length | The length of the path expression. |
[in] | path_expression | The string form of the path expression. |
[out] | path | The Json_path object to be initialized. |
[out] | bad_index | If null is returned, the parsing failed around here. |
Initialize a Json_path from a path expression.