MySQL 26.10.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, 2026, 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 explicit 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 val_date(Date_val *date, my_time_flags_t flags) override;
203 bool val_time(Time_val *time) override;
205 longlong val_int() override;
206 double val_real() override;
207 my_decimal *val_decimal(my_decimal *decimal_value) override;
208
209 void cleanup() override;
210
211 Item_result cast_to_int_type() const override { return INT_RESULT; }
212
213 /**
214 Does this function call support partial update of the given JSON column?
215
216 JSON_SET, JSON_REPLACE and JSON_REMOVE support partial update of a JSON
217 column if the JSON column is the first argument of the function call, or if
218 the first argument is a sequence of nested JSON_SET, JSON_REPLACE and
219 JSON_REMOVE calls in which the JSON column is the first argument of the
220 inner function call.
221
222 For example, this expression can be used to partially update column
223 `json_col`:
224
225 JSON_SET(JSON_REPLACE(json_col, path1, val1), path2, val2)
226 */
227 bool supports_partial_update(const Field_json *field) const override;
228
229 /**
230 Mark this expression as used in partial update. Should only be
231 called if #supports_partial_update returns true.
232 */
233 void mark_for_partial_update(const Field_json *field);
234};
235
236bool sql_scalar_to_json(Item *arg, const char *calling_function, String *value,
237 String *tmp, Json_wrapper *wr,
238 Json_scalar_holder *scalar, bool scalar_string);
239
240/**
241 Return the JSON value of the argument in a wrapper.
242
243 Handles arguments with type JSON, including array objects (which do
244 not report type JSON but rather the type of individual elements).
245
246 Does not handle literals.
247 See also get_json_wrapper.
248
249 @param[in] arg the argument
250 @param[in,out] result the JSON value wrapper
251 @param[out] has_value true if argument was handled, false otherwise
252 undefined when error
253*/
254bool json_value(Item *arg, Json_wrapper *result, bool *has_value);
255
256/**
257 Return the JSON value of the argument in a wrapper. Abstracts whether
258 the value comes from a field or a function or a valid JSON text.
259
260 @param[in] args the arguments
261 @param[in] arg_idx the argument index
262 @param[out] str the string buffer
263 @param[in] func_name the name of the function we are executing
264 @param[out] wrapper the JSON value wrapper
265 @returns false if we found a value or NULL, true if not.
266*/
267bool get_json_wrapper(Item **args, uint arg_idx, String *str,
268 const char *func_name, Json_wrapper *wrapper);
269
270/**
271 Convert Json values or MySQL values to JSON.
272
273 @param[in] args arguments to function
274 @param[in] arg_idx the index of the argument to process
275 @param[in] calling_function name of the calling function
276 @param[in,out] value working area (if the returned Json_wrapper points
277 to a binary value rather than a DOM, this string
278 will end up holding the binary representation, and
279 it must stay alive until the wrapper is destroyed
280 or converted from binary to DOM)
281 @param[in,out] tmp temporary scratch space for converting strings to
282 the correct charset; only used if accept_string is
283 true and conversion is needed
284 @param[in,out] wr the result wrapper
285 @param[in,out] scalar pointer to pre-allocated memory that can be
286 borrowed by the result wrapper if the result is a
287 scalar. If the pointer is NULL, memory for a
288 scalar result will be allocated on the heap.
289 @param[in] accept_string
290 if true, accept MySQL strings as JSON strings
291 by converting them to UTF8, else emit an error
292 @returns false if we found a value or NULL, true otherwise
293*/
294bool get_json_atom_wrapper(Item **args, uint arg_idx,
295 const char *calling_function, String *value,
296 String *tmp, Json_wrapper *wr,
297 Json_scalar_holder *scalar, bool accept_string);
298
299/**
300 Check a non-empty val for character set. If it has character set
301 my_charset_binary, signal error and return false. Else, try to convert to
302 my_charset_utf8mb4_bin. If this fails, signal error and return true, else
303 return false.
304
305 @param[in] val the string to be checked
306 @param[in,out] buf buffer to hold the converted string
307 @param[out] resptr the resulting, possibly converted string,
308 only set if no error
309 @param[out] reslength the length of resptr
310 @param[in] require_string
311 If true, give error messages if binary string. If we
312 see a conversion error (space), we give error
313 notwithstanding this parameter value
314
315 @returns True if the string could not be converted. False on success.
316*/
317bool ensure_utf8mb4(const String &val, String *buf, const char **resptr,
318 size_t *reslength, bool require_string);
319
320/**
321 Represents the JSON function JSON_VALID( <value> )
322*/
325
326 public:
327 Item_func_json_valid(const POS &pos, Item *a) : Item_int_func(pos, a) {}
328
329 const char *func_name() const override { return "json_valid"; }
330 enum Functype functype() const override { return JSON_VALID_FUNC; }
331
332 bool is_bool_func() const override { return true; }
333
334 longlong val_int() override;
335
336 bool resolve_type(THD *thd) override {
337 if (reject_vector_args()) return true;
338 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
339 set_nullable(true);
340 return false;
341 }
342};
343
344/**
345 Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
346*/
348 public:
349 Item_func_json_schema_valid(const POS &pos, Item *a, Item *b);
351
352 const char *func_name() const override { return "json_schema_valid"; }
353 enum Functype functype() const override { return JSON_SCHEMA_VALID_FUNC; }
354
355 bool val_bool() override;
356
357 longlong val_int() override { return val_bool() ? 1 : 0; }
358
359 bool fix_fields(THD *, Item **) override;
360
361 void cleanup() override;
362
363 private:
365};
366
367/**
368 Represents the JSON function
369 JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> )
370*/
372 public:
374 PT_item_list *a);
376
377 const char *func_name() const override {
378 return "json_schema_validation_report";
379 }
380
381 enum Functype functype() const override {
383 }
384
385 bool val_json(Json_wrapper *wr) override;
386
387 bool resolve_type(THD *thd) override {
388 if (reject_vector_args()) return true;
389 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
390 set_nullable(true);
391 return false;
392 }
393
394 bool fix_fields(THD *, Item **) override;
395
396 void cleanup() override;
397
398 private:
400};
401
402/**
403 Represents the JSON function JSON_CONTAINS()
404*/
408
409 public:
411 : Item_int_func(pos, a), m_path_cache(thd, arg_count) {}
412
413 const char *func_name() const override { return "json_contains"; }
414 enum Functype functype() const override { return JSON_CONTAINS; }
415 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
416 bool gc_subst_analyzer(uchar **) override { return true; }
417
418 bool is_bool_func() const override { return true; }
419
420 longlong val_int() override;
421
422 bool resolve_type(THD *thd) override {
423 if (reject_vector_args()) return true;
424 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
425 if (param_type_is_default(thd, 1, 3)) return true;
426 set_nullable(true);
427 return false;
428 }
429
430 /** Cleanup between executions of the statement */
431 void cleanup() override;
432
434 return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
435 }
436};
437
438/**
439 Represents the JSON function JSON_CONTAINS_PATH()
440*/
444
445 // Cache for constant path expressions
447
448 public:
450 : Item_int_func(pos, a),
452 m_path_cache(thd, arg_count) {}
453
454 const char *func_name() const override { return "json_contains_path"; }
455 enum Functype functype() const override { return JSON_CONTAINS_PATH_FUNC; }
456
457 bool is_bool_func() const override { return true; }
458
459 longlong val_int() override;
460
461 bool resolve_type(THD *thd) override {
462 if (reject_vector_args()) return true;
463 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
464 if (param_type_is_default(thd, 1, -1)) return true;
465 set_nullable(true);
466 return false;
467 }
468
469 /** Cleanup between executions of the statement */
470 void cleanup() override;
471
473 return (arg == args[0]) ? CACHE_JSON_VALUE : CACHE_NONE;
474 }
475};
476
477/**
478 Represents the JSON function JSON_TYPE
479*/
482
483 public:
484 Item_func_json_type(const POS &pos, Item *a) : Item_str_func(pos, a) {}
485
486 const char *func_name() const override { return "json_type"; }
487 enum Functype functype() const override { return JSON_TYPE_FUNC; }
488
489 bool resolve_type(THD *) override;
490
491 String *val_str(String *) override;
492};
493
494/**
495 Represents a "CAST( <value> AS JSON )" coercion.
496*/
497class Item_typecast_json final : public Item_json_func {
499
500 public:
501 Item_typecast_json(THD *thd, const POS &pos, Item *a)
502 : Item_json_func(thd, pos, a) {}
503
504 bool resolve_type(THD *thd) override {
505 if (reject_vector_args()) return true;
506 if (Item_json_func::resolve_type(thd)) return true;
507 return args[0]->propagate_type(thd, MYSQL_TYPE_JSON, false, true);
508 }
509
510 void print(const THD *thd, String *str,
511 enum_query_type query_type) const override;
512 const char *func_name() const override { return "cast_as_json"; }
513 const char *cast_type() const { return "json"; }
514 bool val_json(Json_wrapper *wr) override;
515};
516
517/**
518 Represents the JSON function JSON_LENGTH()
519*/
522
523 public:
524 Item_func_json_length(const POS &pos, Item *doc) : Item_int_func(pos, doc) {}
525
526 bool resolve_type(THD *thd) override {
527 if (reject_vector_args()) return true;
528 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
529 if (param_type_is_default(thd, 1, 2)) return true;
530 set_nullable(true);
531 return false;
532 }
533
534 const char *func_name() const override { return "json_length"; }
535 enum Functype functype() const override { return JSON_LENGTH_FUNC; }
536
537 longlong val_int() override;
538};
539
540/**
541 Represents the JSON function JSON_DEPTH()
542*/
545
546 public:
547 Item_func_json_depth(const POS &pos, Item *a) : Item_int_func(pos, a) {}
548
549 const char *func_name() const override { return "json_depth"; }
550 enum Functype functype() const override { return JSON_DEPTH_FUNC; }
551
552 bool resolve_type(THD *thd) override {
553 if (reject_vector_args()) return true;
554 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
555 set_nullable(true);
556 return false;
557 }
558
559 longlong val_int() override;
560};
561
562/**
563 Represents the JSON function JSON_KEYS()
564*/
567
568 public:
569 Item_func_json_keys(THD *thd, const POS &pos, Item *a)
570 : Item_json_func(thd, pos, a) {}
571
572 Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
573 : Item_json_func(thd, pos, a, b) {}
574
575 const char *func_name() const override { return "json_keys"; }
576
577 bool resolve_type(THD *thd) override {
578 if (reject_vector_args()) return true;
579 if (Item_json_func::resolve_type(thd)) return true;
580 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
581 if (param_type_is_default(thd, 1, 2)) return true;
582 return false;
583 }
584
585 bool val_json(Json_wrapper *wr) override;
586};
587
588/**
589 Represents the JSON function JSON_EXTRACT()
590*/
593
594 public:
596 : Item_json_func(thd, pos, a) {}
597
598 Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
599 : Item_json_func(thd, pos, a, b) {}
600
601 const char *func_name() const override { return "json_extract"; }
602 enum Functype functype() const override { return JSON_EXTRACT_FUNC; }
603
604 bool resolve_type(THD *thd) override {
605 if (reject_vector_args()) return true;
606 if (Item_json_func::resolve_type(thd)) return true;
607 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
608 if (param_type_is_default(thd, 1, -1)) return true;
609 return false;
610 }
611
612 bool val_json(Json_wrapper *wr) override;
613
614 bool eq(const Item *item) const override;
615};
616
617/// Base class for all the functions that take a JSON document as the first
618/// argument and one of more pairs of a JSON path and a value to insert into the
619/// JSON document, and returns the modified JSON document.
621 protected:
622 template <typename... Args>
623 explicit Item_func_modify_json_in_path(Args &&...parent_args)
624 : Item_json_func(std::forward<Args>(parent_args)...) {
625 // The function does not necessarily return NULL when an argument is NULL.
626 // It returns NULL only if the first argument is NULL, or if one of the JSON
627 // path arguments is null. The set of tables for which the function is
628 // null-rejecting, is calculated in resolve_type() and possibly updated in
629 // update_used_tables().
630 null_on_null = false;
631 }
633
634 public:
635 bool resolve_type(THD *thd) final;
636 void update_used_tables() final;
637
638 private:
639 /// Calculates the set of tables to return from not_used_tables(). The
640 /// returned value is cached by resolve_type() and update_used_tables().
642};
643
644/**
645 Represents the JSON function JSON_ARRAY_APPEND()
646*/
648 public:
650 : Item_func_modify_json_in_path(thd, pos, a) {}
651
652 const char *func_name() const override { return "json_array_append"; }
653
654 bool val_json(Json_wrapper *wr) override;
655};
656
657/**
658 Represents the JSON function JSON_INSERT()
659*/
661 public:
663 : Item_func_modify_json_in_path(thd, pos, a) {}
664
665 const char *func_name() const override { return "json_insert"; }
666
667 bool val_json(Json_wrapper *wr) override;
668};
669
670/**
671 Represents the JSON function JSON_ARRAY_INSERT()
672*/
674 public:
676 : Item_func_modify_json_in_path(thd, pos, a) {}
677
678 const char *func_name() const override { return "json_array_insert"; }
679
680 bool val_json(Json_wrapper *wr) override;
681};
682
683/**
684 Common base class for JSON_SET() and JSON_REPLACE().
685*/
687 /// True if this is JSON_SET, false if it is JSON_REPLACE.
688 const bool m_json_set;
690 bool can_use_in_partial_update() const override { return true; }
691
692 protected:
693 template <typename... Args>
694 explicit Item_func_json_set_replace(bool json_set, Args &&...parent_args)
695 : Item_func_modify_json_in_path(std::forward<Args>(parent_args)...),
696 m_json_set(json_set),
697 m_path(key_memory_JSON) {}
698
699 public:
700 bool val_json(Json_wrapper *wr) override;
701};
702
703/**
704 Represents the JSON function JSON_SET()
705*/
707 public:
708 template <typename... Args>
709 explicit Item_func_json_set(Args &&...parent_args)
710 : Item_func_json_set_replace(true, std::forward<Args>(parent_args)...) {}
711
712 const char *func_name() const override { return "json_set"; }
713};
714
715/**
716 Represents the JSON function JSON_REPLACE()
717*/
719 public:
720 template <typename... Args>
721 explicit Item_func_json_replace(Args &&...parent_args)
722 : Item_func_json_set_replace(false, std::forward<Args>(parent_args)...) {}
723
724 const char *func_name() const override { return "json_replace"; }
725};
726
727/**
728 Represents the JSON function JSON_ARRAY()
729*/
731 public:
732 template <typename... Args>
733 explicit Item_func_json_array(Args &&...parent_args)
734 : Item_json_func(std::forward<Args>(parent_args)...) {
735 // Does not return NULL on NULL input. A NULL argument is interpreted as the
736 // JSON null literal.
737 null_on_null = false;
738 }
739
740 const char *func_name() const override { return "json_array"; }
741 enum Functype functype() const override { return JSON_ARRAY_FUNC; }
742
743 bool resolve_type(THD *thd) override {
744 if (Item_json_func::resolve_type(thd)) return true;
745 if (param_type_is_default(thd, 0, -1)) return true;
746 return false;
747 }
748
749 bool val_json(Json_wrapper *wr) override;
750};
751
752/**
753 Represents the JSON function JSON_OBJECT()
754*/
757
758 public:
760 : Item_json_func(thd, pos, a) {
761 // Does not return NULL on NULL input. If a key argument is NULL, an error
762 // is raised. If a value argument is NULL, it is interpreted as the JSON
763 // null literal.
764 null_on_null = false;
765 }
766
768 : Item_json_func(thd, list) {
769 // Does not return NULL on NULL input. If a key argument is NULL, an error
770 // is raised. If a value argument is NULL, it is interpreted as the JSON
771 // null literal.
772 null_on_null = false;
773 }
774
775 const char *func_name() const override { return "json_object"; }
776 enum Functype functype() const override { return JSON_OBJECT_FUNC; }
777
778 bool resolve_type(THD *thd) override {
779 if (Item_json_func::resolve_type(thd)) return true;
780 if (param_type_is_default(thd, 0, -1)) return true;
781 return false;
782 }
783
784 bool val_json(Json_wrapper *wr) override;
785};
786
787/**
788 Implements JSON_DUALITY_OBJECT(). It exists separately from JSON_OBJECT() to
789 retain JDV tags and add ETAG metadata to the root object.
790*/
793
794 jdv::Duality_view_tags m_table_tags{0};
795 PT_jdv_name_value_list *m_jdv_name_value_list{nullptr};
796
797 /// True when this is the root JDV object that adds ETAG metadata.
798 bool m_inject_object_hash{false};
799
800 /// JDV table reference used to obtain the ETAG content tree.
801 Table_ref *m_jdv_table_ref{nullptr};
802
803 std::unordered_set<std::string> m_json_arrayagg_keys;
804
805 bool inject_etag_metadata(Json_wrapper *wr);
806
807 public:
808 Item_func_json_duality_object(THD *thd, const POS &pos, int table_tags,
809 PT_jdv_name_value_list *jdv_name_value_list);
810
811 const char *func_name() const override { return "json_duality_object"; }
812 enum Functype functype() const override { return JSON_DUALITY_OBJECT_FUNC; }
813
814 bool resolve_type(THD *thd) override;
815 bool val_json(Json_wrapper *wr) override;
816
817 void print(const THD *thd, String *str,
818 enum_query_type query_type) const override;
819
820 bool set_json_arrayagg_keys(THD *thd);
821
822 jdv::Duality_view_tags table_tags() const { return m_table_tags; }
823 Mem_root_array<LEX_STRING> *name_list();
824 Mem_root_array<uint> *col_tags_list() const;
825
826 std::unordered_set<std::string> get_json_arrayagg_keys() {
827 return m_json_arrayagg_keys;
828 }
829};
830
831/**
832 Represents the JSON function JSON_SEARCH()
833*/
837
838 // LIKE machinery
841
842 public:
843 /**
844 Construct a JSON_SEARCH() node.
845
846 @param parent_args arguments to pass to Item_json_func's constructor
847 */
848 template <typename... Args>
849 explicit Item_func_json_search(Args &&...parent_args)
850 : Item_json_func(std::forward<Args>(parent_args)...),
851 m_cached_ooa(ooa_uninitialized) {}
852
853 const char *func_name() const override { return "json_search"; }
854
855 enum Functype functype() const override { return JSON_SEARCH_FUNC; }
856
857 bool val_json(Json_wrapper *wr) override;
858
859 /**
860 Bind logic for the JSON_SEARCH() node.
861 */
862 bool fix_fields(THD *, Item **) override;
863
864 bool resolve_type(THD *thd) override {
865 if (Item_json_func::resolve_type(thd)) return true;
866 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
867 if (param_type_is_default(thd, 1, -1)) return true;
868 return false;
869 }
870
871 void cleanup() override;
872};
873
874/**
875 Represents the JSON function JSON_REMOVE()
876*/
879 bool can_use_in_partial_update() const override { return true; }
880
881 public:
882 template <typename... Args>
883 explicit Item_func_json_remove(Args &&...parent_args)
884 : Item_json_func(std::forward<Args>(parent_args)...) {}
885
886 const char *func_name() const override { return "json_remove"; }
887
888 bool resolve_type(THD *thd) override {
889 if (Item_json_func::resolve_type(thd)) return true;
890 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_JSON)) return true;
891 if (param_type_is_default(thd, 1, -1)) return true;
892 return false;
893 }
894
895 bool val_json(Json_wrapper *wr) override;
896};
897
898/**
899 Represents the JSON function JSON_MERGE_PRESERVE.
900*/
902 public:
904 : Item_json_func(thd, pos, a) {}
905
906 const char *func_name() const override { return "json_merge_preserve"; }
907
908 bool resolve_type(THD *thd) override {
909 if (Item_json_func::resolve_type(thd)) return true;
910 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
911 return false;
912 }
913
914 bool val_json(Json_wrapper *wr) override;
915};
916
917/**
918 Represents the JSON function JSON_MERGE. It is a deprecated alias
919 for JSON_MERGE_PRESERVE.
920*/
922 public:
923 Item_func_json_merge(THD *thd, const POS &pos, PT_item_list *a);
924
925 bool is_deprecated() const override { return true; }
926};
927
928/**
929 Represents the JSON function JSON_MERGE_PATCH.
930*/
932 public:
934 : Item_json_func(thd, pos, a) {}
935
936 const char *func_name() const override { return "json_merge_patch"; }
937
938 bool resolve_type(THD *thd) override {
939 if (Item_json_func::resolve_type(thd)) return true;
940 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
941 return false;
942 }
943
944 bool val_json(Json_wrapper *wr) override;
945};
946
947/**
948 Represents the JSON function JSON_QUOTE()
949*/
952
953 public:
955 : Item_str_func(pos, a) {}
956
957 const char *func_name() const override { return "json_quote"; }
958
959 enum Functype functype() const override { return JSON_QUOTE_FUNC; }
960
961 bool resolve_type(THD *thd) override {
962 if (reject_vector_args()) return true;
963 if (param_type_is_default(thd, 0, -1)) return true;
964 set_nullable(true);
965
966 /*
967 Any interior character could be replaced by a 6 character
968 escape sequence. Plus we will add 2 framing quote characters.
969 */
970 const uint32 max_char_length = (6 * args[0]->max_char_length()) + 2;
972 return false;
973 }
974
975 String *val_str(String *tmpspace) override;
976};
977
978/**
979 Represents the JSON function JSON_UNQUOTE()
980*/
984
985 public:
987 : Item_str_func(pos, a) {}
988
989 Item_func_json_unquote(const POS &pos, Item *a) : Item_str_func(pos, a) {}
990
991 const char *func_name() const override { return "json_unquote"; }
992
993 enum Functype functype() const override { return JSON_UNQUOTE_FUNC; }
994
995 bool resolve_type(THD *thd) override {
996 if (reject_vector_args()) return true;
997 if (param_type_is_default(thd, 0, -1)) return true;
998 set_nullable(true);
1000 return false;
1001 }
1002
1003 String *val_str(String *str) override;
1004};
1005
1006/**
1007 Represents the JSON_PRETTY function.
1008*/
1010 public:
1011 Item_func_json_pretty(const POS &pos, Item *a) : Item_str_func(pos, a) {}
1012
1013 const char *func_name() const override { return "json_pretty"; }
1014
1015 enum Functype functype() const override { return JSON_PRETTY_FUNC; }
1016
1017 bool resolve_type(THD *thd) override {
1018 if (reject_vector_args()) return true;
1019 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
1021 return false;
1022 }
1023
1024 String *val_str(String *str) override;
1025};
1026
1027/**
1028 Class that represents the function JSON_STORAGE_SIZE.
1029*/
1031 public:
1033 : Item_int_func(pos, a) {}
1034 const char *func_name() const override { return "json_storage_size"; }
1035 enum Functype functype() const override { return JSON_STORAGE_SIZE_FUNC; }
1036
1037 bool resolve_type(THD *thd) override {
1038 if (reject_vector_args()) return true;
1039 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
1040 if (Item_int_func::resolve_type(thd)) return true;
1041 set_nullable(true);
1042 return false;
1043 }
1044
1045 longlong val_int() override;
1046};
1047
1048/**
1049 Class that represents the function JSON_STORAGE_FREE.
1050*/
1052 public:
1054 : Item_int_func(pos, a) {}
1055 const char *func_name() const override { return "json_storage_free"; }
1056 enum Functype functype() const override { return JSON_STORAGE_FREE_FUNC; }
1057
1058 bool resolve_type(THD *thd) override {
1059 if (reject_vector_args()) return true;
1060 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_JSON)) return true;
1061 return false;
1062 }
1063
1064 longlong val_int() override;
1065};
1066
1067/**
1068 Class that represents CAST(<expr> AS <type> ARRAY)
1069*/
1070
1071class Item_func_array_cast final : public Item_func {
1072 /// Type to cast to
1074 /**
1075 Whether use of CAST(.. AS .. ARRAY) is allowed
1076
1077 Currently use of CAST(.. AS .. ARRAY) is limited only to CREATE
1078 TABLE/INDEX. In all other cases an error is thrown. This flag is set to
1079 true only for allowed cases to ensure allowed function usage.
1080 */
1081 bool m_is_allowed{false};
1082
1083 /**
1084 An array used by #save_in_field_inner() to store the result of an array cast
1085 operation. It is cached in the Item in order to avoid the need for
1086 reallocation on each row.
1087 */
1089
1090 protected:
1091 void add_json_info(Json_object *obj) override;
1092
1093 public:
1094 Item_func_array_cast(const POS &pos, Item *a, Cast_target type, uint len_arg,
1095 uint dec_arg, const CHARSET_INFO *cs_arg);
1097 const char *func_name() const override { return "cast_as_array"; }
1098 enum Functype functype() const override { return TYPECAST_FUNC; }
1099 bool returns_array() const override { return true; }
1100 bool val_json(Json_wrapper *wr) override;
1101 void print(const THD *thd, String *str,
1102 enum_query_type query_type) const override;
1103 enum Item_result result_type() const override;
1104 bool resolve_type(THD *) override;
1105 Field *tmp_table_field(TABLE *table) override;
1106 bool fix_fields(THD *thd, Item **ref) override;
1107 void cleanup() override;
1108 void allow_array_cast() override { m_is_allowed = true; }
1110 bool no_conversions) override;
1111 // Regular val_x() funcs shouldn't be called
1112 /* purecov: begin inspected */
1113 longlong val_int() override {
1114 assert(false);
1115 return 0;
1116 }
1117 String *val_str(String *) override {
1118 assert(false);
1119 return nullptr;
1120 }
1122 assert(false);
1123 return nullptr;
1124 }
1125 double val_real() override {
1126 assert(false);
1127 return 0;
1128 }
1130 assert(false);
1131 return true;
1132 }
1133 bool val_time(Time_val *) override {
1134 assert(false);
1135 return true;
1136 }
1138 assert(false);
1139 return true;
1140 }
1141 /* purecov: end */
1142};
1143
1145 public:
1147 : Item_bool_func(pos, a, b) {}
1148 const char *func_name() const override { return "json_overlaps"; }
1149 enum Functype functype() const override { return JSON_OVERLAPS; }
1150 bool gc_subst_analyzer(uchar **) override { return true; }
1151 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1152 longlong val_int() override;
1153 Item *key_item() const override;
1155 return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
1156 }
1157};
1158
1160 public:
1161 Item_func_member_of(const POS &pos, Item *a, Item *b)
1162 : Item_bool_func(pos, a, b) {}
1163 const char *func_name() const override { return "member of"; }
1164 enum Functype functype() const override { return MEMBER_OF_FUNC; }
1165 bool resolve_type(THD *thd) override {
1166 if (reject_vector_args()) return true;
1167 if (param_type_is_default(thd, 0, 2, MYSQL_TYPE_JSON)) return true;
1169 return false;
1170 }
1171 bool gc_subst_analyzer(uchar **) override { return true; }
1172 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1173 longlong val_int() override;
1174 void print(const THD *thd, String *str,
1175 enum_query_type query_type) const override;
1176 Item *key_item() const override { return args[1]; }
1178 return (arg == args[1]) ? CACHE_JSON_VALUE
1179 : ((arg == args[0]) ? CACHE_JSON_ATOM : CACHE_NONE);
1180 }
1181};
1182
1183/**
1184 Class implementing the JSON_VALUE function.
1185
1186 Functionality-wise it's a combination of CAST, JSON_UNQUOTE and JSON_EXTRACT,
1187 but with additional functionality for flexible handling of empty values and
1188 conversion errors.
1189*/
1190class Item_func_json_value final : public Item_func {
1191 public:
1192 Item_func_json_value(const POS &pos, Item *arg, Item *path,
1193 const Cast_type &cast_type, unsigned length,
1194 unsigned precision, Json_on_response_type on_empty_type,
1195 Item *on_empty_default,
1196 Json_on_response_type on_error_type,
1197 Item *on_error_default);
1199 const char *func_name() const override { return "json_value"; }
1200 enum Functype functype() const override { return JSON_VALUE_FUNC; }
1201 enum Item_result result_type() const override;
1202 bool resolve_type(THD *) override;
1203 bool fix_fields(THD *thd, Item **ref) override;
1204 void print(const THD *thd, String *str,
1205 enum_query_type query_type) const override;
1206 bool eq_specific(const Item *item) const override;
1207 bool val_json(Json_wrapper *wr) override;
1208 String *val_str(String *buffer) override;
1209 double val_real() override;
1210 longlong val_int() override;
1212 bool val_date(Date_val *date, my_time_flags_t flags) override;
1213 bool val_time(Time_val *time) override;
1214 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1215 Json_on_response_type on_empty_response_type() const;
1216 Json_on_response_type on_error_response_type() const;
1217
1218 private:
1219 /// Represents a default value given in JSON_VALUE's DEFAULT xxx ON EMPTY or
1220 /// DEFAULT xxx ON ERROR clause.
1221 struct Default_value;
1222
1223 /// Parsed path.
1225 /// Type of the ON EMPTY clause.
1227 /// Type of the ON ERROR clause.
1229 /// The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
1231 /// The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
1233 /// The target data type.
1235
1236 /**
1237 Creates a Json_value_default object representing the default value given in
1238 a DEFAULT xxx ON EMPTY clause or a DEFAULT xxx ON ERROR clause.
1239
1240 @param thd the current session
1241 @param item the Item that represents the default value expression
1242 @return a pointer to the created object on success, nullptr on error
1243 */
1244 unique_ptr_destroy_only<Default_value> create_json_value_default(THD *thd,
1245 Item *item);
1246
1247 /**
1248 Extracts the JSON value at the given path.
1249
1250 @param[out] json the extracted JSON value, if the path matched exactly
1251 one value; empty otherwise
1252 @param[out] return_default the default value to return if a
1253 DEFAULT ... ON EMPTY or DEFAULT ... ON ERROR clause was invoked,
1254 or nullptr if no DEFAULT clause was invoked
1255 @return true if an error was raised, false otherwise
1256 */
1257 bool extract_json_value(Json_wrapper *json,
1258 const Default_value **return_default);
1259
1260 /// Implements val_int() for RETURNING SIGNED and RETURNING UNSIGNED.
1261 int64_t extract_integer_value();
1262 /// Implements val_int() for RETURNING YEAR
1263 int64_t extract_year_value();
1264 /// Implements val_date() for RETURNING DATE.
1265 bool extract_date_value(Date_val *date);
1266 /// Implements val_time() for RETURNING TIME.
1267 bool extract_time_value(Time_val *time);
1268 /// Implements val_datetime() for RETURNING DATETIME.
1269 bool extract_datetime_value(Datetime_val *dt);
1270 /// Implements val_decimal() for RETURNING DECIMAL.
1271 my_decimal *extract_decimal_value(my_decimal *value);
1272 /// Implements val_str() for RETURNING CHAR and RETURNING BINARY.
1273 String *extract_string_value(String *buffer);
1274 /// Implements val_real() for RETURNING FLOAT/REAL/DOUBLE.
1275 double extract_real_value();
1276};
1277
1278/**
1279 Turn a GEOMETRY value into a JSON value per the GeoJSON specification
1280 revision 1.0. This method is implemented in item_geofunc.cc.
1281
1282 @param[in,out] wr The wrapper to be stuffed with the JSON value.
1283 @param[in] swkb The source GEOMETRY value.
1284 @param[in] calling_function Name of user-invoked function (for errors)
1285 @param[in] max_decimal_digits See the user documentation for ST_AsGeoJSON.
1286 @param[in] add_bounding_box See the user documentation for ST_AsGeoJSON.
1287 @param[in] add_short_crs_urn See the user documentation for ST_AsGeoJSON.
1288 @param[in] add_long_crs_urn See the user documentation for ST_AsGeoJSON.
1289 @param[in,out] geometry_srid Spatial Reference System Identifier to be filled
1290 in.
1291
1292 @return false if the conversion succeeds, true otherwise
1293*/
1294bool geometry_to_json(Json_wrapper *wr, String *swkb,
1295 const char *calling_function, int max_decimal_digits,
1296 bool add_bounding_box, bool add_short_crs_urn,
1297 bool add_long_crs_urn, uint32 *geometry_srid);
1298
1299/**
1300 Convert a value represented with an Item to a JSON value
1301
1302 @param[in] item the input value, may be any data type
1303 @param[in] func_name for error reporting
1304 @param[in,out] wr the result wrapper for the JSON value
1305
1306 @return false if success, true if error
1307*/
1308bool convert_value_to_json(Item *item, const char *func_name, Json_wrapper *wr);
1309/**
1310 Convert JSON values or MySQL values to JSON. Converts SQL NULL
1311 to the JSON null literal.
1312
1313 @param[in] args arguments to function
1314 @param[in] arg_idx the index of the argument to process
1315 @param[in] calling_function name of the calling function
1316 @param[in,out] value working area (if the returned Json_wrapper points
1317 to a binary value rather than a DOM, this string
1318 will end up holding the binary representation, and
1319 it must stay alive until the wrapper is destroyed
1320 or converted from binary to DOM)
1321 @param[in,out] tmp temporary scratch space for converting strings to
1322 the correct charset; only used if accept_string is
1323 true and conversion is needed
1324 @param[in,out] wr the result wrapper
1325 @returns false if we found a value or NULL, true otherwise
1326*/
1327bool get_atom_null_as_null(Item **args, uint arg_idx,
1328 const char *calling_function, String *value,
1329 String *tmp, Json_wrapper *wr);
1330
1331/**
1332 Gets a JSON object member name from an Item. An error is raised if
1333 the Item evaluates to NULL, or if it cannot be converted to a
1334 utf8mb4 string.
1335
1336 @param[in] thd THD handle
1337 @param[in] arg_item An argument Item
1338 @param[out] value Where to materialize the arg_item's string value
1339 @param[out] utf8_res Buffer for use by ensure_utf8mb4.
1340 @param[out] safep String pointer after any relevant conversion
1341 @param[out] safe_length Corresponding string length
1342
1343 @returns true if the Item is not a utf8mb4 string
1344*/
1345bool get_json_object_member_name(const THD *thd, Item *arg_item, String *value,
1346 String *utf8_res, const char **safep,
1347 size_t *safe_length);
1348using Json_dom_ptr = std::unique_ptr<Json_dom>;
1349
1350bool parse_json(const String &res, Json_dom_ptr *dom, bool require_str_or_json,
1351 const JsonParseErrorHandler &error_handler,
1352 const JsonErrorHandler &depth_handler);
1353
1354/**
1355 Apply a sequence of JSON diffs to the value stored in a JSON column.
1356
1357 @param field the column to update
1358 @param diffs the diffs to apply
1359 @return an enum_json_diff_status value that tells if the diffs were
1360 applied successfully
1361 */
1363 const Json_diff_vector *diffs);
1364
1365bool save_json_to_field(THD *thd, Field *field, const Json_wrapper *w,
1366 bool no_error);
1367#endif /* ITEM_JSON_FUNC_INCLUDED */
Date_val is a temporal type that represents dates within the range 0000-01-01 and 9999-12-31.
Definition: my_temporal.h:421
Definition: my_temporal.h:341
A field that stores a JSON value.
Definition: field.h:3922
Definition: field.h:573
Definition: item_cmpfunc.h:305
Class that represents CAST(<expr> AS <type> ARRAY)
Definition: item_json_func.h:1071
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:1088
bool val_time(Time_val *) override
Evaluate the item and return result as a time value.
Definition: item_json_func.h:1133
void allow_array_cast() override
A helper function to ensure proper usage of CAST(.
Definition: item_json_func.h:1108
const char * func_name() const override
Definition: item_json_func.h:1097
longlong val_int() override
Definition: item_json_func.h:1113
bool returns_array() const override
Whether the item returns array of its data type.
Definition: item_json_func.h:1099
my_decimal * val_decimal(my_decimal *) override
Definition: item_json_func.h:1121
enum Functype functype() const override
Definition: item_json_func.h:1098
double val_real() override
Definition: item_json_func.h:1125
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item_json_func.h:1129
~Item_func_array_cast() override
Cast_target cast_type
Type to cast to.
Definition: item_json_func.h:1073
bool val_datetime(Datetime_val *, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item_json_func.h:1137
String * val_str(String *) override
Definition: item_json_func.h:1117
Represents the JSON function JSON_ARRAY_APPEND()
Definition: item_json_func.h:647
Item_func_json_array_append(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:649
const char * func_name() const override
Definition: item_json_func.h:652
Represents the JSON function JSON_ARRAY_INSERT()
Definition: item_json_func.h:673
Item_func_json_array_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:675
const char * func_name() const override
Definition: item_json_func.h:678
Represents the JSON function JSON_ARRAY()
Definition: item_json_func.h:730
enum Functype functype() const override
Definition: item_json_func.h:741
Item_func_json_array(Args &&...parent_args)
Definition: item_json_func.h:733
const char * func_name() const override
Definition: item_json_func.h:740
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:743
Represents the JSON function JSON_CONTAINS_PATH()
Definition: item_json_func.h:441
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:457
longlong val_int() override
Definition: item_json_func.cc:918
Json_path_cache m_path_cache
Definition: item_json_func.h:446
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:461
enum Functype functype() const override
Definition: item_json_func.h:455
String m_doc_value
Definition: item_json_func.h:442
Item_func_json_contains_path(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:449
const char * func_name() const override
Definition: item_json_func.h:454
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:472
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:443
Represents the JSON function JSON_CONTAINS()
Definition: item_json_func.h:405
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:416
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:415
Item_func_json_contains(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:410
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:422
longlong val_int() override
Definition: item_json_func.cc:853
String m_doc_value
Definition: item_json_func.h:406
enum Functype functype() const override
Definition: item_json_func.h:414
Json_path_cache m_path_cache
Definition: item_json_func.h:407
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:433
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:413
bool is_bool_func() const override
Definition: item_json_func.h:418
Represents the JSON function JSON_DEPTH()
Definition: item_json_func.h:543
enum Functype functype() const override
Definition: item_json_func.h:550
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:552
longlong val_int() override
Definition: item_json_func.cc:1584
String m_doc_value
Definition: item_json_func.h:544
const char * func_name() const override
Definition: item_json_func.h:549
Item_func_json_depth(const POS &pos, Item *a)
Definition: item_json_func.h:547
Implements JSON_DUALITY_OBJECT().
Definition: item_json_func.h:791
jdv::Duality_view_tags table_tags() const
Definition: item_json_func.h:822
enum Functype functype() const override
Definition: item_json_func.h:812
std::unordered_set< std::string > get_json_arrayagg_keys()
Definition: item_json_func.h:826
Item_func_json_row_object super
Definition: item_json_func.h:792
const char * func_name() const override
Definition: item_json_func.h:811
std::unordered_set< std::string > m_json_arrayagg_keys
Definition: item_json_func.h:803
Represents the JSON function JSON_EXTRACT()
Definition: item_json_func.h:591
const char * func_name() const override
Definition: item_json_func.h:601
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item_json_func.cc:1731
enum Functype functype() const override
Definition: item_json_func.h:602
Item_func_json_extract(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:595
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:604
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1664
Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:598
String m_doc_value
Definition: item_json_func.h:592
Represents the JSON function JSON_INSERT()
Definition: item_json_func.h:660
Item_func_json_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:662
const char * func_name() const override
Definition: item_json_func.h:665
Represents the JSON function JSON_KEYS()
Definition: item_json_func.h:565
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1605
String m_doc_value
Definition: item_json_func.h:566
Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:572
Item_func_json_keys(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:569
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:577
const char * func_name() const override
Definition: item_json_func.h:575
Represents the JSON function JSON_LENGTH()
Definition: item_json_func.h:520
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:526
Item_func_json_length(const POS &pos, Item *doc)
Definition: item_json_func.h:524
longlong val_int() override
Definition: item_json_func.cc:1560
String m_doc_value
Definition: item_json_func.h:521
enum Functype functype() const override
Definition: item_json_func.h:535
const char * func_name() const override
Definition: item_json_func.h:534
Represents the JSON function JSON_MERGE_PATCH.
Definition: item_json_func.h:931
Item_func_json_merge_patch(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:933
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:938
const char * func_name() const override
Definition: item_json_func.h:936
Represents the JSON function JSON_MERGE_PRESERVE.
Definition: item_json_func.h:901
const char * func_name() const override
Definition: item_json_func.h:906
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:908
Item_func_json_merge_preserve(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:903
Represents the JSON function JSON_MERGE.
Definition: item_json_func.h:921
bool is_deprecated() const override
Definition: item_json_func.h:925
Definition: item_json_func.h:1144
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:1150
enum Functype functype() const override
Definition: item_json_func.h:1149
const char * func_name() const override
Definition: item_json_func.h:1148
Item_func_json_overlaps(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:1146
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:1151
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:1154
Represents the JSON_PRETTY function.
Definition: item_json_func.h:1009
const char * func_name() const override
Definition: item_json_func.h:1013
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:1017
enum Functype functype() const override
Definition: item_json_func.h:1015
Item_func_json_pretty(const POS &pos, Item *a)
Definition: item_json_func.h:1011
Represents the JSON function JSON_QUOTE()
Definition: item_json_func.h:950
enum Functype functype() const override
Definition: item_json_func.h:959
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:961
String m_value
Definition: item_json_func.h:951
Item_func_json_quote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:954
const char * func_name() const override
Definition: item_json_func.h:957
Represents the JSON function JSON_REMOVE()
Definition: item_json_func.h:877
Item_func_json_remove(Args &&...parent_args)
Definition: item_json_func.h:883
const char * func_name() const override
Definition: item_json_func.h:886
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:879
String m_doc_value
Definition: item_json_func.h:878
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:888
Represents the JSON function JSON_REPLACE()
Definition: item_json_func.h:718
Item_func_json_replace(Args &&...parent_args)
Definition: item_json_func.h:721
const char * func_name() const override
Definition: item_json_func.h:724
Represents the JSON function JSON_OBJECT()
Definition: item_json_func.h:755
String tmp_key_value
Definition: item_json_func.h:756
Item_func_json_row_object(THD *thd, mem_root_deque< Item * > *list)
Definition: item_json_func.h:767
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:778
enum Functype functype() const override
Definition: item_json_func.h:776
Item_func_json_row_object(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:759
const char * func_name() const override
Definition: item_json_func.h:775
Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
Definition: item_json_func.h:347
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:357
Json_schema_validator m_cached_schema_validator
Definition: item_json_func.h:364
enum Functype functype() const override
Definition: item_json_func.h:353
const char * func_name() const override
Definition: item_json_func.h:352
~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:371
const char * func_name() const override
Definition: item_json_func.h:377
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:387
Json_schema_validator m_cached_schema_validator
Definition: item_json_func.h:399
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:381
Represents the JSON function JSON_SEARCH()
Definition: item_json_func.h:834
String m_doc_value
Definition: item_json_func.h:835
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:864
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:836
Item_func_like * m_like_node
Definition: item_json_func.h:840
Item_func_json_search(Args &&...parent_args)
Construct a JSON_SEARCH() node.
Definition: item_json_func.h:849
enum Functype functype() const override
Definition: item_json_func.h:855
const char * func_name() const override
Definition: item_json_func.h:853
Item_string * m_source_string_item
Definition: item_json_func.h:839
Common base class for JSON_SET() and JSON_REPLACE().
Definition: item_json_func.h:686
Item_func_json_set_replace(bool json_set, Args &&...parent_args)
Definition: item_json_func.h:694
const bool m_json_set
True if this is JSON_SET, false if it is JSON_REPLACE.
Definition: item_json_func.h:688
Json_path_clone m_path
Definition: item_json_func.h:689
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:690
Represents the JSON function JSON_SET()
Definition: item_json_func.h:706
Item_func_json_set(Args &&...parent_args)
Definition: item_json_func.h:709
const char * func_name() const override
Definition: item_json_func.h:712
Class that represents the function JSON_STORAGE_FREE.
Definition: item_json_func.h:1051
enum Functype functype() const override
Definition: item_json_func.h:1056
Item_func_json_storage_free(const POS &pos, Item *a)
Definition: item_json_func.h:1053
const char * func_name() const override
Definition: item_json_func.h:1055
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:1058
Class that represents the function JSON_STORAGE_SIZE.
Definition: item_json_func.h:1030
Item_func_json_storage_size(const POS &pos, Item *a)
Definition: item_json_func.h:1032
const char * func_name() const override
Definition: item_json_func.h:1034
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:1037
enum Functype functype() const override
Definition: item_json_func.h:1035
Represents the JSON function JSON_TYPE.
Definition: item_json_func.h:480
const char * func_name() const override
Definition: item_json_func.h:486
String * val_str(String *) override
Definition: item_json_func.cc:1056
String m_value
Definition: item_json_func.h:481
Item_func_json_type(const POS &pos, Item *a)
Definition: item_json_func.h:484
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:487
Represents the JSON function JSON_UNQUOTE()
Definition: item_json_func.h:981
String m_value
Definition: item_json_func.h:982
const char * func_name() const override
Definition: item_json_func.h:991
Item_func_json_unquote(const POS &pos, Item *a)
Definition: item_json_func.h:989
Item_func_json_unquote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:986
enum Functype functype() const override
Definition: item_json_func.h:993
String m_conversion_buffer
Definition: item_json_func.h:983
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:995
Represents the JSON function JSON_VALID( <value> )
Definition: item_json_func.h:323
const char * func_name() const override
Definition: item_json_func.h:329
Item_func_json_valid(const POS &pos, Item *a)
Definition: item_json_func.h:327
longlong val_int() override
Definition: item_json_func.cc:629
enum Functype functype() const override
Definition: item_json_func.h:330
bool is_bool_func() const override
Definition: item_json_func.h:332
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:336
String m_value
Definition: item_json_func.h:324
Class implementing the JSON_VALUE function.
Definition: item_json_func.h:1190
enum Functype functype() const override
Definition: item_json_func.h:1200
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:1232
~Item_func_json_value() override
Json_on_response_type m_on_error
Type of the ON ERROR clause.
Definition: item_json_func.h:1228
Cast_target m_cast_target
The target data type.
Definition: item_json_func.h:1234
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:1230
const char * func_name() const override
Definition: item_json_func.h:1199
Json_on_response_type m_on_empty
Type of the ON EMPTY clause.
Definition: item_json_func.h:1226
Json_path m_path_json
Parsed path.
Definition: item_json_func.h:1221
Definition: item_cmpfunc.h:2503
Definition: item_json_func.h:1159
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:1177
Item_func_member_of(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:1161
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:1165
enum Functype functype() const override
Definition: item_json_func.h:1164
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:1171
Item * key_item() const override
Definition: item_json_func.h:1176
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:1172
const char * func_name() const override
Definition: item_json_func.h:1163
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:620
void update_used_tables() final
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_json_func.cc:1778
String m_doc_value
Definition: item_json_func.h:632
Item_func_modify_json_in_path(Args &&...parent_args)
Definition: item_json_func.h:623
table_map calculate_not_null_tables() const
Calculates the set of tables to return from not_used_tables().
Definition: item_json_func.cc:1783
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:1765
Definition: item_func.h:101
Item ** args
Array of pointers to arguments.
Definition: item_func.h:108
bool reject_vector_args()
Definition: item_func.cc:1636
Functype
Definition: item_func.h:214
@ JSON_VALUE_FUNC
Definition: item_func.h:360
@ JSON_SCHEMA_VALIDATION_REPORT_FUNC
Definition: item_func.h:362
@ JSON_STORAGE_SIZE_FUNC
Definition: item_func.h:358
@ JSON_SEARCH_FUNC
Definition: item_func.h:361
@ JSON_STORAGE_FREE_FUNC
Definition: item_func.h:359
@ JSON_CONTAINS
Definition: item_func.h:333
@ JSON_VALID_FUNC
Definition: item_func.h:353
@ JSON_UNQUOTE_FUNC
Definition: item_func.h:335
@ JSON_CONTAINS_PATH_FUNC
Definition: item_func.h:357
@ JSON_ARRAY_FUNC
Definition: item_func.h:352
@ JSON_SCHEMA_VALID_FUNC
Definition: item_func.h:363
@ JSON_DEPTH_FUNC
Definition: item_func.h:348
@ JSON_QUOTE_FUNC
Definition: item_func.h:356
@ JSON_OBJECT_FUNC
Definition: item_func.h:350
@ JSON_TYPE_FUNC
Definition: item_func.h:354
@ JSON_PRETTY_FUNC
Definition: item_func.h:355
@ JSON_EXTRACT_FUNC
Definition: item_func.h:349
@ MEMBER_OF_FUNC
Definition: item_func.h:336
@ TYPECAST_FUNC
Definition: item_func.h:263
@ JSON_OVERLAPS
Definition: item_func.h:334
@ JSON_DUALITY_OBJECT_FUNC
Definition: item_func.h:351
@ JSON_LENGTH_FUNC
Definition: item_func.h:347
virtual bool eq_specific(const Item *) const
Provide a more specific equality check for a function.
Definition: item_func.h:544
optimize_type
Definition: item_func.h:368
@ OPTIMIZE_KEY
Definition: item_func.h:370
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:728
virtual const char * func_name() const =0
enum Type type() const override
Definition: item_func.h:375
virtual Item * key_item() const
Definition: item_func.h:547
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:530
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:765
bool fix_fields(THD *, Item **ref) override
Definition: item_func.cc:408
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:131
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_func.cc:829
bool null_on_null
Affects how to determine that NULL argument implies a NULL function return.
Definition: item_func.h:187
Definition: item_func.h:1048
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:2114
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:1147
Item_result cast_to_int_type() const override
Definition: item_json_func.h:211
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 val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_json_func.cc:1120
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
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:1169
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_json_func.cc:1136
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:2131
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
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_json_func.cc:1124
double val_real() override
Definition: item_json_func.cc:1156
void cleanup() override
JSON_*() support methods.
Definition: item_json_func.cc:623
Definition: item_strfunc.h:79
Definition: item.h:5657
Represents a "CAST( <value> AS JSON )" coercion.
Definition: item_json_func.h:497
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1504
const char * cast_type() const
Definition: item_json_func.h:513
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:1551
Item_json_func super
Definition: item_json_func.h:498
const char * func_name() const override
Definition: item_json_func.h:512
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:504
Item_typecast_json(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:501
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:935
uint32 max_char_length() const
Definition: item.h:3473
void set_nullable(bool nullable)
Definition: item.h:3792
virtual bool propagate_type(THD *thd, const Type_properties &type)
Propagate data type specifications into parameters and user variables.
Definition: item.h:1320
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:7277
virtual bool val_json(Json_wrapper *result)
Get a JSON value from an Item.
Definition: item.h:2131
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:1004
@ CACHE_NONE
Don't cache.
Definition: item.h:1006
@ CACHE_JSON_VALUE
Source data is a JSON string, parse and cache result.
Definition: item.h:1008
@ CACHE_JSON_ATOM
Source data is SQL scalar, convert and cache result.
Definition: item.h:1010
void set_data_type_json()
Set the data type of the Item to be JSON.
Definition: item.h:1770
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1606
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:1361
Represents a JSON array container, i.e.
Definition: json_dom.h:520
Vector of logical diffs describing changes to a JSON column.
Definition: json_diff.h:141
JSON DOM abstract base class.
Definition: json_dom.h:179
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:374
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:2035
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:1268
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:109
Definition: parse_tree_nodes.h:5945
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
Definition: table.h:2958
Time_val is a temporal type that represents only time.
Definition: my_temporal.h:57
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:172
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:97
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:81
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:164
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:2346
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:88
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:4420
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:1433
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:139
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:1224
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:1490
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 int_to_datetime.
Definition: my_time.h:87
Common definition between mysql server & client.
#define MAX_BLOB_WIDTH
Default width for blob in bytes.
Definition: mysql_com.h:913
static char * path
Definition: mysqldump.cc:153
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
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
Define std::hash<Gtid>.
Definition: gtid.h:355
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2728
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:200
Our own string classes, used pervasively throughout the executor.
Definition: m_ctype.h:421
Definition: parser_yystype.h:191
Definition: item_json_func.cc:4562
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
Bison "location" class.
Definition: parse_location.h:43
Definition: table.h:1456
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