1#ifndef JSON_BINARY_INCLUDED 
    2#define JSON_BINARY_INCLUDED 
  148#include <string_view> 
  167#if defined(WIN32) && defined(EXPORT_JSON_FUNCTIONS) 
  168#define EXPORT_JSON_FUNCTION __declspec(dllexport) 
  170#define EXPORT_JSON_FUNCTION 
  362                      size_t *space) 
const;
 
  366                        size_t data_length, 
const char *original,
 
  367                        char *destination, 
bool *changed) 
const;
 
  369                        const char *original, 
char *destination) 
const;
 
  372  bool has_space(
size_t pos, 
size_t needed, 
size_t *offset) 
const;
 
  393  Value(
const char *data, uint32_t len)
 
  477  int eq(
const Value &val) 
const;
 
  535                       bool *inlined) 
const;
 
  578template <
typename Func>
 
  580  if (func(
value)) 
return true;
 
  583    for (
size_t i = 0, 
size = 
value.element_count(); i < 
size; ++i)
 
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
 
A field that stores a JSON value.
Definition: field.h:3835
 
Error handler for the functions that serialize a JSON value in the JSON binary storage format.
Definition: json_error_handler.h:49
 
JSON DOM abstract base class.
Definition: json_dom.h:178
 
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1225
 
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
 
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
 
Class used for reading JSON values that are stored in the binary format.
Definition: json_binary.h:234
 
double m_double_value
The value if the type is DOUBLE.
Definition: json_binary.h:504
 
EXPORT_JSON_FUNCTION uint32_t element_count() const
Get the number of elements in an array, or the number of members in an object.
Definition: json_binary.h:327
 
EXPORT_JSON_FUNCTION const char * get_data() const
Get a pointer to the beginning of the STRING or OPAQUE data represented by this instance.
Definition: json_binary.h:270
 
EXPORT_JSON_FUNCTION Value(enum_field_types ft, const char *data, uint32_t len)
Constructor for values that represent opaque data.
Definition: json_binary.h:419
 
EXPORT_JSON_FUNCTION Value key(size_t pos) const
Get the key of the member stored at the specified position in a JSON object.
Definition: json_binary.cc:1146
 
EXPORT_JSON_FUNCTION enum_field_types field_type() const
Get the MySQL field type of an opaque value.
Definition: json_binary.h:337
 
EXPORT_JSON_FUNCTION Value(enum_type t, const char *data, uint32_t bytes, uint32_t element_count, bool large)
Constructor for values that represent arrays or objects.
Definition: json_binary.h:407
 
EXPORT_JSON_FUNCTION int64_t get_int64() const
Get the value of an INT.
Definition: json_binary.h:303
 
bool m_large
True if an array or an object uses the large storage format with 4 byte offsets instead of 2 byte off...
Definition: json_binary.h:531
 
EXPORT_JSON_FUNCTION Value(const char *data, uint32_t len)
Constructor for values that represent strings.
Definition: json_binary.h:393
 
int64_t m_int_value
The value if the type is INT or UINT.
Definition: json_binary.h:502
 
EXPORT_JSON_FUNCTION uint32_t get_data_length() const
Get the length in bytes of the STRING or OPAQUE value represented by this instance.
Definition: json_binary.h:280
 
EXPORT_JSON_FUNCTION size_t value_entry_offset(size_t pos) const
Get the offset of the value entry that describes the element at a given position in this array or obj...
Definition: json_binary.cc:1537
 
bool first_value_offset(size_t *offset) const
Find the lowest possible offset where a value can be located inside this array or object.
Definition: json_binary.cc:1391
 
EXPORT_JSON_FUNCTION bool is_object() const
Is this value an object?
Definition: json_binary.h:432
 
EXPORT_JSON_FUNCTION bool to_std_string(std::string *buffer, const JsonErrorHandler &depth_handler) const
Format the JSON value to an external JSON string in buffer in the format of ISO/IEC 10646.
Definition: json_binary.cc:2124
 
EXPORT_JSON_FUNCTION bool to_pretty_std_string(std::string *buffer, const JsonErrorHandler &depth_handler) const
Format the JSON value to an external JSON string in buffer in the format of ISO/IEC 10646.
Definition: json_binary.cc:2136
 
EXPORT_JSON_FUNCTION const char * get_container_data() const
Definition: json_binary.h:296
 
EXPORT_JSON_FUNCTION Value(double val)
Constructor for values that represent doubles.
Definition: json_binary.h:389
 
EXPORT_JSON_FUNCTION Value lookup(std::string_view key) const
Get the value associated with the specified key in a JSON object.
Definition: json_binary.cc:1183
 
EXPORT_JSON_FUNCTION bool get_free_space(const JsonSerializationErrorHandler &error_handler, size_t *space) const
Get the amount of unused space in the binary representation of this value.
Definition: json_binary.cc:1983
 
uint32_t m_length
The full length (in bytes) of the binary representation of an array or object, or the length of a str...
Definition: json_binary.h:516
 
enum_type
Definition: json_binary.h:236
 
@ DOUBLE
Definition: json_binary.h:242
 
@ LITERAL_FALSE
Definition: json_binary.h:245
 
@ INT
Definition: json_binary.h:240
 
@ STRING
Definition: json_binary.h:239
 
@ OBJECT
Definition: json_binary.h:237
 
@ LITERAL_TRUE
Definition: json_binary.h:244
 
@ ERROR
Definition: json_binary.h:247
 
@ LITERAL_NULL
Definition: json_binary.h:243
 
@ UINT
Definition: json_binary.h:241
 
@ OPAQUE
Definition: json_binary.h:246
 
@ ARRAY
Definition: json_binary.h:238
 
EXPORT_JSON_FUNCTION uint32_t get_container_length() const
Get the length in bytes of the STRING or OPAQUE value represented by this instance.
Definition: json_binary.h:290
 
EXPORT_JSON_FUNCTION Value()
Empty constructor.
Definition: json_binary.h:424
 
EXPORT_JSON_FUNCTION enum_type type() const
Definition: json_binary.h:259
 
EXPORT_JSON_FUNCTION bool has_space(size_t pos, size_t needed, size_t *offset) const
Does this array or object have enough space to replace the value at the given position with another v...
Definition: json_binary.cc:1423
 
int eq(const Value &val) const
Compare two Values.
Definition: json_binary.cc:2077
 
EXPORT_JSON_FUNCTION Value(enum_type t)
Constructor for values that represent literals or errors.
Definition: json_binary.h:376
 
enum_field_types m_field_type
The MySQL field type of the value, in case the type of the value is OPAQUE.
Definition: json_binary.h:522
 
EXPORT_JSON_FUNCTION bool is_array() const
Is this value an array?
Definition: json_binary.h:428
 
EXPORT_JSON_FUNCTION Value element(size_t pos) const
Get the element at the specified position of a JSON array or a JSON object.
Definition: json_binary.cc:1107
 
EXPORT_JSON_FUNCTION bool large_format() const
Does this value use the large storage format?
Definition: json_binary.h:263
 
EXPORT_JSON_FUNCTION bool is_backed_by(const String *str) const
Is this binary value pointing to data that is contained in the specified string.
Definition: json_binary.cc:1244
 
enum_type m_type
The JSON type of the value.
Definition: json_binary.h:525
 
bool update_in_shadow(const Field_json *field, size_t pos, Json_wrapper *new_value, size_t data_offset, size_t data_length, const char *original, char *destination, bool *changed) const
Update a value in an array or object.
Definition: json_binary.cc:1741
 
bool remove_in_shadow(const Field_json *field, size_t pos, const char *original, char *destination) const
Remove a value from an array or object.
Definition: json_binary.cc:1929
 
const char * m_data
Pointer to the start of the binary representation of the value.
Definition: json_binary.h:500
 
EXPORT_JSON_FUNCTION size_t lookup_index(std::string_view key) const
Get the index of the element with the specified key in a JSON object.
Definition: json_binary.cc:1196
 
EXPORT_JSON_FUNCTION uint64_t get_uint64() const
Get the value of a UINT.
Definition: json_binary.h:310
 
EXPORT_JSON_FUNCTION size_t key_entry_offset(size_t pos) const
Get the offset of the key entry that describes the key of the member at a given position in this obje...
Definition: json_binary.cc:1524
 
EXPORT_JSON_FUNCTION bool raw_binary(const JsonSerializationErrorHandler &error_handler, String *buf) const
Copy the binary representation of this value into a buffer, replacing the contents of the receiving b...
Definition: json_binary.cc:1269
 
EXPORT_JSON_FUNCTION bool is_valid() const
Does this value, and all of its members, represent a valid JSON value?
Definition: json_binary.cc:881
 
bool element_offsets(size_t pos, size_t *start, size_t *end, bool *inlined) const
Find the start offset and the end offset of the specified element.
Definition: json_binary.cc:1334
 
EXPORT_JSON_FUNCTION Value(enum_type t, int64_t val)
Constructor for values that represent ints or uints.
Definition: json_binary.h:383
 
uint32_t m_element_count
Element count for arrays and objects.
Definition: json_binary.h:510
 
EXPORT_JSON_FUNCTION double get_double() const
Get the value of a DOUBLE.
Definition: json_binary.h:317
 
This file contains the field type.
 
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
 
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
 
#define EXPORT_JSON_FUNCTION
Definition: json_binary.h:170
 
std::function< void()> JsonErrorHandler
Definition: json_error_handler.h:36
 
uint32 element_count
Definition: my_tree.h:52
 
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1078
 
Definition: buf0block_hint.cc:30
 
Definition: json_binary.cc:89
 
void write_offset_or_size(char *dest, size_t offset_or_size, bool large)
Write an offset or a size to a char array.
Definition: json_binary.cc:220
 
constexpr char JSONB_TYPE_SMALL_OBJECT
Definition: json_binary.h:175
 
constexpr char JSONB_TYPE_DOUBLE
Definition: json_binary.h:186
 
uint8_t offset_size(bool large)
Get the size of an offset value.
Definition: json_binary.cc:413
 
constexpr char JSONB_TYPE_LITERAL
Definition: json_binary.h:179
 
bool space_needed(const Json_wrapper *value, bool large, size_t *needed)
How much space is needed for a JSON value when it is stored in the binary format.
Definition: json_binary.cc:1551
 
constexpr char JSONB_TYPE_LARGE_ARRAY
Definition: json_binary.h:178
 
bool serialize(const Json_dom *dom, const JsonSerializationErrorHandler &error_handler, String *dest)
Serialize the JSON document represented by dom to binary format in the destination string,...
Definition: json_binary.cc:121
 
bool append_offset_or_size(String *dest, size_t offset_or_size, bool large)
Append an offset or a size to a String.
Definition: json_binary.cc:190
 
constexpr char JSONB_TYPE_INT32
Definition: json_binary.h:182
 
bool append_int16(String *dest, int16_t value)
Encode a 16-bit int at the end of the destination string.
Definition: json_binary.cc:158
 
constexpr char JSONB_TRUE_LITERAL
Definition: json_binary.h:191
 
constexpr char JSONB_TYPE_UINT64
Definition: json_binary.h:185
 
constexpr char JSONB_NULL_LITERAL
Definition: json_binary.h:190
 
constexpr char JSONB_TYPE_UINT16
Definition: json_binary.h:181
 
constexpr char JSONB_TYPE_OPAQUE
Definition: json_binary.h:188
 
constexpr char JSONB_TYPE_INT16
Definition: json_binary.h:180
 
constexpr char JSONB_TYPE_SMALL_ARRAY
Definition: json_binary.h:177
 
bool attempt_inline_value(const Json_dom *value, String *dest, size_t pos, bool large)
Attempt to inline a value in its value entry at the beginning of an object or an array.
Definition: json_binary.cc:446
 
uint32_t read_offset_or_size(const char *data, bool large)
Read an offset or size field from a buffer.
Definition: json_binary.cc:1011
 
constexpr char JSONB_TYPE_UINT32
Definition: json_binary.h:183
 
constexpr char JSONB_FALSE_LITERAL
Definition: json_binary.h:192
 
constexpr char JSONB_TYPE_STRING
Definition: json_binary.h:187
 
bool for_each_node(const Value &value, const Func &func)
Apply a function to every value in a JSON document.
Definition: json_binary.h:579
 
bool inlined_type(uint8_t type, bool large)
Will a value of the specified type be inlined?
Definition: json_binary.cc:394
 
Value parse_binary(const char *data, size_t len)
Parse a JSON binary document.
Definition: json_binary.cc:1082
 
uint8_t value_entry_size(bool large)
Get the size of a value entry.
Definition: json_binary.cc:431
 
uint8_t key_entry_size(bool large)
Get the size of a key entry.
Definition: json_binary.cc:422
 
constexpr char JSONB_TYPE_LARGE_OBJECT
Definition: json_binary.h:176
 
constexpr char JSONB_TYPE_INT64
Definition: json_binary.h:184
 
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
 
size_t size(const char *const c)
Definition: base64.h:46
 
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
 
required string type
Definition: replication_group_member_actions.proto:34