MySQL 8.0.40
Source Code Documentation
|
This file contains implementation support for the JSON path abstraction. More...
#include "sql-common/json_path.h"
#include "my_rapidjson_size_t.h"
#include <assert.h>
#include <rapidjson/encodings.h>
#include <rapidjson/memorystream.h>
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <string>
#include "m_ctype.h"
#include "m_string.h"
#include "my_inttypes.h"
#include "sql-common/json_dom.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_const.h"
#include "sql_string.h"
#include "template_utils.h"
Classes | |
class | anonymous_namespace{json_path.cc}::Stream |
A simple input stream class for the JSON path parser. More... | |
Namespaces | |
namespace | anonymous_namespace{json_path.cc} |
Functions | |
static bool | is_ecmascript_identifier (const std::string &name) |
Returns true if the name is a valid ECMAScript identifier. More... | |
static bool | is_digit (unsigned codepoint) |
Return true if the codepoint is a Unicode digit. More... | |
static bool | is_whitespace (char ch) |
Is this a whitespace character? More... | |
static bool | parse_path (Stream *stream, Json_path *path, const JsonDocumentDepthHandler &depth_handler) |
Fills in a Json_path from a path expression. More... | |
static bool | parse_path_leg (Stream *stream, Json_path *path, const JsonDocumentDepthHandler &depth_handler) |
Parses a single path leg and appends it to a Json_path object. More... | |
static bool | parse_ellipsis_leg (Stream *stream, Json_path *path) |
Parses a single ellipsis leg and appends it to a Json_path object. More... | |
static bool | parse_array_leg (Stream *stream, Json_path *path) |
Parses a single array leg and appends it to a Json_path object. More... | |
static bool | parse_member_leg (Stream *stream, Json_path *path, const JsonDocumentDepthHandler &depth_handler) |
Parses a single member leg and appends it to a Json_path object. More... | |
static bool | append_array_index (String *buf, size_t index, bool from_end) |
bool | parse_path (size_t path_length, const char *path_expression, Json_path *path, size_t *bad_index, const JsonDocumentDepthHandler &depth_handler) |
Top level parsing factory method. More... | |
static bool | parse_array_index (Stream *stream, uint32 *array_index, bool *from_end) |
Parse an array index in an array cell index or array range path leg. More... | |
static const char * | find_end_of_member_name (const char *start, const char *end) |
Find the end of a member name in a JSON path. More... | |
static std::unique_ptr< Json_string > | parse_name_with_rapidjson (const char *str, size_t len, const JsonDocumentDepthHandler &depth_handler) |
Parse a quoted member name using the rapidjson parser, so that we get the name without the enclosing quotes and with any escape sequences replaced with the actual characters. More... | |
static bool | unicode_combining_mark (unsigned codepoint) |
Return true if the character is a unicode combining mark. More... | |
static bool | is_letter (unsigned codepoint) |
Return true if the codepoint is a Unicode letter. More... | |
static bool | is_connector_punctuation (unsigned codepoint) |
Return true if the codepoint is Unicode connector punctuation. More... | |
Variables | |
constexpr char | anonymous_namespace{json_path.cc}::SCOPE = '$' |
constexpr char | anonymous_namespace{json_path.cc}::BEGIN_MEMBER = '.' |
constexpr char | anonymous_namespace{json_path.cc}::BEGIN_ARRAY = '[' |
constexpr char | anonymous_namespace{json_path.cc}::END_ARRAY = ']' |
constexpr char | anonymous_namespace{json_path.cc}::DOUBLE_QUOTE = '"' |
constexpr char | anonymous_namespace{json_path.cc}::WILDCARD = '*' |
constexpr char | anonymous_namespace{json_path.cc}::MINUS = '-' |
constexpr char | anonymous_namespace{json_path.cc}::LAST [] = "last" |
This file contains implementation support for the JSON path abstraction.
The path abstraction is described by the functional spec attached to WL#7909.
|
static |
|
static |
Find the end of a member name in a JSON path.
The name could be either a quoted or an unquoted identifier.
start | the start of the member name |
end | the end of the JSON path expression |
|
static |
Return true if the codepoint is Unicode connector punctuation.
|
static |
Return true if the codepoint is a Unicode digit.
This was the best recommendation from the old-times about how to answer this question.
|
static |
Returns true if the name is a valid ECMAScript identifier.
The name must be a sequence of UTF8-encoded bytes. All escape sequences have been replaced with UTF8-encoded bytes.
[in] | name | name to check |
|
static |
Return true if the codepoint is a Unicode letter.
This was the best recommendation from the old-timers about how to answer this question. But as you can see from the need to call unicode_combining_mark(), my_isalpha() isn't good enough. It probably has many other defects.
FIXME
|
inlinestatic |
Is this a whitespace character?
|
static |
Parse an array index in an array cell index or array range path leg.
An array index is either a non-negative integer (a 0-based index relative to the beginning of the array), or the keyword "last" (which means the last element in the array), or the keyword "last" followed by a minus ("-") and a non-negative integer (which is the 0-based index relative to the end of the array).
[in,out] | stream | the stream to read the path expression from |
[out] | array_index | gets set to the parsed array index |
[out] | from_end | gets set to true if the array index is relative to the end of the array |
|
static |
Parses a single array leg and appends it to a Json_path object.
[in,out] | stream | The stream to read the path expression from. |
[in,out] | path | The Json_path object to fill. |
|
static |
Parses a single ellipsis leg and appends it to a Json_path object.
[in,out] | stream | The stream to read the path expression from. |
[in,out] | path | The Json_path object to fill. |
|
static |
Parses a single member leg and appends it to a Json_path object.
[in,out] | stream | The stream to read the path expression from. |
[in,out] | path | The Json_path object to fill. |
[in] | depth_handler | Pointer to a function that should handle error occurred when depth is exceeded. |
|
static |
Parse a quoted member name using the rapidjson parser, so that we get the name without the enclosing quotes and with any escape sequences replaced with the actual characters.
It is the caller's responsibility to destroy the returned Json_string when it's done with it.
str | the input string |
len | the length of the input string |
depth_handler | Pointer to a function that should handle error occurred when depth is exceeded. |
bool parse_path | ( | size_t | path_length, |
const char * | path_expression, | ||
Json_path * | path, | ||
size_t * | bad_index, | ||
const JsonDocumentDepthHandler & | depth_handler | ||
) |
Top level parsing factory method.
Initialize a Json_path from a path expression.
|
static |
Fills in a Json_path from a path expression.
[in,out] | stream | The stream to read the path expression from. |
[in,out] | path | The Json_path object to fill. |
[in] | depth_handler | Pointer to a function that should handle error occurred when depth is exceeded. |
|
static |
Parses a single path leg and appends it to a Json_path object.
[in,out] | stream | The stream to read the path expression from. |
[in,out] | path | The Json_path object to fill. |
[in] | depth_handler | Pointer to a function that should handle error occurred when depth is exceeded. |
|
inlinestatic |
Return true if the character is a unicode combining mark.
codepoint | A unicode codepoint. |