MySQL 9.1.0
Source Code Documentation
json_diff.cc File Reference
#include "sql-common/json_diff.h"
#include <cassert>
#include <optional>
#include <utility>
#include "my_alloc.h"
#include "my_byteorder.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sys.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql-common/json_binary.h"
#include "sql-common/json_dom.h"
#include "sql-common/json_error_handler.h"
#include "sql-common/json_path.h"
#include "sql/current_thd.h"
#include "sql/log_event.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql_string.h"
#include "template_utils.h"

Functions

static size_t length_of_length_and_string (size_t length)
 Return the total size of a data field, plus the size of the preceding integer that describes the length, when the integer is stored in net_field_length() format. More...
 
static bool write_length_and_string (String *to, const String &from)
 Encode a String as (length, data) pair, with length being stored in net_field_length() format. More...
 
optional< ReadJsonDiffResultread_json_diff (const unsigned char *pos, size_t length)
 Read one JSON diff from a buffer. More...
 
static Json_domseek_exact_path (Json_dom *dom, const Json_path_iterator &first_leg, const Json_path_iterator &last_leg)
 Find the value at the specified path in a JSON DOM. More...
 
enum_json_diff_status apply_json_diff (const Json_diff &diff, Json_dom *dom)
 Apply one JSON diff to the DOM provided. More...
 

Variables

static MEM_ROOT empty_json_diff_vector_mem_root (PSI_NOT_INSTRUMENTED, 256)
 

Function Documentation

◆ apply_json_diff()

enum_json_diff_status apply_json_diff ( const Json_diff diff,
Json_dom dom 
)

Apply one JSON diff to the DOM provided.

Parameters
diffThe diff which contains the path to apply it and the new value.
domThe DOM to apply the diff to.
Returns
An enum_json_diff_status value that tells if the diff was applied successfully.

◆ length_of_length_and_string()

static size_t length_of_length_and_string ( size_t  length)
static

Return the total size of a data field, plus the size of the preceding integer that describes the length, when the integer is stored in net_field_length() format.

Parameters
lengthThe length of the data
Returns
The length of the data plus the length of the length field.

◆ read_json_diff()

optional< ReadJsonDiffResult > read_json_diff ( const unsigned char *  pos,
size_t  length 
)

Read one JSON diff from a buffer.

Parameters
posThe position to start reading from in the buffer. When the function returns, it will be set to the position right after the last byte read.
lengthThe maximum number of bytes to read from the buffer.
Returns
An object containing the Json_diff value and the number of bytes read, if successful. An empty value if an error was raised, or if the buffer did not contain a valid diff.

◆ seek_exact_path()

static Json_dom * seek_exact_path ( Json_dom dom,
const Json_path_iterator first_leg,
const Json_path_iterator last_leg 
)
static

Find the value at the specified path in a JSON DOM.

The path should not contain any wildcard or ellipsis, only simple array cells or member names. Auto-wrapping is not performed.

Parameters
domthe root of the DOM
first_legthe first path leg
last_legthe last path leg (exclusive)
Returns
the JSON DOM at the given path, or nullptr if the path is not found

◆ write_length_and_string()

static bool write_length_and_string ( String to,
const String from 
)
static

Encode a String as (length, data) pair, with length being stored in net_field_length() format.

Parameters
toBuffer where length and data will be stored.
fromSource string containing the data.
Returns
true on out of memory, false on success.

Variable Documentation

◆ empty_json_diff_vector_mem_root

MEM_ROOT empty_json_diff_vector_mem_root(PSI_NOT_INSTRUMENTED, 256) ( PSI_NOT_INSTRUMENTED  ,
256   
)
static