1#ifndef JSON_DOM_INCLUDED
2#define JSON_DOM_INCLUDED
36#include <unordered_set>
141template <
typename T,
typename... Args>
143 return std::unique_ptr<T>(
new (std::nothrow)
T(std::forward<Args>(args)...));
201 void *
operator new(
size_t size,
const std::nothrow_t &)
noexcept;
206 void operator delete(
void *ptr)
noexcept;
211 void operator delete(
void *ptr,
const std::nothrow_t &)
noexcept;
321 bool auto_wrap,
bool only_need_one);
358 bool operator()(std::string_view
key1, std::string_view key2)
const;
522 std::vector<Json_dom_ptr, Malloc_allocator<Json_dom_ptr>>
m_v;
663 std::sort(
m_v.begin(),
m_v.end(), comparator);
707 template <
typename... Args>
714 return create_dom_ptr<Json_string>(
m_str);
779 return create_dom_ptr<Json_decimal>(
m_dec);
841 return create_dom_ptr<Json_double>(
m_f);
1087 template <
typename... Args>
1129 return create_dom_ptr<Json_boolean>(
m_v);
1361 return m_dom.m_value;
1673 bool *unsigned_flag)
const;
1677 return coerce_int(error_handler,
nullptr,
nullptr);
1797 size_t *space)
const;
1830 bool *replaced_path);
1922 return !(*
this == other);
2005 scalar->~Json_scalar();
2025 template <
typename T,
typename... Args>
2028 static_assert(
sizeof(
T) <=
sizeof(
m_buffer),
"Buffer is too small");
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
Definition: my_temporal.h:395
Definition: my_temporal.h:339
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
Represents a JSON array container, i.e.
Definition: json_dom.h:519
void sort(const CHARSET_INFO *cs=nullptr)
Sort the array.
Definition: json_dom.cc:1100
Json_dom * operator[](size_t index) const
Get the value at position index.
Definition: json_dom.h:636
Json_array()
Definition: json_dom.cc:1001
bool binary_search(Json_dom *val)
Check if the given value appears in the array.
Definition: json_dom.cc:1109
bool remove(size_t index)
Remove the value at this index.
Definition: json_dom.cc:1025
const_iterator end() const
Returns a const_iterator that refers past the last element.
Definition: json_dom.h:653
decltype(m_v)::const_iterator const_iterator
Constant iterator over the elements in the JSON array.
Definition: json_dom.h:647
bool append_alias(Json_dom_ptr value)
Append the value to the end of the array and take over the ownership of the value.
Definition: json_dom.h:565
void replace_dom_in_container(const Json_dom *oldv, Json_dom_ptr newv) override
Replace oldv contained inside this container array or object) with newv.
Definition: json_dom.cc:819
bool consume(Json_array_ptr other)
Moves all of the elements in the other array to the end of this array.
Definition: json_dom.cc:1003
bool insert_alias(size_t index, Json_dom_ptr value)
Insert the value at position index of the array.
Definition: json_dom.cc:1013
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.cc:1043
void clear()
Remove the values in the array.
Definition: json_dom.h:644
void sort(const T &comparator)
Sort the array using a user-defined comparator.
Definition: json_dom.h:662
size_t size() const
The cardinality of the array (number of values).
Definition: json_dom.h:619
std::vector< Json_dom_ptr, Malloc_allocator< Json_dom_ptr > > m_v
Holds the array values.
Definition: json_dom.h:522
void remove_duplicates(const CHARSET_INFO *cs)
Sort array and remove duplicate elements.
Definition: json_dom.cc:1104
bool append_alias(Json_dom *value)
Append the value to the end of the array.
Definition: json_dom.h:554
friend Json_dom
Definition: json_dom.h:683
bool insert_clone(size_t index, const Json_dom *value)
Insert a clone of the value at position index of the array.
Definition: json_dom.h:588
uint32 depth() const override
Compute the depth of a document.
Definition: json_dom.cc:1034
const_iterator begin() const
Returns a const_iterator that refers to the first element.
Definition: json_dom.h:650
bool append_clone(const Json_dom *value)
Append a clone of the value to the end of the array.
Definition: json_dom.h:535
enum_json_type json_type() const override
Definition: json_dom.h:527
Represents a JSON true or false value, type J_BOOLEAN here.
Definition: json_dom.h:1113
bool value() const
Definition: json_dom.h:1126
enum_json_type json_type() const override
Definition: json_dom.h:1119
Json_boolean(bool value)
Definition: json_dom.h:1117
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:1128
bool m_v
false or true: represents the eponymous JSON literal
Definition: json_dom.h:1115
Abstract base class of all JSON container types (Json_object and Json_array).
Definition: json_dom.h:331
virtual void replace_dom_in_container(const Json_dom *oldv, Json_dom_ptr newv)=0
Replace oldv contained inside this container array or object) with newv.
MySQL temporal value that is represented by a MYSQL_TIME struct, ie.
Definition: json_dom.h:1003
enum_field_types m_field_type
identifies which type of date/time
Definition: json_dom.h:1059
enum_json_type json_type() const override
Definition: json_dom.cc:1254
void to_packed(char *dest) const
Convert the datetime to the packed format used for storage.
Definition: json_dom.cc:1274
enum_field_types field_type() const override
Definition: json_dom.h:1027
Datetime_val m_t
holds the date/time value
Definition: json_dom.h:1058
const Datetime_val * value() const
Definition: json_dom.h:1025
static void from_packed(const char *from, enum_field_types ft, MYSQL_TIME *to)
Convert a packed datetime back to a MYSQL_TIME.
Definition: json_dom.cc:1279
Json_datetime(const Datetime_val &t, enum_field_types ft)
Constructs a object to hold a MySQL date/time value.
Definition: json_dom.h:1012
static void from_packed_to_key(const char *from, enum_field_types ft, uchar *to, uint8 dec)
Convert a packed datetime to key string for indexing by SE.
Definition: json_dom.cc:1285
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.cc:1270
Represents a MySQL decimal number, type J_DECIMAL.
Definition: json_dom.h:742
Json_decimal(const my_decimal &value)
Definition: json_dom.cc:1195
my_decimal m_dec
holds the decimal number
Definition: json_dom.h:744
bool get_binary(char *dest) const
Get the binary representation of the wrapped my_decimal, so that this value can be stored inside of a...
Definition: json_dom.cc:1206
enum_json_type json_type() const override
Definition: json_dom.h:767
const my_decimal * value() const
Get a pointer to the MySQL decimal held by this object.
Definition: json_dom.h:776
static const int MAX_BINARY_SIZE
Definition: json_dom.h:747
static const char * get_encoded_binary(const char *bin)
Returns stored DECIMAL binary.
Definition: json_dom.h:808
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:778
static bool convert_from_binary(const char *bin, size_t len, my_decimal *dec)
Convert a binary value produced by get_binary() back to a my_decimal.
Definition: json_dom.cc:1219
int binary_size() const
Get the number of bytes needed to store this decimal in a Json_opaque.
Definition: json_dom.cc:1198
static size_t get_encoded_binary_len(size_t length)
Returns length of stored DECIMAL binary.
Definition: json_dom.h:822
JSON DOM abstract base class.
Definition: json_dom.h:178
virtual bool is_scalar() const
Definition: json_dom.h:228
Json_container * parent() const
Get the parent dom to which this dom is attached.
Definition: json_dom.h:218
bool seek(const Json_seekable_path &path, size_t legs, Json_dom_vector *hits, bool auto_wrap, bool only_need_one)
Finds all of the json sub-documents which match the path expression.
Definition: json_dom.cc:1976
virtual ~Json_dom()=default
virtual uint32 depth() const =0
Compute the depth of a document.
Json_path get_location() const
Get the path location of this dom, measured from the outermost document it nests inside.
Definition: json_dom.cc:1949
static Json_dom_ptr parse(const char *text, size_t length, const JsonParseErrorHandler &error_handler, const JsonErrorHandler &depth_handler)
Parse Json text to DOM (using rapidjson).
Definition: json_dom.cc:616
void set_parent(Json_container *parent)
Set the parent dom to which this dom is attached.
Definition: json_dom.h:189
virtual bool is_number() const
Definition: json_dom.h:233
Json_container * m_parent
Parent pointer.
Definition: json_dom.h:325
virtual enum_json_type json_type() const =0
virtual Json_dom_ptr clone() const =0
Make a deep clone.
Represents a MySQL double JSON scalar (an extension of the ECMA number value), type J_DOUBLE.
Definition: json_dom.h:832
double m_f
holds the double value
Definition: json_dom.h:834
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:840
enum_json_type json_type() const override
Definition: json_dom.h:838
double value() const
Return the double value held by this object.
Definition: json_dom.h:848
Json_double(double value)
Definition: json_dom.h:836
Represents a MySQL integer (64 bits signed) JSON scalar (an extension of the ECMA number value),...
Definition: json_dom.h:855
enum_json_type json_type() const override
Definition: json_dom.h:861
bool is_16bit() const
Definition: json_dom.h:872
Json_int(longlong value)
Definition: json_dom.h:859
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:879
longlong m_i
holds the value
Definition: json_dom.h:857
bool is_32bit() const
Definition: json_dom.h:877
longlong value() const
Return the signed int held by this object.
Definition: json_dom.h:867
Represents a JSON null type (ECMA), type J_NULL here.
Definition: json_dom.h:919
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:922
enum_json_type json_type() const override
Definition: json_dom.h:921
Abstract base class of all JSON number (ECMA) types (subclasses represent MySQL extensions).
Definition: json_dom.h:734
bool is_number() const final
Definition: json_dom.h:736
A wrapper over a JSON object which provides an interface that can be iterated over with a for-each lo...
Definition: json_dom.h:1953
Json_wrapper_object_iterator const_iterator
Definition: json_dom.h:1955
const_iterator end() const
Definition: json_dom.h:1961
Json_object_wrapper(const Json_wrapper &wrapper)
Definition: json_dom.h:1956
const_iterator begin() const
Definition: json_dom.h:1960
const_iterator cbegin() const
Definition: json_dom.h:1958
const_iterator cend() const
Definition: json_dom.h:1959
const Json_wrapper & m_wrapper
Definition: json_dom.h:1964
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:373
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.cc:924
Json_object_map m_map
Map to hold the object elements.
Definition: json_dom.h:378
bool add_alias(std::string_view key, Json_dom *value)
Insert the value into the object.
Definition: json_dom.h:415
Json_object_map::const_iterator const_iterator
Constant iterator over the elements in the JSON object.
Definition: json_dom.h:484
enum_json_type json_type() const override
Definition: json_dom.h:382
bool consume(Json_object_ptr other)
Transfer all of the key/value pairs in the other object into this object.
Definition: json_dom.cc:869
Json_object()
Definition: json_dom.cc:403
const_iterator end() const
Returns a const_iterator that refers past the last element.
Definition: json_dom.h:490
size_t cardinality() const
Definition: json_dom.cc:912
uint32 depth() const override
Compute the depth of a document.
Definition: json_dom.cc:914
bool remove(std::string_view key)
Remove the child element addressed by key.
Definition: json_dom.cc:904
Json_dom * get(std::string_view key) const
Return the value at key.
Definition: json_dom.cc:893
bool add_clone(std::string_view key, const Json_dom *value)
Insert a clone of the value into the object.
Definition: json_dom.h:394
bool merge_patch(Json_object_ptr patch)
Implementation of the MergePatch function specified in RFC 7396:
Definition: json_dom.cc:936
void clear()
Remove all elements in the object.
Definition: json_dom.h:476
const_iterator begin() const
Returns a const_iterator that refers to the first element.
Definition: json_dom.h:487
void replace_dom_in_container(const Json_dom *oldv, Json_dom_ptr newv) override
Replace oldv contained inside this container array or object) with newv.
Definition: json_dom.cc:828
Represents a MySQL value opaquely, i.e.
Definition: json_dom.h:1071
enum_field_types type() const
Definition: json_dom.h:1101
Json_opaque(enum_field_types mytype, Args &&...args)
An opaque MySQL value.
Definition: json_dom.h:1088
size_t size() const
Definition: json_dom.h:1105
enum_json_type json_type() const override
Definition: json_dom.h:1091
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.cc:1323
std::string m_val
Definition: json_dom.h:1074
const char * value() const
Definition: json_dom.h:1096
enum_field_types m_mytype
Definition: json_dom.h:1073
A JSON path expression.
Definition: json_path.h:350
A class that is capable of holding objects of any sub-type of Json_scalar.
Definition: json_dom.h:1984
Json_scalar * m_scalar_ptr
Pointer to the held scalar, or nullptr if no value is held.
Definition: json_dom.h:2013
void emplace(Args &&...args)
Construct a new Json_scalar value in this Json_scalar_holder.
Definition: json_dom.h:2026
Json_scalar * get()
Get a pointer to the held object, or nullptr if there is none.
Definition: json_dom.h:2017
Any_json_scalar m_buffer
The buffer in which the Json_scalar value is stored.
Definition: json_dom.h:2010
Abstract base class for all Json scalars.
Definition: json_dom.h:689
uint32 depth() const final
Compute the depth of a document.
Definition: json_dom.h:691
bool is_scalar() const final
Definition: json_dom.h:693
A path expression which can be used to seek to a position inside a JSON value.
Definition: json_path.h:295
Represents a JSON string value (ECMA), of type J_STRING here.
Definition: json_dom.h:699
std::string m_str
holds the string
Definition: json_dom.h:701
Json_string(Args &&...args)
Definition: json_dom.h:708
enum_json_type json_type() const override
Definition: json_dom.h:711
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:713
size_t size() const
Get the number of characters in the string.
Definition: json_dom.h:727
const std::string & value() const
Get the reference to the value of the JSON string.
Definition: json_dom.h:721
Represents a MySQL temporal value (DATE, TIME, DATETIME or TIMESTAMP) - an extension to the ECMA set ...
Definition: json_dom.h:932
virtual enum_field_types field_type() const =0
Json_temporal()
Definition: json_dom.h:934
static const size_t PACKED_SIZE
Datetimes are packed in eight bytes.
Definition: json_dom.h:943
MySQL TIME value.
Definition: json_dom.h:947
void to_packed(char *dest) const
Convert the TIME value to the packed format used for storage.
Definition: json_dom.cc:1246
static void from_packed_to_key(const char *from, uchar *to, uint8 dec)
Convert a packed time value to key string for indexing by SE.
Definition: json_dom.cc:1315
Time_val m_time
Holds the time value.
Definition: json_dom.h:996
enum_json_type json_type() const override
Definition: json_dom.h:956
Json_time(const Time_val time)
Constructs a object to hold a MySQL time value.
Definition: json_dom.h:954
Time_val value() const
Definition: json_dom.h:961
static void from_packed(const char *from, Time_val *to)
Convert a packed time back to a time value.
Definition: json_dom.cc:1250
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.cc:1242
enum_field_types field_type() const override
Return what kind of temporal value this object holds.
Definition: json_dom.h:968
Represents a MySQL integer (64 bits unsigned) JSON scalar (an extension of the ECMA number value),...
Definition: json_dom.h:887
enum_json_type json_type() const override
Definition: json_dom.h:893
Json_uint(ulonglong value)
Definition: json_dom.h:891
Json_dom_ptr clone() const override
Make a deep clone.
Definition: json_dom.h:913
ulonglong value() const
Return the unsigned int held by this object.
Definition: json_dom.h:899
ulonglong m_i
holds the value
Definition: json_dom.h:889
bool is_16bit() const
Definition: json_dom.h:905
bool is_32bit() const
Definition: json_dom.h:911
Helper class for building a hash key.
Definition: json_hash.h:45
Class that iterates over all members of a JSON object that is wrapped in a Json_wrapper instance.
Definition: json_dom.h:1871
bool operator==(const Json_wrapper_object_iterator &other) const
Checks two iterators for equality.
Definition: json_dom.h:1915
const json_binary::Value * m_binary_value
The binary JSON object being iterated over, or nullptr for DOMs.
Definition: json_dom.h:1938
const value_type * pointer
Definition: json_dom.h:1876
size_t m_current_element_index
The index of the current member in the binary JSON object.
Definition: json_dom.h:1940
std::forward_iterator_tag iterator_category
Definition: json_dom.h:1878
const Json_wrapper_object_iterator operator++(int)
Advances the iterator to the next element and returns an iterator that points to the current element ...
Definition: json_dom.h:1908
bool is_dom() const
Returns true if iterating over a DOM.
Definition: json_dom.h:1944
void initialize_current_member()
Fill m_current_member with the key and value of the current member.
Definition: json_dom.cc:1340
const value_type & reference
Definition: json_dom.h:1875
bool m_current_member_initialized
True if m_current_member is initialized.
Definition: json_dom.h:1936
bool operator!=(const Json_wrapper_object_iterator &other) const
Checks two iterators for inequality.
Definition: json_dom.h:1921
std::pair< std::string_view, Json_wrapper > value_type
Definition: json_dom.h:1874
Json_object::const_iterator m_iter
Iterator pointing to the current member in the JSON DOM object.
Definition: json_dom.h:1942
pointer operator->()
Definition: json_dom.h:1925
Json_wrapper_object_iterator & operator++()
Advances the iterator to the next element.
Definition: json_dom.h:1895
ptrdiff_t difference_type
Definition: json_dom.h:1877
value_type m_current_member
Pair holding the key and value of the member pointed to by the iterator.
Definition: json_dom.h:1934
Json_wrapper_object_iterator()=default
Forward iterators must be default constructible.
reference operator*()
Definition: json_dom.h:1930
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1225
const char * get_data() const
Get a pointer to the data of a JSON string or JSON opaque value.
Definition: json_dom.cc:1847
const Json_dom * get_dom() const
Gets a pointer to the wrapped Json_dom object, if this wrapper holds a DOM.
Definition: json_dom.h:1359
void make_hash_key_common(Json_wrapper_hasher &hash_key) const
Definition: json_dom.cc:3384
void get_time(Time_val *t) const
Get the value of a JSON time value.
Definition: json_dom.cc:1910
bool to_pretty_string(String *buffer, const char *func_name, 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_dom.cc:1759
void set_alias()
Only meaningful iff the wrapper encapsulates a DOM.
Definition: json_dom.h:1285
size_t get_data_length() const
Get the length to the data of a JSON string or JSON opaque value.
Definition: json_dom.cc:1857
bool get_decimal_data(my_decimal *d) const
Get the MySQL representation of a JSON decimal value.
Definition: json_dom.cc:1867
ulonglong get_uint() const
Get the value of a JSON unsigned integer number.
Definition: json_dom.cc:1893
longlong coerce_int(const JsonCoercionHandler &error_handler, bool *err, bool *unsigned_flag) const
Extract an int (signed or unsigned) from the JSON if possible coercing if need be.
Definition: json_dom.cc:2742
bool get_boolean() const
Get a boolean value (a JSON true or false literal).
Definition: json_dom.cc:1941
enum_field_types field_type() const
Return the MYSQL type of the opaque value, see type().
Definition: json_dom.cc:1813
bool to_string(String *buffer, bool json_quoted, const char *func_name, 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_dom.cc:1751
void remove_duplicates(const CHARSET_INFO *cs=nullptr)
Remove duplicate values.
Definition: json_dom.cc:3691
bool m_alias
If true, don't deallocate m_dom_value in destructor.
Definition: json_dom.h:1236
bool coerce_time(const JsonCoercionHandler &error_handler, const JsonCoercionDeprecatedHandler &deprecation_checker, Time_val *time) const
Extract a time value from the JSON if possible, coercing if need be.
Definition: json_dom.cc:2979
Json_dom * to_dom()
Get the wrapped contents in DOM form.
Definition: json_dom.cc:1427
bool coerce_datetime(const JsonCoercionHandler &error_handler, const JsonCoercionDeprecatedHandler &deprecation_checker, Datetime_val *dt, my_time_flags_t flags=0) const
Extract a datetime from the JSON if possible, coercing if need be.
Definition: json_dom.cc:2951
longlong get_int() const
Get the value of a JSON signed integer number.
Definition: json_dom.cc:1885
const char * get_datetime_packed(char *buffer) const
Get the wrapped datetime value in the packed format.
Definition: json_dom.cc:1919
Json_wrapper operator[](size_t index) const
If this wrapper holds a JSON array, get an array value by indexing into the array.
Definition: json_dom.cc:1833
bool m_is_dom
Wraps a DOM iff true.
Definition: json_dom.h:1241
const json_binary::Value & get_binary_value() const
Gets the wrapped json_binary::Value object, if this wrapper holds a binary JSON value.
Definition: json_dom.h:1369
void get_datetime(MYSQL_TIME *t) const
Get the value of a JSON date/time value.
Definition: json_dom.cc:1901
bool attempt_binary_update(const Field_json *field, const Json_seekable_path &path, Json_wrapper *new_value, bool replace, String *result, bool *partially_updated, bool *replaced_path)
Attempt a binary partial update by replacing the value at path with new_value.
Definition: json_dom.cc:3464
longlong coerce_int(const JsonCoercionHandler &error_handler) const
Shorthand for coerce_int(error_handler, nullptr, nullptr).
Definition: json_dom.h:1676
enum_json_type type() const
Return the type of the wrapped JSON value.
Definition: json_dom.cc:1780
void dbug_print(const char *message, const JsonErrorHandler &depth_handler) const
Print this JSON document to the debug trace.
Definition: json_dom.cc:1767
Json_wrapper()
Create an empty wrapper.
Definition: json_dom.h:1258
bool to_binary(const JsonSerializationErrorHandler &error_handler, String *str) const
Get the wrapped contents in binary value form.
Definition: json_dom.cc:1447
int compare(const Json_wrapper &other, const CHARSET_INFO *cs=nullptr) const
Compare this JSON value to another JSON value.
Definition: json_dom.cc:2503
void sort(const CHARSET_INFO *cs=nullptr)
Sort contents.
Definition: json_dom.cc:3686
bool get_free_space(const JsonSerializationErrorHandler &error_handler, size_t *space) const
Calculate the amount of unused space inside a JSON binary value.
Definition: json_dom.cc:3453
ulonglong make_hash_key(ulonglong hash_val) const
Make a hash key that can be used by sql_executor.cc/unique_hash in order to support SELECT DISTINCT.
Definition: json_dom.cc:3378
my_decimal * coerce_decimal(const JsonCoercionHandler &error_handler, my_decimal *decimal_value, bool *err) const
Extract a decimal from the JSON if possible, coercing if need be.
Definition: json_dom.cc:2864
bool seek(const Json_seekable_path &path, size_t legs, Json_wrapper_vector *hits, bool auto_wrap, bool only_need_one)
Finds all of the json sub-documents which match the path expression.
Definition: json_dom.cc:2205
Json_wrapper & operator=(const Json_wrapper &old)
Assignment operator.
Definition: json_dom.cc:1419
bool is_binary_backed_by(const String *str) const
Check if the wrapped JSON document is a binary value (a json_binary::Value), and if that binary is po...
Definition: json_dom.h:1407
double get_double() const
Get the value of a JSON double number.
Definition: json_dom.cc:1877
size_t make_sort_key(uchar *to, size_t length) const
Make a sort key that can be used by filesort to order JSON values.
Definition: json_dom.cc:3258
bool binary_remove(const Field_json *field, const Json_seekable_path &path, String *result, bool *found_path)
Remove a path from a binary JSON document.
Definition: json_dom.cc:3609
double coerce_real(const JsonCoercionHandler &error_handler) const
Shorthand for coerce_real(error_handler, nullptr).
Definition: json_dom.h:1690
size_t length() const
Compute the length of a document.
Definition: json_dom.cc:2241
Json_wrapper lookup(std::string_view key) const
If this wrapper holds a JSON object, get the value corresponding to the member key.
Definition: json_dom.cc:1821
struct Json_wrapper::@42::@44 m_dom
The DOM representation, only used if m_is_dom is true.
bool empty() const
A Wrapper is defined to be empty if it is passed a NULL value with the constructor for JSON dom,...
Definition: json_dom.h:1336
Json_wrapper(Json_dom_ptr dom_value)
Wrap the supplied DOM value.
Definition: json_dom.h:1276
my_decimal * coerce_decimal(const JsonCoercionHandler &error_handler, my_decimal *decimal_value) const
Shorthand for coerce_decimal(error_handler, decimal_value, nullptr).
Definition: json_dom.h:1706
~Json_wrapper()
Definition: json_dom.cc:1392
Json_dom * m_value
Definition: json_dom.h:1234
bool is_dom() const
Does this wrapper contain a DOM?
Definition: json_dom.h:1344
double coerce_real(const JsonCoercionHandler &error_handler, bool *err) const
Extract a real from the JSON if possible, coercing if need be.
Definition: json_dom.cc:2816
const char * get_time_packed(char *buffer) const
Definition: json_dom.cc:1930
bool coerce_date(const JsonCoercionHandler &error_handler, const JsonCoercionDeprecatedHandler &deprecation_checker, Date_val *date, my_time_flags_t flags=0) const
Extract a date from the JSON if possible, coercing if need be.
Definition: json_dom.cc:2922
Json_dom_ptr clone_dom() const
Get the wrapped contents in DOM form.
Definition: json_dom.cc:1439
json_binary::Value m_value
The binary representation, only used if m_is_dom is false.
Definition: json_dom.h:1239
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
Time_val is a temporal type that represents only time.
Definition: my_temporal.h:55
Class used for reading JSON values that are stored in the binary format.
Definition: json_binary.h:234
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:97
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
@ MYSQL_TYPE_TIME
Definition: field_types.h:67
static const std::string dec("DECRYPTION")
static int flags[50]
Definition: hp_test1.cc:40
static uint16 key1[1001]
Definition: hp_test2.cc:50
#define T
Definition: jit_executor_value.cc:373
This file specifies the interface for serializing JSON values into binary representation,...
constexpr uchar JSON_KEY_OBJECT
Definition: json_dom.h:1207
bool json_wrapper_contains(const Json_wrapper &doc_wrapper, const Json_wrapper &containee_wr, bool *result)
Check if one Json_wrapper contains all the elements of another Json_wrapper.
Definition: json_dom.cc:3725
std::unique_ptr< Json_dom > Json_dom_ptr
Definition: json_dom.h:67
Prealloced_array< Json_dom *, 16 > Json_dom_vector
Definition: json_dom.h:65
constexpr uchar JSON_KEY_TRUE
Definition: json_dom.h:1210
constexpr uchar JSON_KEY_FALSE
Definition: json_dom.h:1209
std::unique_ptr< T > create_dom_ptr(Args &&...args)
Allocate a new Json_dom object and return a std::unique_ptr which points to it.
Definition: json_dom.h:142
std::map< std::string, Json_dom_ptr, Json_key_comparator, Malloc_allocator< std::pair< const std::string, Json_dom_ptr > > > Json_object_map
A type used to hold JSON object elements in a map, see the Json_object class.
Definition: json_dom.h:367
constexpr uchar JSON_KEY_ARRAY
Definition: json_dom.h:1208
bool is_valid_json_syntax(const char *text, size_t length)
Check if a string contains valid JSON text, without generating a Json_dom representation of the docum...
std::unique_ptr< Json_object > Json_object_ptr
Definition: json_dom.h:69
enum_json_type
Json values in MySQL comprises the stand set of JSON values plus a MySQL specific set.
Definition: json_dom.h:112
std::string_view json_type_name(const Json_wrapper &doc)
Returns the name of the type of the JSON document contained in "doc".
Definition: json_dom.cc:3930
constexpr uchar JSON_KEY_NULL
Definition: json_dom.h:1206
std::unique_ptr< Json_array > Json_array_ptr
Definition: json_dom.h:68
bool double_quote(const char *cptr, size_t length, String *buf)
Perform quoting on a JSON string to make an external representation of it.
Definition: json_dom.cc:1163
const size_t kMaxJsonTypeNameLength
The maximum length of the type name returned from JSON_TYPE.
Definition: json_dom.cc:3925
Prealloced_array< Json_wrapper, 16 > Json_wrapper_vector
Definition: json_dom.h:62
Json_dom_ptr merge_doms(Json_dom_ptr left, Json_dom_ptr right)
Merge two doms.
Definition: json_dom.cc:157
std::function< void(MYSQL_TIME_STATUS &status)> JsonCoercionDeprecatedHandler
Definition: json_error_handler.h:40
std::function< void(const char *target_type, int error_code)> JsonCoercionHandler
Definition: json_error_handler.h:38
std::function< void()> JsonErrorHandler
Definition: json_error_handler.h:36
std::function< void(const char *parse_err, size_t err_offset)> JsonParseErrorHandler
Definition: json_error_handler.h:35
Functions for reading and storing in machine-independent format.
std::uint32_t ha_checksum
Definition: my_checksum.h:106
It is interface module to fixed precision decimals library.
static constexpr int DECIMAL_MAX_FIELD_SIZE
maximum size of packet length.
Definition: my_decimal.h:83
Some integer typedefs for easier portability.
#define UINT_MAX16
Definition: my_inttypes.h:85
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint8_t uint8
Definition: my_inttypes.h:63
unsigned char uchar
Definition: my_inttypes.h:52
#define INT_MAX16
Definition: my_inttypes.h:84
#define INT_MIN32
Definition: my_inttypes.h:77
long long int longlong
Definition: my_inttypes.h:55
#define INT_MAX32
Definition: my_inttypes.h:78
#define INT_MIN16
Definition: my_inttypes.h:83
uint32_t uint32
Definition: my_inttypes.h:67
#define UINT_MAX32
Definition: my_inttypes.h:79
Interface for low level time utilities.
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:85
static char * path
Definition: mysqldump.cc:150
static bool replace
Definition: mysqlimport.cc:70
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:354
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1078
Definition: buf0block_hint.cc:30
Definition: commit_order_queue.h:34
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
void right(std::string *to_trim)
Definition: trim.h:41
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
void left(std::string *to_trim)
Definition: trim.h:35
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:924
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
const char * begin(const char *const c)
Definition: base64.h:44
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Definition: gcs_xcom_synode.h:64
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2898
required string key
Definition: replication_asynchronous_connection_failover.proto:60
const uchar * hash_key(const uchar *el, size_t *length)
Definition: sql_auth_cache.cc:3316
Definition: m_ctype.h:421
A comparator that is used for ordering keys in a Json_object.
Definition: json_dom.h:350
bool operator()(std::string_view key1, std::string_view key2) const
Compare two keys from a JSON object and determine whether or not the first key is less than the secon...
Definition: json_dom.cc:993
void is_transparent
Definition: json_dom.h:356
Definition: mysql_time.h:82
Union of all concrete subclasses of Json_scalar.
Definition: json_dom.h:1986
Json_null m_null
Definition: json_dom.h:1993
Json_time m_time
Definition: json_dom.h:1994
Json_boolean m_boolean
Definition: json_dom.h:1992
Json_decimal m_decimal
Definition: json_dom.h:1988
Json_datetime m_datetime
Definition: json_dom.h:1995
Json_double m_double
Definition: json_dom.h:1991
Json_opaque m_opaque
Definition: json_dom.h:1996
~Any_json_scalar()
Destructor which delegates to Json_scalar's virtual destructor.
Definition: json_dom.h:2000
Json_int m_int
Definition: json_dom.h:1989
Any_json_scalar()
Constructor which initializes the union to hold a Json_null value.
Definition: json_dom.h:1998
Json_uint m_uint
Definition: json_dom.h:1990
Json_string m_string
Definition: json_dom.h:1987