MySQL 9.4.0
Source Code Documentation
item_json_func.h
Go to the documentation of this file.
1#ifndef ITEM_JSON_FUNC_INCLUDED
2#define ITEM_JSON_FUNC_INCLUDED
3
4/* Copyright (c) 2015, 2025, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27#include <assert.h>
28#include <sys/types.h>
29
30#include <cstdint>
31#include <memory>
32#include <utility> // std::forward
33
34#include "field_types.h"
35#include "my_alloc.h"
36#include "my_inttypes.h"
37#include "my_table_map.h"
38#include "my_time.h"
41#include "mysql_com.h"
42#include "mysql_time.h"
43#include "prealloced_array.h" // Prealloced_array
45#include "sql-common/json_path.h" // Json_path
46#include "sql-common/json_schema.h" //Json_schema_validator_holder
47#include "sql/current_thd.h" // current_thd
48#include "sql/enum_query_type.h"
49#include "sql/field.h"
50#include "sql/item.h"
51#include "sql/item_cmpfunc.h"
52#include "sql/item_func.h"
53#include "sql/item_strfunc.h" // Item_str_func
55#include "sql/mem_root_array.h" // Mem_root_array
56#include "sql/parse_location.h" // POS
57#include "sql/psi_memory_key.h" // key_memory_JSON
58#include "sql_string.h"
59
60class Json_array;
62class Json_dom;
63class Json_object;
66class Json_wrapper;
67class PT_item_list;
69class THD;
70class my_decimal;
71enum Cast_target : unsigned char;
72enum class Json_on_response_type : uint16;
73enum class enum_json_diff_status;
74
75struct Cast_type;
76struct TABLE;
77
78/** For use by JSON_CONTAINS_PATH() and JSON_SEARCH() */
85};
86
87/**
88 Path cache for JSON functions. Caches parsed path
89 objects for arguments which are string literals.
90 Maintains a vector of path objects and an array of
91 ints which map path argument numbers to slots in
92 the array.
93*/
95 private:
96 /// Holder for path strings.
98
99 /// List of paths.
101
102 /// Enum that tells the status of a cell in m_paths.
103 enum class enum_path_status : uint8 {
106 OK_NULL,
107 };
108
109 /// Struct that points to a cell in m_paths and tells its status.
110 struct Path_cell {
112 size_t m_index = 0;
113 };
114
115 /// Map argument indexes to indexes into m_paths.
117
118 public:
119 Json_path_cache(THD *thd, uint size);
121
122 /**
123 Parse a path expression if necessary. Does nothing if the path
124 expression is constant and it has already been parsed. Assumes that
125 we've already verified that the path expression is not null. Raises an
126 error if the path expression is syntactically incorrect. Raises an
127 error if the path expression contains wildcard tokens but is not
128 supposed to. Otherwise puts the parsed path onto the
129 path vector.
130
131 @param[in] thd THD handle
132 @param[in] args Array of args to a JSON function
133 @param[in] arg_idx Index of the path_expression in args
134 @param[in] forbid_wildcards True if the path shouldn't contain * or **
135
136 @returns false on success (valid path or NULL), true on error
137 */
138 bool parse_and_cache_path(const THD *thd, Item **args, uint arg_idx,
139 bool forbid_wildcards);
140
141 /**
142 Return an already parsed path expression.
143
144 @param[in] arg_idx Index of the path_expression in the JSON function args
145
146 @returns the already parsed path, possibly NULL
147 */
148 const Json_path *get_path(uint arg_idx) const;
149
150 /**
151 Reset the cache for re-use when a statement is re-executed.
152 */
153 void reset_cache();
154};
155
156/* JSON function support */
157
158/**
159 Base class for all item functions that a return JSON value
160*/
161class Item_json_func : public Item_func {
162 /// Can this function type be used in partial update?
163 virtual bool can_use_in_partial_update() const { return false; }
164
165 protected:
166 /// String used when reading JSON binary values or JSON text values.
168 /// String used for converting JSON text values to utf8mb4 charset.
170 /// String used for converting a JSON value to text in val_str().
172
173 // Cache for constant path expressions
175
176 /**
177 Target column for partial update, if this function is used in an
178 update statement and partial update can be used.
179 */
181
182 public:
183 /**
184 Construct an Item_json_func instance.
185 @param thd THD handle
186 @param parent_args arguments to forward to Item_func's constructor
187 */
188 template <typename... Args>
189 Item_json_func(THD *thd, Args &&...parent_args)
190 : Item_func(std::forward<Args>(parent_args)...),
191 m_path_cache(thd, arg_count) {
193 }
194
195 bool resolve_type(THD *) override {
196 if (reject_vector_args()) return true;
197 set_nullable(true);
198 return false;
199 }
200 enum Item_result result_type() const override { return STRING_RESULT; }
201 String *val_str(String *arg) override;
202 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
203 bool get_time(MYSQL_TIME *ltime) override;
204 longlong val_int() override;
205 double val_real() override;
206 my_decimal *val_decimal(my_decimal *decimal_value) override;
207
208 void cleanup() override;
209
210 Item_result cast_to_int_type() const override { return INT_RESULT; }
211
212 /**
213 Does this function call support partial update of the given JSON column?
214
215 JSON_SET, JSON_REPLACE and JSON_REMOVE support partial update of a JSON
216 column if the JSON column is the first argument of the function call, or if
217 the first argument is a sequence of nested JSON_SET, JSON_REPLACE and
218 JSON_REMOVE calls in which the JSON column is the first argument of the
219 inner function call.
220
221 For example, this expression can be used to partially update column
222 `json_col`:
223
224 JSON_SET(JSON_REPLACE(json_col, path1, val1), path2, val2)
225 */
226 bool supports_partial_update(const Field_json *field) const override;
227
228 /**
229 Mark this expression as used in partial update. Should only be
230 called if #supports_partial_update returns true.
231 */
232 void mark_for_partial_update(const Field_json *field);
233};
234
235bool sql_scalar_to_json(Item *arg, const char *calling_function, String *value,
236 String *tmp, Json_wrapper *wr,
237 Json_scalar_holder *scalar, bool scalar_string);
238
239/**
240 Return the JSON value of the argument in a wrapper.
241
242 Handles arguments with type JSON, including array objects (which do
243 not report type JSON but rather the type of individual elements).
244
245 Does not handle literals.
246 See also get_json_wrapper.
247
248 @param[in] arg the argument
249 @param[in,out] result the JSON value wrapper
250 @param[out] has_value true if argument was handled, false otherwise
251 undefined when error
252*/
253bool json_value(Item *arg, Json_wrapper *result, bool *has_value);
254
255/**
256 Return the JSON value of the argument in a wrapper. Abstracts whether
257 the value comes from a field or a function or a valid JSON text.
258
259 @param[in] args the arguments
260 @param[in] arg_idx the argument index
261 @param[out] str the string buffer
262 @param[in] func_name the name of the function we are executing
263 @param[out] wrapper the JSON value wrapper
264 @returns false if we found a value or NULL, true if not.
265*/
266bool get_json_wrapper(Item **args, uint arg_idx, String *str,
267 const char *func_name, Json_wrapper *wrapper);
268
269/**
270 Convert Json values or MySQL values to JSON.
271
272 @param[in] args arguments to function
273 @param[in] arg_idx the index of the argument to process
274 @param[in] calling_function name of the calling function
275 @param[in,out] value working area (if the returned Json_wrapper points
276 to a binary value rather than a DOM, this string
277 will end up holding the binary representation, and
278 it must stay alive until the wrapper is destroyed
279 or converted from binary to DOM)
280 @param[in,out] tmp temporary scratch space for converting strings to
281 the correct charset; only used if accept_string is
282 true and conversion is needed
283 @param[in,out] wr the result wrapper
284 @param[in,out] scalar pointer to pre-allocated memory that can be
285 borrowed by the result wrapper if the result is a
286 scalar. If the pointer is NULL, memory for a
287 scalar result will be allocated on the heap.
288 @param[in] accept_string
289 if true, accept MySQL strings as JSON strings
290 by converting them to UTF8, else emit an error
291 @returns false if we found a value or NULL, true otherwise
292*/
293bool get_json_atom_wrapper(Item **args, uint arg_idx,
294 const char *calling_function, String *value,
295 String *tmp, Json_wrapper *wr,
296 Json_scalar_holder *scalar, bool accept_string);
297
298/**
299 Check a non-empty val for character set. If it has character set
300 my_charset_binary, signal error and return false. Else, try to convert to
301 my_charset_utf8mb4_bin. If this fails, signal error and return true, else
302 return false.
303
304 @param[in] val the string to be checked
305 @param[in,out] buf buffer to hold the converted string
306 @param[out] resptr the resulting, possibly converted string,
307 only set if no error
308 @param[out] reslength the length of resptr
309 @param[in] require_string
310 If true, give error messages if binary string. If we
311 see a conversion error (space), we give error
312 notwithstanding this parameter value
313
314 @returns True if the string could not be converted. False on success.
315*/
316bool ensure_utf8mb4(const String &val, String *buf, const char **resptr,
317 size_t *reslength, bool require_string);
318
319/**
320 Represents the JSON function JSON_VALID( <value> )
321*/
324
325 public:
326 Item_func_json_valid(const POS &pos, Item *a) : Item_int_func(pos, a) {}
327
328 const char *func_name() const override { return "json_valid"; }
329 enum Functype functype() const override { return JSON_VALID_FUNC; }
330
331 bool is_bool_func() const override { return true; }
332
333 longlong val_int() override;
334
335 bool resolve_type(THD *thd) override {
336 if (reject_vector_args()) return true;
337 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
338 set_nullable(true);
339 return false;
340 }
341};
342
343/**
344 Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
345*/
347 public:
348 Item_func_json_schema_valid(const POS &pos, Item *a, Item *b);
350
351 const char *func_name() const override { return "json_schema_valid"; }
352 enum Functype functype() const override { return JSON_SCHEMA_VALID_FUNC; }
353
354 bool val_bool() override;
355
356 longlong val_int() override { return val_bool() ? 1 : 0; }
357
358 bool fix_fields(THD *, Item **) override;
359
360 void cleanup() override;
361
362 private:
364};
365
366/**
367 Represents the JSON function
368 JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> )
369*/
371 public:
373 PT_item_list *a);
375
376 const char *func_name() const override {
377 return "json_schema_validation_report";
378 }
379
380 enum Functype functype() const override {
382 }
383
384 bool val_json(Json_wrapper *wr) override;
385
386 bool resolve_type(THD *thd) override {
387 if (reject_vector_args()) return true;
388 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
389 set_nullable(true);
390 return false;
391 }
392
393 bool fix_fields(THD *, Item **) override;
394
395 void cleanup() override;
396
397 private:
399};
400
401/**
402 Represents the JSON function JSON_CONTAINS()
403*/
407
408 public:
410 : Item_int_func(pos, a), m_path_cache(thd, arg_count) {}
411
412 const char *func_name() const override { return "json_contains"; }
413 enum Functype functype() const override { return JSON_CONTAINS; }
414 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
415 bool gc_subst_analyzer(uchar **) override { return true; }
416
417 bool is_bool_func() const override { return true; }
418
419 longlong val_int() override;
420
421 bool resolve_type(THD *thd) override {
422 if (reject_vector_args()) return true;
423 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
424 if (param_type_is_default(thd, 1, 3)) return true;
425 set_nullable(true);
426 return false;
427 }
428
429 /** Cleanup between executions of the statement */
430 void cleanup() override;
431
433 return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
434 }
435};
436
437/**
438 Represents the JSON function JSON_CONTAINS_PATH()
439*/
443
444 // Cache for constant path expressions
446
447 public:
449 : Item_int_func(pos, a),
451 m_path_cache(thd, arg_count) {}
452
453 const char *func_name() const override { return "json_contains_path"; }
454 enum Functype functype() const override { return JSON_CONTAINS_PATH_FUNC; }
455
456 bool is_bool_func() const override { return true; }
457
458 longlong val_int() override;
459
460 bool resolve_type(THD *thd) override {
461 if (reject_vector_args()) return true;
462 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
463 if (param_type_is_default(thd, 1, -1)) return true;
464 set_nullable(true);
465 return false;
466 }
467
468 /** Cleanup between executions of the statement */
469 void cleanup() override;
470
472 return (arg == args[0]) ? CACHE_JSON_VALUE : CACHE_NONE;
473 }
474};
475
476/**
477 Represents the JSON function JSON_TYPE
478*/
481
482 public:
483 Item_func_json_type(const POS &pos, Item *a) : Item_str_func(pos, a) {}
484
485 const char *func_name() const override { return "json_type"; }
486 enum Functype functype() const override { return JSON_TYPE_FUNC; }
487
488 bool resolve_type(THD *) override;
489
490 String *val_str(String *) override;
491};
492
493/**
494 Represents a "CAST( <value> AS JSON )" coercion.
495*/
496class Item_typecast_json final : public Item_json_func {
498
499 public:
500 Item_typecast_json(THD *thd, const POS &pos, Item *a)
501 : Item_json_func(thd, pos, a) {}
502
503 bool resolve_type(THD *thd) override {
504 if (reject_vector_args()) return true;
505 if (Item_json_func::resolve_type(thd)) return true;
506 return args[0]->propagate_type(thd, MYSQL_TYPE_JSON, false, true);
507 }
508
509 void print(const THD *thd, String *str,
510 enum_query_type query_type) const override;
511 const char *func_name() const override { return "cast_as_json"; }
512 const char *cast_type() const { return "json"; }
513 bool val_json(Json_wrapper *wr) override;
514};
515
516/**
517 Represents the JSON function JSON_LENGTH()
518*/
521
522 public:
523 Item_func_json_length(const POS &pos, Item *doc) : Item_int_func(pos, doc) {}
524
525 bool resolve_type(THD *thd) override {
526 if (reject_vector_args()) return true;
527 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
528 if (param_type_is_default(thd, 1, 2)) return true;
529 set_nullable(true);
530 return false;
531 }
532
533 const char *func_name() const override { return "json_length"; }
534 enum Functype functype() const override { return JSON_LENGTH_FUNC; }
535
536 longlong val_int() override;
537};
538
539/**
540 Represents the JSON function JSON_DEPTH()
541*/
544
545 public:
546 Item_func_json_depth(const POS &pos, Item *a) : Item_int_func(pos, a) {}
547
548 const char *func_name() const override { return "json_depth"; }
549 enum Functype functype() const override { return JSON_DEPTH_FUNC; }
550
551 bool resolve_type(THD *thd) override {
552 if (reject_vector_args()) return true;
553 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
554 set_nullable(true);
555 return false;
556 }
557
558 longlong val_int() override;
559};
560
561/**
562 Represents the JSON function JSON_KEYS()
563*/
566
567 public:
568 Item_func_json_keys(THD *thd, const POS &pos, Item *a)
569 : Item_json_func(thd, pos, a) {}
570
571 Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
572 : Item_json_func(thd, pos, a, b) {}
573
574 const char *func_name() const override { return "json_keys"; }
575
576 bool resolve_type(THD *thd) override {
577 if (reject_vector_args()) return true;
578 if (Item_json_func::resolve_type(thd)) return true;
579 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
580 if (param_type_is_default(thd, 1, 2)) return true;
581 return false;
582 }
583
584 bool val_json(Json_wrapper *wr) override;
585};
586
587/**
588 Represents the JSON function JSON_EXTRACT()
589*/
592
593 public:
595 : Item_json_func(thd, pos, a) {}
596
597 Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
598 : Item_json_func(thd, pos, a, b) {}
599
600 const char *func_name() const override { return "json_extract"; }
601 enum Functype functype() const override { return JSON_EXTRACT_FUNC; }
602
603 bool resolve_type(THD *thd) override {
604 if (reject_vector_args()) return true;
605 if (Item_json_func::resolve_type(thd)) return true;
606 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
607 if (param_type_is_default(thd, 1, -1)) return true;
608 return false;
609 }
610
611 bool val_json(Json_wrapper *wr) override;
612
613 bool eq(const Item *item) const override;
614};
615
616/// Base class for all the functions that take a JSON document as the first
617/// argument and one of more pairs of a JSON path and a value to insert into the
618/// JSON document, and returns the modified JSON document.
620 protected:
621 template <typename... Args>
622 explicit Item_func_modify_json_in_path(Args &&...parent_args)
623 : Item_json_func(std::forward<Args>(parent_args)...) {
624 // The function does not necessarily return NULL when an argument is NULL.
625 // It returns NULL only if the first argument is NULL, or if one of the JSON
626 // path arguments is null. The set of tables for which the function is
627 // null-rejecting, is calculated in resolve_type() and possibly updated in
628 // update_used_tables().
629 null_on_null = false;
630 }
632
633 public:
634 bool resolve_type(THD *thd) final;
635 void update_used_tables() final;
636
637 private:
638 /// Calculates the set of tables to return from not_used_tables(). The
639 /// returned value is cached by resolve_type() and update_used_tables().
641};
642
643/**
644 Represents the JSON function JSON_ARRAY_APPEND()
645*/
647 public:
649 : Item_func_modify_json_in_path(thd, pos, a) {}
650
651 const char *func_name() const override { return "json_array_append"; }
652
653 bool val_json(Json_wrapper *wr) override;
654};
655
656/**
657 Represents the JSON function JSON_INSERT()
658*/
660 public:
662 : Item_func_modify_json_in_path(thd, pos, a) {}
663
664 const char *func_name() const override { return "json_insert"; }
665
666 bool val_json(Json_wrapper *wr) override;
667};
668
669/**
670 Represents the JSON function JSON_ARRAY_INSERT()
671*/
673 public:
675 : Item_func_modify_json_in_path(thd, pos, a) {}
676
677 const char *func_name() const override { return "json_array_insert"; }
678
679 bool val_json(Json_wrapper *wr) override;
680};
681
682/**
683 Common base class for JSON_SET() and JSON_REPLACE().
684*/
686 /// True if this is JSON_SET, false if it is JSON_REPLACE.
687 const bool m_json_set;
689 bool can_use_in_partial_update() const override { return true; }
690
691 protected:
692 template <typename... Args>
693 explicit Item_func_json_set_replace(bool json_set, Args &&...parent_args)
694 : Item_func_modify_json_in_path(std::forward<Args>(parent_args)...),
695 m_json_set(json_set),
696 m_path(key_memory_JSON) {}
697
698 public:
699 bool val_json(Json_wrapper *wr) override;
700};
701
702/**
703 Represents the JSON function JSON_SET()
704*/
706 public:
707 template <typename... Args>
708 explicit Item_func_json_set(Args &&...parent_args)
709 : Item_func_json_set_replace(true, std::forward<Args>(parent_args)...) {}
710
711 const char *func_name() const override { return "json_set"; }
712};
713
714/**
715 Represents the JSON function JSON_REPLACE()
716*/
718 public:
719 template <typename... Args>
720 explicit Item_func_json_replace(Args &&...parent_args)
721 : Item_func_json_set_replace(false, std::forward<Args>(parent_args)...) {}
722
723 const char *func_name() const override { return "json_replace"; }
724};
725
726/**
727 Represents the JSON function JSON_ARRAY()
728*/
730 public:
731 template <typename... Args>
732 explicit Item_func_json_array(Args &&...parent_args)
733 : Item_json_func(std::forward<Args>(parent_args)...) {
734 // Does not return NULL on NULL input. A NULL argument is interpreted as the
735 // JSON null literal.
736 null_on_null = false;
737 }
738
739 const char *func_name() const override { return "json_array"; }
740 enum Functype functype() const override { return JSON_ARRAY_FUNC; }
741
742 bool resolve_type(THD *thd) override {
743 if (Item_json_func::resolve_type(thd)) return true;
744 if (param_type_is_default(thd, 0, -1)) return true;
745 return false;
746 }
747
748 bool val_json(Json_wrapper *wr) override;
749};
750
751/**
752 Represents the JSON function JSON_OBJECT()
753*/
756
757 public:
759 : Item_json_func(thd, pos, a) {
760 // Does not return NULL on NULL input. If a key argument is NULL, an error
761 // is raised. If a value argument is NULL, it is interpreted as the JSON
762 // null literal.
763 null_on_null = false;
764 }
765
767 : Item_json_func(thd, list) {
768 // Does not return NULL on NULL input. If a key argument is NULL, an error
769 // is raised. If a value argument is NULL, it is interpreted as the JSON
770 // null literal.
771 null_on_null = false;
772 }
773
774 const char *func_name() const override { return "json_object"; }
775 enum Functype functype() const override { return JSON_OBJECT_FUNC; }
776
777 bool resolve_type(THD *thd) override {
778 if (Item_json_func::resolve_type(thd)) return true;
779 if (param_type_is_default(thd, 0, -1)) return true;
780 return false;
781 }
782
783 bool val_json(Json_wrapper *wr) override;
784};
785
786/**
787 * @brief Represents the JSON function JSON_DUALITY_OBJECT()
788 */
791
792 jdv::Duality_view_tags m_table_tags{0};
793 PT_jdv_name_value_list *m_jdv_name_value_list{nullptr};
794 bool m_inject_object_hash{false};
795 std::unordered_set<std::string> m_json_arrayagg_keys;
796 bool get_inject_object_hash() const { return m_inject_object_hash; }
797
798 public:
799 Item_func_json_duality_object(THD *thd, const POS &pos, int table_tags,
800 PT_jdv_name_value_list *jdv_name_value_list);
801
802 const char *func_name() const override { return "json_duality_object"; }
803 enum Functype functype() const override { return JSON_DUALITY_OBJECT_FUNC; }
804
805 bool resolve_type(THD *thd) override;
806 bool val_json(Json_wrapper *wr) override;
807
808 void print(const THD *thd, String *str,
809 enum_query_type query_type) const override;
810
811 bool set_json_arrayagg_keys(THD *thd);
812
813 jdv::Duality_view_tags table_tags() const { return m_table_tags; }
814 Mem_root_array<LEX_STRING> *name_list();
815 Mem_root_array<uint> *col_tags_list();
816
817 std::unordered_set<std::string> get_json_arrayagg_keys() {
818 return m_json_arrayagg_keys;
819 }
820};
821
822/**
823 Represents the JSON function JSON_SEARCH()
824*/
828
829 // LIKE machinery
832
833 public:
834 /**
835 Construct a JSON_SEARCH() node.
836
837 @param parent_args arguments to pass to Item_json_func's constructor
838 */
839 template <typename... Args>
840 Item_func_json_search(Args &&...parent_args)
841 : Item_json_func(std::forward<Args>(parent_args)...),
842 m_cached_ooa(ooa_uninitialized) {}
843
844 const char *func_name() const override { return "json_search"; }
845
846 enum Functype functype() const override { return JSON_SEARCH_FUNC; }
847
848 bool val_json(Json_wrapper *wr) override;
849
850 /**
851 Bind logic for the JSON_SEARCH() node.
852 */
853 bool fix_fields(THD *, Item **) override;
854
855 bool resolve_type(THD *thd) override {
856 if (Item_json_func::resolve_type(thd)) return true;
857 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
858 if (param_type_is_default(thd, 1, -1)) return true;
859 return false;
860 }
861
862 void cleanup() override;
863};
864
865/**
866 Represents the JSON function JSON_REMOVE()
867*/
870 bool can_use_in_partial_update() const override { return true; }
871
872 public:
873 template <typename... Args>
874 Item_func_json_remove(Args &&...parent_args)
875 : Item_json_func(std::forward<Args>(parent_args)...) {}
876
877 const char *func_name() const override { return "json_remove"; }
878
879 bool resolve_type(THD *thd) override {
880 if (Item_json_func::resolve_type(thd)) return true;
881 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
882 if (param_type_is_default(thd, 1, -1)) return true;
883 return false;
884 }
885
886 bool val_json(Json_wrapper *wr) override;
887};
888
889/**
890 Represents the JSON function JSON_MERGE_PRESERVE.
891*/
893 public:
895 : Item_json_func(thd, pos, a) {}
896
897 const char *func_name() const override { return "json_merge_preserve"; }
898
899 bool resolve_type(THD *thd) override {
900 if (Item_json_func::resolve_type(thd)) return true;
901 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
902 return false;
903 }
904
905 bool val_json(Json_wrapper *wr) override;
906};
907
908/**
909 Represents the JSON function JSON_MERGE. It is a deprecated alias
910 for JSON_MERGE_PRESERVE.
911*/
913 public:
914 Item_func_json_merge(THD *thd, const POS &pos, PT_item_list *a);
915
916 bool is_deprecated() const override { return true; }
917};
918
919/**
920 Represents the JSON function JSON_MERGE_PATCH.
921*/
923 public:
925 : Item_json_func(thd, pos, a) {}
926
927 const char *func_name() const override { return "json_merge_patch"; }
928
929 bool resolve_type(THD *thd) override {
930 if (Item_json_func::resolve_type(thd)) return true;
931 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
932 return false;
933 }
934
935 bool val_json(Json_wrapper *wr) override;
936};
937
938/**
939 Represents the JSON function JSON_QUOTE()
940*/
943
944 public:
946 : Item_str_func(pos, a) {}
947
948 const char *func_name() const override { return "json_quote"; }
949
950 enum Functype functype() const override { return JSON_QUOTE_FUNC; }
951
952 bool resolve_type(THD *thd) override {
953 if (reject_vector_args()) return true;
954 if (param_type_is_default(thd, 0, -1)) return true;
955 set_nullable(true);
956
957 /*
958 Any interior character could be replaced by a 6 character
959 escape sequence. Plus we will add 2 framing quote characters.
960 */
961 const uint32 max_char_length = (6 * args[0]->max_char_length()) + 2;
963 return false;
964 }
965
966 String *val_str(String *tmpspace) override;
967};
968
969/**
970 Represents the JSON function JSON_UNQUOTE()
971*/
975
976 public:
978 : Item_str_func(pos, a) {}
979
980 Item_func_json_unquote(const POS &pos, Item *a) : Item_str_func(pos, a) {}
981
982 const char *func_name() const override { return "json_unquote"; }
983
984 enum Functype functype() const override { return JSON_UNQUOTE_FUNC; }
985
986 bool resolve_type(THD *thd) override {
987 if (reject_vector_args()) return true;
988 if (param_type_is_default(thd, 0, -1)) return true;
989 set_nullable(true);
991 return false;
992 }
993
994 String *val_str(String *str) override;
995};
996
997/**
998 Represents the JSON_PRETTY function.
999*/
1001 public:
1002 Item_func_json_pretty(const POS &pos, Item *a) : Item_str_func(pos, a) {}
1003
1004 const char *func_name() const override { return "json_pretty"; }
1005
1006 enum Functype functype() const override { return JSON_PRETTY_FUNC; }
1007
1008 bool resolve_type(THD *thd) override {
1009 if (reject_vector_args()) return true;
1010 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
1012 return false;
1013 }
1014
1015 String *val_str(String *str) override;
1016};
1017
1018/**
1019 Class that represents the function JSON_STORAGE_SIZE.
1020*/
1022 public:
1024 : Item_int_func(pos, a) {}
1025 const char *func_name() const override { return "json_storage_size"; }
1026 enum Functype functype() const override { return JSON_STORAGE_SIZE_FUNC; }
1027
1028 bool resolve_type(THD *thd) override {
1029 if (reject_vector_args()) return true;
1030 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
1031 if (Item_int_func::resolve_type(thd)) return true;
1032 set_nullable(true);
1033 return false;
1034 }
1035
1036 longlong val_int() override;
1037};
1038
1039/**
1040 Class that represents the function JSON_STORAGE_FREE.
1041*/
1043 public:
1045 : Item_int_func(pos, a) {}
1046 const char *func_name() const override { return "json_storage_free"; }
1047 enum Functype functype() const override { return JSON_STORAGE_FREE_FUNC; }
1048
1049 bool resolve_type(THD *thd) override {
1050 if (reject_vector_args()) return true;
1051 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
1052 return false;
1053 }
1054
1055 longlong val_int() override;
1056};
1057
1058/**
1059 Class that represents CAST(<expr> AS <type> ARRAY)
1060*/
1061
1062class Item_func_array_cast final : public Item_func {
1063 /// Type to cast to
1065 /**
1066 Whether use of CAST(.. AS .. ARRAY) is allowed
1067
1068 Currently use of CAST(.. AS .. ARRAY) is limited only to CREATE
1069 TABLE/INDEX. In all other cases an error is thrown. This flag is set to
1070 true only for allowed cases to ensure allowed function usage.
1071 */
1072 bool m_is_allowed{false};
1073
1074 /**
1075 An array used by #save_in_field_inner() to store the result of an array cast
1076 operation. It is cached in the Item in order to avoid the need for
1077 reallocation on each row.
1078 */
1080
1081 protected:
1082 void add_json_info(Json_object *obj) override;
1083
1084 public:
1085 Item_func_array_cast(const POS &pos, Item *a, Cast_target type, uint len_arg,
1086 uint dec_arg, const CHARSET_INFO *cs_arg);
1088 const char *func_name() const override { return "cast_as_array"; }
1089 enum Functype functype() const override { return TYPECAST_FUNC; }
1090 bool returns_array() const override { return true; }
1091 bool val_json(Json_wrapper *wr) override;
1092 void print(const THD *thd, String *str,
1093 enum_query_type query_type) const override;
1094 enum Item_result result_type() const override;
1095 bool resolve_type(THD *) override;
1096 Field *tmp_table_field(TABLE *table) override;
1097 bool fix_fields(THD *thd, Item **ref) override;
1098 void cleanup() override;
1099 void allow_array_cast() override { m_is_allowed = true; }
1101 bool no_conversions) override;
1102 // Regular val_x() funcs shouldn't be called
1103 /* purecov: begin inspected */
1104 longlong val_int() override {
1105 assert(false);
1106 return 0;
1107 }
1108 String *val_str(String *) override {
1109 assert(false);
1110 return nullptr;
1111 }
1113 assert(false);
1114 return nullptr;
1115 }
1116 double val_real() override {
1117 assert(false);
1118 return 0;
1119 }
1121 assert(false);
1122 return true;
1123 }
1124 bool get_time(MYSQL_TIME *) override {
1125 assert(false);
1126 return true;
1127 }
1128 /* purecov: end */
1129};
1130
1132 public:
1134 : Item_bool_func(pos, a, b) {}
1135 const char *func_name() const override { return "json_overlaps"; }
1136 enum Functype functype() const override { return JSON_OVERLAPS; }
1137 bool gc_subst_analyzer(uchar **) override { return true; }
1138 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1139 longlong val_int() override;
1140 Item *key_item() const override;
1142 return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
1143 }
1144};
1145
1147 public:
1148 Item_func_member_of(const POS &pos, Item *a, Item *b)
1149 : Item_bool_func(pos, a, b) {}
1150 const char *func_name() const override { return "member of"; }
1151 enum Functype functype() const override { return MEMBER_OF_FUNC; }
1152 bool resolve_type(THD *thd) override {
1153 if (reject_vector_args()) return true;
1154 if (param_type_is_default(thd, 0, 2, MYSQL_TYPE_JSON)) return true;
1156 return false;
1157 }
1158 bool gc_subst_analyzer(uchar **) override { return true; }
1159 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1160 longlong val_int() override;
1161 void print(const THD *thd, String *str,
1162 enum_query_type query_type) const override;
1163 Item *key_item() const override { return args[1]; }
1165 return (arg == args[1]) ? CACHE_JSON_VALUE
1166 : ((arg == args[0]) ? CACHE_JSON_ATOM : CACHE_NONE);
1167 }
1168};
1169
1170/**
1171 Class implementing the JSON_VALUE function.
1172
1173 Functionality-wise it's a combination of CAST, JSON_UNQUOTE and JSON_EXTRACT,
1174 but with additional functionality for flexible handling of empty values and
1175 conversion errors.
1176*/
1177class Item_func_json_value final : public Item_func {
1178 public:
1179 Item_func_json_value(const POS &pos, Item *arg, Item *path,
1180 const Cast_type &cast_type, unsigned length,
1181 unsigned precision, Json_on_response_type on_empty_type,
1182 Item *on_empty_default,
1183 Json_on_response_type on_error_type,
1184 Item *on_error_default);
1186 const char *func_name() const override { return "json_value"; }
1187 enum Functype functype() const override { return JSON_VALUE_FUNC; }
1188 enum Item_result result_type() const override;
1189 bool resolve_type(THD *) override;
1190 bool fix_fields(THD *thd, Item **ref) override;
1191 void print(const THD *thd, String *str,
1192 enum_query_type query_type) const override;
1193 bool eq_specific(const Item *item) const override;
1194 bool val_json(Json_wrapper *wr) override;
1195 String *val_str(String *buffer) override;
1196 double val_real() override;
1197 longlong val_int() override;
1199 bool get_date(MYSQL_TIME *ltime, my_time_flags_t flags) override;
1200 bool get_time(MYSQL_TIME *ltime) override;
1201 Json_on_response_type on_empty_response_type() const;
1202 Json_on_response_type on_error_response_type() const;
1203
1204 private:
1205 /// Represents a default value given in JSON_VALUE's DEFAULT xxx ON EMPTY or
1206 /// DEFAULT xxx ON ERROR clause.
1207 struct Default_value;
1208
1209 /// Parsed path.
1211 /// Type of the ON EMPTY clause.
1213 /// Type of the ON ERROR clause.
1215 /// The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
1217 /// The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
1219 /// The target data type.
1221
1222 /**
1223 Creates a Json_value_default object representing the default value given in
1224 a DEFAULT xxx ON EMPTY clause or a DEFAULT xxx ON ERROR clause.
1225
1226 @param thd the current session
1227 @param item the Item that represents the default value expression
1228 @return a pointer to the created object on success, nullptr on error
1229 */
1230 unique_ptr_destroy_only<Default_value> create_json_value_default(THD *thd,
1231 Item *item);
1232
1233 /**
1234 Extracts the JSON value at the given path.
1235
1236 @param[out] json the extracted JSON value, if the path matched exactly
1237 one value; empty otherwise
1238 @param[out] return_default the default value to return if a
1239 DEFAULT ... ON EMPTY or DEFAULT ... ON ERROR clause was invoked,
1240 or nullptr if no DEFAULT clause was invoked
1241 @return true if an error was raised, false otherwise
1242 */
1243 bool extract_json_value(Json_wrapper *json,
1244 const Default_value **return_default);
1245
1246 /// Implements val_int() for RETURNING SIGNED and RETURNING UNSIGNED.
1247 int64_t extract_integer_value();
1248 /// Implements val_int() for RETURNING YEAR
1249 int64_t extract_year_value();
1250 /// Implements get_date() for RETURNING DATE.
1251 bool extract_date_value(MYSQL_TIME *ltime);
1252 /// Implements get_time() for RETURNING TIME.
1253 bool extract_time_value(MYSQL_TIME *ltime);
1254 /// Implements get_date() for RETURNING DATETIME.
1255 bool extract_datetime_value(MYSQL_TIME *ltime);
1256 /// Implements val_decimal() for RETURNING DECIMAL.
1257 my_decimal *extract_decimal_value(my_decimal *value);
1258 /// Implements val_str() for RETURNING CHAR and RETURNING BINARY.
1259 String *extract_string_value(String *buffer);
1260 /// Implements val_real() for RETURNING FLOAT/REAL/DOUBLE.
1261 double extract_real_value();
1262};
1263
1264/**
1265 Turn a GEOMETRY value into a JSON value per the GeoJSON specification
1266 revision 1.0. This method is implemented in item_geofunc.cc.
1267
1268 @param[in,out] wr The wrapper to be stuffed with the JSON value.
1269 @param[in] swkb The source GEOMETRY value.
1270 @param[in] calling_function Name of user-invoked function (for errors)
1271 @param[in] max_decimal_digits See the user documentation for ST_AsGeoJSON.
1272 @param[in] add_bounding_box See the user documentation for ST_AsGeoJSON.
1273 @param[in] add_short_crs_urn See the user documentation for ST_AsGeoJSON.
1274 @param[in] add_long_crs_urn See the user documentation for ST_AsGeoJSON.
1275 @param[in,out] geometry_srid Spatial Reference System Identifier to be filled
1276 in.
1277
1278 @return false if the conversion succeeds, true otherwise
1279*/
1280bool geometry_to_json(Json_wrapper *wr, String *swkb,
1281 const char *calling_function, int max_decimal_digits,
1282 bool add_bounding_box, bool add_short_crs_urn,
1283 bool add_long_crs_urn, uint32 *geometry_srid);
1284
1285/**
1286 Convert a value represented with an Item to a JSON value
1287
1288 @param[in] item the input value, may be any data type
1289 @param[in] func_name for error reporting
1290 @param[in,out] wr the result wrapper for the JSON value
1291
1292 @return false if success, true if error
1293*/
1294bool convert_value_to_json(Item *item, const char *func_name, Json_wrapper *wr);
1295/**
1296 Convert JSON values or MySQL values to JSON. Converts SQL NULL
1297 to the JSON null literal.
1298
1299 @param[in] args arguments to function
1300 @param[in] arg_idx the index of the argument to process
1301 @param[in] calling_function name of the calling function
1302 @param[in,out] value working area (if the returned Json_wrapper points
1303 to a binary value rather than a DOM, this string
1304 will end up holding the binary representation, and
1305 it must stay alive until the wrapper is destroyed
1306 or converted from binary to DOM)
1307 @param[in,out] tmp temporary scratch space for converting strings to
1308 the correct charset; only used if accept_string is
1309 true and conversion is needed
1310 @param[in,out] wr the result wrapper
1311 @returns false if we found a value or NULL, true otherwise
1312*/
1313bool get_atom_null_as_null(Item **args, uint arg_idx,
1314 const char *calling_function, String *value,
1315 String *tmp, Json_wrapper *wr);
1316
1317/**
1318 Gets a JSON object member name from an Item. An error is raised if
1319 the Item evaluates to NULL, or if it cannot be converted to a
1320 utf8mb4 string.
1321
1322 @param[in] thd THD handle
1323 @param[in] arg_item An argument Item
1324 @param[out] value Where to materialize the arg_item's string value
1325 @param[out] utf8_res Buffer for use by ensure_utf8mb4.
1326 @param[out] safep String pointer after any relevant conversion
1327 @param[out] safe_length Corresponding string length
1328
1329 @returns true if the Item is not a utf8mb4 string
1330*/
1331bool get_json_object_member_name(const THD *thd, Item *arg_item, String *value,
1332 String *utf8_res, const char **safep,
1333 size_t *safe_length);
1334using Json_dom_ptr = std::unique_ptr<Json_dom>;
1335
1336bool parse_json(const String &res, Json_dom_ptr *dom, bool require_str_or_json,
1337 const JsonParseErrorHandler &error_handler,
1338 const JsonErrorHandler &depth_handler);
1339
1340/**
1341 Apply a sequence of JSON diffs to the value stored in a JSON column.
1342
1343 @param field the column to update
1344 @param diffs the diffs to apply
1345 @return an enum_json_diff_status value that tells if the diffs were
1346 applied successfully
1347 */
1349 const Json_diff_vector *diffs);
1350
1351bool save_json_to_field(THD *thd, Field *field, const Json_wrapper *w,
1352 bool no_error);
1353#endif /* ITEM_JSON_FUNC_INCLUDED */
A field that stores a JSON value.
Definition: field.h:3840
Definition: field.h:569
Definition: item_cmpfunc.h:299
Class that represents CAST(<expr> AS <type> ARRAY)
Definition: item_json_func.h:1062
unique_ptr_destroy_only< Json_array > m_result_array
An array used by save_in_field_inner() to store the result of an array cast operation.
Definition: item_json_func.h:1079
bool get_time(MYSQL_TIME *) override
Definition: item_json_func.h:1124
void allow_array_cast() override
A helper function to ensure proper usage of CAST(.
Definition: item_json_func.h:1099
const char * func_name() const override
Definition: item_json_func.h:1088
longlong val_int() override
Definition: item_json_func.h:1104
bool returns_array() const override
Whether the item returns array of its data type.
Definition: item_json_func.h:1090
bool get_date(MYSQL_TIME *, my_time_flags_t) override
Definition: item_json_func.h:1120
my_decimal * val_decimal(my_decimal *) override
Definition: item_json_func.h:1112
enum Functype functype() const override
Definition: item_json_func.h:1089
double val_real() override
Definition: item_json_func.h:1116
~Item_func_array_cast() override
Cast_target cast_type
Type to cast to.
Definition: item_json_func.h:1064
String * val_str(String *) override
Definition: item_json_func.h:1108
Represents the JSON function JSON_ARRAY_APPEND()
Definition: item_json_func.h:646
Item_func_json_array_append(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:648
const char * func_name() const override
Definition: item_json_func.h:651
Represents the JSON function JSON_ARRAY_INSERT()
Definition: item_json_func.h:672
Item_func_json_array_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:674
const char * func_name() const override
Definition: item_json_func.h:677
Represents the JSON function JSON_ARRAY()
Definition: item_json_func.h:729
enum Functype functype() const override
Definition: item_json_func.h:740
Item_func_json_array(Args &&...parent_args)
Definition: item_json_func.h:732
const char * func_name() const override
Definition: item_json_func.h:739
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:742
Represents the JSON function JSON_CONTAINS_PATH()
Definition: item_json_func.h:440
void cleanup() override
Cleanup between executions of the statement.
Definition: item_json_func.cc:911
bool is_bool_func() const override
Definition: item_json_func.h:456
longlong val_int() override
Definition: item_json_func.cc:918
Json_path_cache m_path_cache
Definition: item_json_func.h:445
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:460
enum Functype functype() const override
Definition: item_json_func.h:454
String m_doc_value
Definition: item_json_func.h:441
Item_func_json_contains_path(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:448
const char * func_name() const override
Definition: item_json_func.h:453
enum_const_item_cache can_cache_json_arg(Item *arg) override
Whether an arg of a JSON function can be cached to avoid repetitive string->JSON conversion.
Definition: item_json_func.h:471
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:442
Represents the JSON function JSON_CONTAINS()
Definition: item_json_func.h:404
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:415
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:414
Item_func_json_contains(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:409
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:421
longlong val_int() override
Definition: item_json_func.cc:853
String m_doc_value
Definition: item_json_func.h:405
enum Functype functype() const override
Definition: item_json_func.h:413
Json_path_cache m_path_cache
Definition: item_json_func.h:406
enum_const_item_cache can_cache_json_arg(Item *arg) override
Whether an arg of a JSON function can be cached to avoid repetitive string->JSON conversion.
Definition: item_json_func.h:432
void cleanup() override
Cleanup between executions of the statement.
Definition: item_json_func.cc:847
const char * func_name() const override
Definition: item_json_func.h:412
bool is_bool_func() const override
Definition: item_json_func.h:417
Represents the JSON function JSON_DEPTH()
Definition: item_json_func.h:542
enum Functype functype() const override
Definition: item_json_func.h:549
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:551
longlong val_int() override
Definition: item_json_func.cc:1555
String m_doc_value
Definition: item_json_func.h:543
const char * func_name() const override
Definition: item_json_func.h:548
Item_func_json_depth(const POS &pos, Item *a)
Definition: item_json_func.h:546
Represents the JSON function JSON_DUALITY_OBJECT()
Definition: item_json_func.h:789
jdv::Duality_view_tags table_tags() const
Definition: item_json_func.h:813
enum Functype functype() const override
Definition: item_json_func.h:803
bool get_inject_object_hash() const
Definition: item_json_func.h:796
std::unordered_set< std::string > get_json_arrayagg_keys()
Definition: item_json_func.h:817
Item_func_json_row_object super
Definition: item_json_func.h:790
const char * func_name() const override
Definition: item_json_func.h:802
std::unordered_set< std::string > m_json_arrayagg_keys
Definition: item_json_func.h:795
Represents the JSON function JSON_EXTRACT()
Definition: item_json_func.h:590
const char * func_name() const override
Definition: item_json_func.h:600
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item_json_func.cc:1702
enum Functype functype() const override
Definition: item_json_func.h:601
Item_func_json_extract(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:594
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:603
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1635
Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:597
String m_doc_value
Definition: item_json_func.h:591
Represents the JSON function JSON_INSERT()
Definition: item_json_func.h:659
Item_func_json_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:661
const char * func_name() const override
Definition: item_json_func.h:664
Represents the JSON function JSON_KEYS()
Definition: item_json_func.h:564
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1576
String m_doc_value
Definition: item_json_func.h:565
Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:571
Item_func_json_keys(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:568
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:576
const char * func_name() const override
Definition: item_json_func.h:574
Represents the JSON function JSON_LENGTH()
Definition: item_json_func.h:519
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:525
Item_func_json_length(const POS &pos, Item *doc)
Definition: item_json_func.h:523
longlong val_int() override
Definition: item_json_func.cc:1531
String m_doc_value
Definition: item_json_func.h:520
enum Functype functype() const override
Definition: item_json_func.h:534
const char * func_name() const override
Definition: item_json_func.h:533
Represents the JSON function JSON_MERGE_PATCH.
Definition: item_json_func.h:922
Item_func_json_merge_patch(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:924
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:929
const char * func_name() const override
Definition: item_json_func.h:927
Represents the JSON function JSON_MERGE_PRESERVE.
Definition: item_json_func.h:892
const char * func_name() const override
Definition: item_json_func.h:897
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:899
Item_func_json_merge_preserve(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:894
Represents the JSON function JSON_MERGE.
Definition: item_json_func.h:912
bool is_deprecated() const override
Definition: item_json_func.h:916
Definition: item_json_func.h:1131
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:1137
enum Functype functype() const override
Definition: item_json_func.h:1136
const char * func_name() const override
Definition: item_json_func.h:1135
Item_func_json_overlaps(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:1133
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:1138
enum_const_item_cache can_cache_json_arg(Item *arg) override
Whether an arg of a JSON function can be cached to avoid repetitive string->JSON conversion.
Definition: item_json_func.h:1141
Represents the JSON_PRETTY function.
Definition: item_json_func.h:1000
const char * func_name() const override
Definition: item_json_func.h:1004
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:1008
enum Functype functype() const override
Definition: item_json_func.h:1006
Item_func_json_pretty(const POS &pos, Item *a)
Definition: item_json_func.h:1002
Represents the JSON function JSON_QUOTE()
Definition: item_json_func.h:941
enum Functype functype() const override
Definition: item_json_func.h:950
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:952
String m_value
Definition: item_json_func.h:942
Item_func_json_quote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:945
const char * func_name() const override
Definition: item_json_func.h:948
Represents the JSON function JSON_REMOVE()
Definition: item_json_func.h:868
Item_func_json_remove(Args &&...parent_args)
Definition: item_json_func.h:874
const char * func_name() const override
Definition: item_json_func.h:877
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:870
String m_doc_value
Definition: item_json_func.h:869
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:879
Represents the JSON function JSON_REPLACE()
Definition: item_json_func.h:717
Item_func_json_replace(Args &&...parent_args)
Definition: item_json_func.h:720
const char * func_name() const override
Definition: item_json_func.h:723
Represents the JSON function JSON_OBJECT()
Definition: item_json_func.h:754
String tmp_key_value
Definition: item_json_func.h:755
Item_func_json_row_object(THD *thd, mem_root_deque< Item * > *list)
Definition: item_json_func.h:766
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:777
enum Functype functype() const override
Definition: item_json_func.h:775
Item_func_json_row_object(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:758
const char * func_name() const override
Definition: item_json_func.h:774
Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
Definition: item_json_func.h:346
Item_func_json_schema_valid(const POS &pos, Item *a, Item *b)
Definition: item_json_func.cc:687
bool val_bool() override
Definition: item_json_func.cc:750
bool fix_fields(THD *, Item **) override
Definition: item_json_func.cc:674
longlong val_int() override
Definition: item_json_func.h:356
Json_schema_validator m_cached_schema_validator
Definition: item_json_func.h:363
enum Functype functype() const override
Definition: item_json_func.h:352
const char * func_name() const override
Definition: item_json_func.h:351
~Item_func_json_schema_valid() override
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_json_func.cc:685
Represents the JSON function JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> )
Definition: item_json_func.h:370
const char * func_name() const override
Definition: item_json_func.h:376
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:386
Json_schema_validator m_cached_schema_validator
Definition: item_json_func.h:398
void cleanup() override
JSON_*() support methods.
Definition: item_json_func.cc:789
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:801
bool fix_fields(THD *, Item **) override
Definition: item_json_func.cc:778
Item_func_json_schema_validation_report(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.cc:794
enum Functype functype() const override
Definition: item_json_func.h:380
Represents the JSON function JSON_SEARCH()
Definition: item_json_func.h:825
String m_doc_value
Definition: item_json_func.h:826
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:855
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:827
Item_func_like * m_like_node
Definition: item_json_func.h:831
Item_func_json_search(Args &&...parent_args)
Construct a JSON_SEARCH() node.
Definition: item_json_func.h:840
enum Functype functype() const override
Definition: item_json_func.h:846
const char * func_name() const override
Definition: item_json_func.h:844
Item_string * m_source_string_item
Definition: item_json_func.h:830
Common base class for JSON_SET() and JSON_REPLACE().
Definition: item_json_func.h:685
Item_func_json_set_replace(bool json_set, Args &&...parent_args)
Definition: item_json_func.h:693
const bool m_json_set
True if this is JSON_SET, false if it is JSON_REPLACE.
Definition: item_json_func.h:687
Json_path_clone m_path
Definition: item_json_func.h:688
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:689
Represents the JSON function JSON_SET()
Definition: item_json_func.h:705
Item_func_json_set(Args &&...parent_args)
Definition: item_json_func.h:708
const char * func_name() const override
Definition: item_json_func.h:711
Class that represents the function JSON_STORAGE_FREE.
Definition: item_json_func.h:1042
enum Functype functype() const override
Definition: item_json_func.h:1047
Item_func_json_storage_free(const POS &pos, Item *a)
Definition: item_json_func.h:1044
const char * func_name() const override
Definition: item_json_func.h:1046
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:1049
Class that represents the function JSON_STORAGE_SIZE.
Definition: item_json_func.h:1021
Item_func_json_storage_size(const POS &pos, Item *a)
Definition: item_json_func.h:1023
const char * func_name() const override
Definition: item_json_func.h:1025
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:1028
enum Functype functype() const override
Definition: item_json_func.h:1026
Represents the JSON function JSON_TYPE.
Definition: item_json_func.h:479
const char * func_name() const override
Definition: item_json_func.h:485
String * val_str(String *) override
Definition: item_json_func.cc:1056
String m_value
Definition: item_json_func.h:480
Item_func_json_type(const POS &pos, Item *a)
Definition: item_json_func.h:483
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.cc:1047
enum Functype functype() const override
Definition: item_json_func.h:486
Represents the JSON function JSON_UNQUOTE()
Definition: item_json_func.h:972
String m_value
Definition: item_json_func.h:973
const char * func_name() const override
Definition: item_json_func.h:982
Item_func_json_unquote(const POS &pos, Item *a)
Definition: item_json_func.h:980
Item_func_json_unquote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:977
enum Functype functype() const override
Definition: item_json_func.h:984
String m_conversion_buffer
Definition: item_json_func.h:974
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:986
Represents the JSON function JSON_VALID( <value> )
Definition: item_json_func.h:322
const char * func_name() const override
Definition: item_json_func.h:328
Item_func_json_valid(const POS &pos, Item *a)
Definition: item_json_func.h:326
longlong val_int() override
Definition: item_json_func.cc:629
enum Functype functype() const override
Definition: item_json_func.h:329
bool is_bool_func() const override
Definition: item_json_func.h:331
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:335
String m_value
Definition: item_json_func.h:323
Class implementing the JSON_VALUE function.
Definition: item_json_func.h:1177
enum Functype functype() const override
Definition: item_json_func.h:1187
unique_ptr_destroy_only< Default_value > m_default_error
The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
Definition: item_json_func.h:1218
~Item_func_json_value() override
Json_on_response_type m_on_error
Type of the ON ERROR clause.
Definition: item_json_func.h:1214
Cast_target m_cast_target
The target data type.
Definition: item_json_func.h:1220
unique_ptr_destroy_only< Default_value > m_default_empty
The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
Definition: item_json_func.h:1216
const char * func_name() const override
Definition: item_json_func.h:1186
Json_on_response_type m_on_empty
Type of the ON EMPTY clause.
Definition: item_json_func.h:1212
Json_path m_path_json
Parsed path.
Definition: item_json_func.h:1207
Definition: item_cmpfunc.h:2454
Definition: item_json_func.h:1146
enum_const_item_cache can_cache_json_arg(Item *arg) override
Whether an arg of a JSON function can be cached to avoid repetitive string->JSON conversion.
Definition: item_json_func.h:1164
Item_func_member_of(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:1148
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:1152
enum Functype functype() const override
Definition: item_json_func.h:1151
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:1158
Item * key_item() const override
Definition: item_json_func.h:1163
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:1159
const char * func_name() const override
Definition: item_json_func.h:1150
Base class for all the functions that take a JSON document as the first argument and one of more pair...
Definition: item_json_func.h:619
void update_used_tables() final
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_json_func.cc:1749
String m_doc_value
Definition: item_json_func.h:631
Item_func_modify_json_in_path(Args &&...parent_args)
Definition: item_json_func.h:622
table_map calculate_not_null_tables() const
Calculates the set of tables to return from not_used_tables().
Definition: item_json_func.cc:1754
bool resolve_type(THD *thd) final
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.cc:1736
Definition: item_func.h:100
Item ** args
Array of pointers to arguments.
Definition: item_func.h:107
bool reject_vector_args()
Definition: item_func.cc:1596
Functype
Definition: item_func.h:209
@ JSON_VALUE_FUNC
Definition: item_func.h:355
@ JSON_SCHEMA_VALIDATION_REPORT_FUNC
Definition: item_func.h:357
@ JSON_STORAGE_SIZE_FUNC
Definition: item_func.h:353
@ JSON_SEARCH_FUNC
Definition: item_func.h:356
@ JSON_STORAGE_FREE_FUNC
Definition: item_func.h:354
@ JSON_CONTAINS
Definition: item_func.h:328
@ JSON_VALID_FUNC
Definition: item_func.h:348
@ JSON_UNQUOTE_FUNC
Definition: item_func.h:330
@ JSON_CONTAINS_PATH_FUNC
Definition: item_func.h:352
@ JSON_ARRAY_FUNC
Definition: item_func.h:347
@ JSON_SCHEMA_VALID_FUNC
Definition: item_func.h:358
@ JSON_DEPTH_FUNC
Definition: item_func.h:343
@ JSON_QUOTE_FUNC
Definition: item_func.h:351
@ JSON_OBJECT_FUNC
Definition: item_func.h:345
@ JSON_TYPE_FUNC
Definition: item_func.h:349
@ JSON_PRETTY_FUNC
Definition: item_func.h:350
@ JSON_EXTRACT_FUNC
Definition: item_func.h:344
@ MEMBER_OF_FUNC
Definition: item_func.h:331
@ TYPECAST_FUNC
Definition: item_func.h:258
@ JSON_OVERLAPS
Definition: item_func.h:329
@ JSON_DUALITY_OBJECT_FUNC
Definition: item_func.h:346
@ JSON_LENGTH_FUNC
Definition: item_func.h:342
virtual bool eq_specific(const Item *) const
Provide a more specific equality check for a function.
Definition: item_func.h:537
optimize_type
Definition: item_func.h:361
@ OPTIMIZE_KEY
Definition: item_func.h:363
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:714
virtual const char * func_name() const =0
enum Type type() const override
Definition: item_func.h:368
virtual Item * key_item() const
Definition: item_func.h:540
bool param_type_is_default(THD *thd, uint start, uint end, uint step, enum_field_types def)
For arguments of this Item_func ("args" array), in range [start, start+step, start+2*step,...
Definition: item_func.cc:528
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:748
bool fix_fields(THD *, Item **ref) override
Definition: item_func.cc:406
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:130
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_func.cc:793
bool null_on_null
Affects how to determine that NULL argument implies a NULL function return.
Definition: item_func.h:186
Definition: item_func.h:1017
Base class for all item functions that a return JSON value.
Definition: item_json_func.h:161
void mark_for_partial_update(const Field_json *field)
Mark this expression as used in partial update.
Definition: item_json_func.cc:2085
Item_json_func(THD *thd, Args &&...parent_args)
Construct an Item_json_func instance.
Definition: item_json_func.h:189
String m_conversion_buffer
String used for converting JSON text values to utf8mb4 charset.
Definition: item_json_func.h:169
longlong val_int() override
Definition: item_json_func.cc:1133
Item_result cast_to_int_type() const override
Definition: item_json_func.h:210
String m_value
String used when reading JSON binary values or JSON text values.
Definition: item_json_func.h:167
virtual bool can_use_in_partial_update() const
Can this function type be used in partial update?
Definition: item_json_func.h:163
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_json_func.cc:1110
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:195
bool get_time(MYSQL_TIME *ltime) override
Definition: item_json_func.cc:1122
String * val_str(String *arg) override
Definition: item_json_func.cc:1095
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_json_func.cc:1155
enum Item_result result_type() const override
Definition: item_json_func.h:200
String m_string_buffer
String used for converting a JSON value to text in val_str().
Definition: item_json_func.h:171
bool supports_partial_update(const Field_json *field) const override
Does this function call support partial update of the given JSON column?
Definition: item_json_func.cc:2102
Json_path_cache m_path_cache
Definition: item_json_func.h:174
const Field_json * m_partial_update_column
Target column for partial update, if this function is used in an update statement and partial update ...
Definition: item_json_func.h:180
double val_real() override
Definition: item_json_func.cc:1142
void cleanup() override
JSON_*() support methods.
Definition: item_json_func.cc:623
Definition: item_strfunc.h:78
Definition: item.h:5463
Represents a "CAST( <value> AS JSON )" coercion.
Definition: item_json_func.h:496
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1475
const char * cast_type() const
Definition: item_json_func.h:512
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_json_func.cc:1522
Item_json_func super
Definition: item_json_func.h:497
const char * func_name() const override
Definition: item_json_func.h:511
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:503
Item_typecast_json(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:500
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:927
uint32 max_char_length() const
Definition: item.h:3369
void set_nullable(bool nullable)
Definition: item.h:3688
virtual bool propagate_type(THD *thd, const Type_properties &type)
Propagate data type specifications into parameters and user variables.
Definition: item.h:1311
virtual type_conversion_status save_in_field_inner(Field *field, bool no_conversions)
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item.cc:6863
virtual bool val_json(Json_wrapper *result)
Get a JSON value from an Item.
Definition: item.h:2091
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:995
@ CACHE_NONE
Don't cache.
Definition: item.h:997
@ CACHE_JSON_VALUE
Source data is a JSON string, parse and cache result.
Definition: item.h:999
@ CACHE_JSON_ATOM
Source data is SQL scalar, convert and cache result.
Definition: item.h:1001
void set_data_type_json()
Set the data type of the Item to be JSON.
Definition: item.h:1761
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1597
virtual void mark_json_as_scalar()
For Items with data type JSON, mark that a string argument is treated as a scalar JSON value.
Definition: item.h:1352
Represents a JSON array container, i.e.
Definition: json_dom.h:517
Vector of logical diffs describing changes to a JSON column.
Definition: json_diff.h:141
JSON DOM abstract base class.
Definition: json_dom.h:176
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:371
Path cache for JSON functions.
Definition: item_json_func.h:94
Json_path_cache(THD *thd, uint size)
Json_path_cache.
Definition: item_json_func.cc:559
const Json_path * get_path(uint arg_idx) const
Return an already parsed path expression.
Definition: item_json_func.cc:604
void reset_cache()
Reset the cache for re-use when a statement is re-executed.
Definition: item_json_func.cc:614
enum_path_status
Enum that tells the status of a cell in m_paths.
Definition: item_json_func.h:103
Prealloced_array< Json_path, 8 > m_paths
List of paths.
Definition: item_json_func.h:100
Mem_root_array< Path_cell > m_arg_idx_to_vector_idx
Map argument indexes to indexes into m_paths.
Definition: item_json_func.h:116
String m_path_value
Holder for path strings.
Definition: item_json_func.h:97
bool parse_and_cache_path(const THD *thd, Item **args, uint arg_idx, bool forbid_wildcards)
Parse a path expression if necessary.
Definition: item_json_func.cc:566
A lightweight path expression.
Definition: json_path.h:444
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:1895
This is just a facade to the Json_schema_validator and it is used to hide the dependency on the rapid...
Definition: json_schema.h:155
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1160
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:105
Definition: parse_tree_nodes.h:5848
virtual void add_json_info(Json_object *json_obj)
Add all the node-specific json fields.
Definition: parse_tree_node_base.h:304
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
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
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:96
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
This file contains the field type.
@ MYSQL_TYPE_JSON
Definition: field_types.h:80
Cast_target
Definition: item_create.h:56
static int flags[50]
Definition: hp_test1.cc:40
bool json_value(Item *arg, Json_wrapper *result, bool *has_value)
Return the JSON value of the argument in a wrapper.
Definition: item_json_func.cc:988
enum_json_diff_status apply_json_diffs(Field_json *field, const Json_diff_vector *diffs)
Apply a sequence of JSON diffs to the value stored in a JSON column.
Definition: item_json_func.cc:163
bool geometry_to_json(Json_wrapper *wr, String *swkb, const char *calling_function, int max_decimal_digits, bool add_bounding_box, bool add_short_crs_urn, bool add_long_crs_urn, uint32 *geometry_srid)
Turn a GEOMETRY value into a JSON value per the GeoJSON specification revision 1.0.
Definition: item_geofunc.cc:2331
bool ensure_utf8mb4(const String &val, String *buf, const char **resptr, size_t *reslength, bool require_string)
Check a non-empty val for character set.
Definition: item_json_func.cc:87
bool save_json_to_field(THD *thd, Field *field, const Json_wrapper *w, bool no_error)
Save JSON to a given field.
Definition: item_json_func.cc:4051
bool get_json_atom_wrapper(Item **args, uint arg_idx, const char *calling_function, String *value, String *tmp, Json_wrapper *wr, Json_scalar_holder *scalar, bool accept_string)
Convert Json values or MySQL values to JSON.
Definition: item_json_func.cc:1404
bool get_json_wrapper(Item **args, uint arg_idx, String *str, const char *func_name, Json_wrapper *wrapper)
Return the JSON value of the argument in a wrapper.
Definition: item_json_func.cc:1008
bool get_json_object_member_name(const THD *thd, Item *arg_item, String *value, String *utf8_res, const char **safep, size_t *safe_length)
Gets a JSON object member name from an Item.
Definition: item_json_func.cc:322
bool parse_json(const String &res, Json_dom_ptr *dom, bool require_str_or_json, const JsonParseErrorHandler &error_handler, const JsonErrorHandler &depth_handler)
Parse a JSON dom out of an argument to a JSON function.
Definition: item_json_func.cc:138
bool sql_scalar_to_json(Item *arg, const char *calling_function, String *value, String *tmp, Json_wrapper *wr, Json_scalar_holder *scalar, bool scalar_string)
Get a JSON value from an SQL scalar value.
Definition: item_json_func.cc:1210
bool get_atom_null_as_null(Item **args, uint arg_idx, const char *calling_function, String *value, String *tmp, Json_wrapper *wr)
Convert JSON values or MySQL values to JSON.
Definition: item_json_func.cc:1461
bool convert_value_to_json(Item *item, const char *func_name, Json_wrapper *wr)
Convert a value represented with an Item to a JSON value.
enum_one_or_all_type
For use by JSON_CONTAINS_PATH() and JSON_SEARCH()
Definition: item_json_func.h:79
@ ooa_null
Definition: item_json_func.h:82
@ ooa_one
Definition: item_json_func.h:80
@ ooa_all
Definition: item_json_func.h:81
@ ooa_uninitialized
Definition: item_json_func.h:84
@ ooa_error
Definition: item_json_func.h:83
enum_json_diff_status
The result of applying JSON diffs on a JSON value using apply_json_diff().
Definition: json_diff.h:264
std::unique_ptr< Json_dom > Json_dom_ptr
Definition: json_dom.h:67
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
This file contains interface support for the JSON path abstraction.
Functions for validating a string against a JSON Schema.
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_utf8mb4_bin
Definition: ctype-utf8.cc:7813
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:480
Some integer typedefs for easier portability.
uint8_t uint8
Definition: my_inttypes.h:63
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
uint16_t uint16
Definition: my_inttypes.h:65
uint32_t uint32
Definition: my_inttypes.h:67
uint64_t table_map
Definition: my_table_map.h:30
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:94
Common definition between mysql server & client.
#define MAX_BLOB_WIDTH
Default width for blob in bytes.
Definition: mysql_com.h:907
static char * path
Definition: mysqldump.cc:150
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1084
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
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
Duality_view_tags
Definition: content_tree.h:33
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
bool has_value(const std::optional< ValueType > &v)
Definition: gtid.h:93
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::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2880
PSI_memory_key key_memory_JSON
Definition: psi_memory_key.cc:53
type_conversion_status
Status when storing a value in a field or converting from one datatype to another.
Definition: field.h:196
Our own string classes, used pervasively throughout the executor.
Definition: m_ctype.h:421
Definition: parser_yystype.h:189
Definition: item_json_func.cc:4176
Struct that points to a cell in m_paths and tells its status.
Definition: item_json_func.h:110
size_t m_index
Definition: item_json_func.h:112
enum_path_status m_status
Definition: item_json_func.h:111
Definition: mysql_time.h:82
Bison "location" class.
Definition: parse_location.h:43
Definition: table.h:1433
Definition: result.h:30
Json_on_response_type
Types of ON EMPTY/ON ERROR clauses for JSON_TABLE and JSON_VALUE.
Definition: table_function.h:205
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:41
@ INT_RESULT
double
Definition: udf_registration_types.h:43