MySQL  8.0.19
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, 2019, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 #include <stddef.h>
27 #include <sys/types.h>
28 #include <memory>
29 #include <utility> // std::forward
30 
31 #include "m_ctype.h"
32 #include "my_alloc.h"
33 #include "my_dbug.h"
34 #include "my_inttypes.h"
35 #include "my_time.h"
37 #include "mysql_com.h"
38 #include "mysql_time.h"
39 #include "prealloced_array.h" // Prealloced_array
40 #include "sql/enum_query_type.h"
41 #include "sql/field.h"
42 #include "sql/item.h"
43 #include "sql/item_cmpfunc.h"
44 #include "sql/item_func.h"
45 #include "sql/item_strfunc.h" // Item_str_func
46 #include "sql/json_path.h" // Json_path
47 #include "sql/mem_root_array.h" // Mem_root_array
49 #include "sql_string.h"
50 
52 class Json_array;
53 class Json_dom;
54 class Json_scalar_holder;
55 class Json_wrapper;
56 class PT_item_list;
57 class THD;
58 class my_decimal;
59 struct TABLE;
60 
61 /** For use by JSON_CONTAINS_PATH() and JSON_SEARCH() */
68 };
69 
70 /**
71  Path cache for JSON functions. Caches parsed path
72  objects for arguments which are string literals.
73  Maintains a vector of path objects and an array of
74  ints which map path argument numbers to slots in
75  the array.
76 */
78  private:
79  /// Holder for path strings.
81 
82  /// List of paths.
84 
85  /// Enum that tells the status of a cell in m_paths.
86  enum class enum_path_status : uint8 {
89  OK_NULL,
90  ERROR
91  };
92 
93  /// Struct that points to a cell in m_paths and tells its status.
94  struct Path_cell {
96  size_t m_index = 0;
97  };
98 
99  /// Map argument indexes to indexes into m_paths.
101 
102  public:
103  Json_path_cache(THD *thd, uint size);
105 
106  /**
107  Parse a path expression if necessary. Does nothing if the path
108  expression is constant and it has already been parsed. Assumes that
109  we've already verified that the path expression is not null. Raises an
110  error if the path expression is syntactically incorrect. Raises an
111  error if the path expression contains wildcard tokens but is not
112  supposed to. Otherwise puts the parsed path onto the
113  path vector.
114 
115  @param[in] args Array of args to a JSON function
116  @param[in] arg_idx Index of the path_expression in args
117  @param[in] forbid_wildcards True if the path shouldn't contain * or **
118 
119  @returns false on success (valid path or NULL), true on error
120  */
121  bool parse_and_cache_path(Item **args, uint arg_idx, bool forbid_wildcards);
122 
123  /**
124  Return an already parsed path expression.
125 
126  @param[in] arg_idx Index of the path_expression in the JSON function args
127 
128  @returns the already parsed path, possibly NULL
129  */
130  const Json_path *get_path(uint arg_idx) const;
131 
132  /**
133  Reset the cache for re-use when a statement is re-executed.
134  */
135  void reset_cache();
136 };
137 
138 /* JSON function support */
139 
140 /**
141  Base class for all item functions that a return JSON value
142 */
143 class Item_json_func : public Item_func {
144  /// Can this function type be used in partial update?
145  virtual bool can_use_in_partial_update() const { return false; }
146 
147  protected:
148  /// String used when reading JSON binary values or JSON text values.
150  /// String used for converting JSON text values to utf8mb4 charset.
152  /// String used for converting a JSON value to text in val_str().
154 
155  // Cache for constant path expressions
157 
158  /**
159  Target column for partial update, if this function is used in an
160  update statement and partial update can be used.
161  */
163 
164  public:
165  /**
166  Construct an Item_json_func instance.
167  @param thd THD handle
168  @param parent_args arguments to forward to Item_func's constructor
169  */
170  template <typename... Args>
171  Item_json_func(THD *thd, Args &&... parent_args)
172  : Item_func(std::forward<Args>(parent_args)...),
173  m_path_cache(thd, arg_count) {
175  }
176 
177  bool resolve_type(THD *) override {
178  maybe_null = true;
179  return false;
180  }
181  enum Item_result result_type() const override { return STRING_RESULT; }
182  String *val_str(String *arg) override;
183  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
184  bool get_time(MYSQL_TIME *ltime) override;
185  longlong val_int() override;
186  double val_real() override;
187  my_decimal *val_decimal(my_decimal *decimal_value) override;
188 
189  void cleanup() override;
190 
191  Item_result cast_to_int_type() const override { return INT_RESULT; }
192 
193  /**
194  Does this function call support partial update of the given JSON column?
195 
196  JSON_SET, JSON_REPLACE and JSON_REMOVE support partial update of a JSON
197  column if the JSON column is the first argument of the function call, or if
198  the first argument is a sequence of nested JSON_SET, JSON_REPLACE and
199  JSON_REMOVE calls in which the JSON column is the first argument of the
200  inner function call.
201 
202  For example, this expression can be used to partially update column
203  `json_col`:
204 
205  JSON_SET(JSON_REPLACE(json_col, path1, val1), path2, val2)
206  */
207  bool supports_partial_update(const Field_json *field) const override;
208 
209  /**
210  Mark this expression as used in partial update. Should only be
211  called if #supports_partial_update returns true.
212  */
213  void mark_for_partial_update(const Field_json *field);
214 };
215 
216 /**
217  Return the JSON value of the argument in a wrapper. Abstracts whether
218  the value comes from a field or a function. Does not handle literals.
219  See also get_json_wrapper.
220 
221  @param[in] args the arguments
222  @param[in] arg_idx the argument index
223  @param[in,out] result the JSON value wrapper
224 
225  @returns false iff the argument is a JSON field or function result
226 */
227 bool json_value(Item **args, uint arg_idx, Json_wrapper *result);
228 
229 /**
230  Return the JSON value of the argument in a wrapper. Abstracts whether
231  the value comes from a field or a function or a valid JSON text.
232 
233  @param[in] args the arguments
234  @param[in] arg_idx the argument index
235  @param[out] str the string buffer
236  @param[in] func_name the name of the function we are executing
237  @param[out] wrapper the JSON value wrapper
238  @returns false if we found a value or NULL, true if not.
239 */
240 bool get_json_wrapper(Item **args, uint arg_idx, String *str,
241  const char *func_name, Json_wrapper *wrapper);
242 
243 /**
244  Convert Json values or MySQL values to JSON.
245 
246  @param[in] args arguments to function
247  @param[in] arg_idx the index of the argument to process
248  @param[in] calling_function name of the calling function
249  @param[in,out] value working area (if the returned Json_wrapper points
250  to a binary value rather than a DOM, this string
251  will end up holding the binary representation, and
252  it must stay alive until the wrapper is destroyed
253  or converted from binary to DOM)
254  @param[in,out] tmp temporary scratch space for converting strings to
255  the correct charset; only used if accept_string is
256  true and conversion is needed
257  @param[in,out] wr the result wrapper
258  @param[in,out] scalar pointer to pre-allocated memory that can be
259  borrowed by the result wrapper if the result is a
260  scalar. If the pointer is NULL, memory for a
261  scalar result will be allocated on the heap.
262  @param[in] accept_string
263  if true, accept MySQL strings as JSON strings
264  by converting them to UTF8, else emit an error
265  @returns false if we found a value or NULL, true otherwise
266 */
267 bool get_json_atom_wrapper(Item **args, uint arg_idx,
268  const char *calling_function, String *value,
269  String *tmp, Json_wrapper *wr,
270  Json_scalar_holder *scalar, bool accept_string);
271 
272 /**
273  Check a non-empty val for character set. If it has character set
274  my_charset_binary, signal error and return false. Else, try to convert to
275  my_charset_utf8mb4_bin. If this fails, signal error and return true, else
276  return false.
277 
278  @param[in] val the string to be checked
279  @param[in,out] buf buffer to hold the converted string
280  @param[out] resptr the resulting, possibly converted string,
281  only set if no error
282  @param[out] reslength the length of resptr
283  @param[in] require_string
284  If true, give error messages if binary string. If we
285  see a conversion error (space), we give error
286  notwithstanding this parameter value
287 
288  @returns True if the string could not be converted. False on success.
289 */
290 bool ensure_utf8mb4(const String &val, String *buf, const char **resptr,
291  size_t *reslength, bool require_string);
292 
293 /**
294  Represents the JSON function JSON_VALID( <value> )
295 */
298 
299  public:
301 
302  const char *func_name() const override { return "json_valid"; }
303 
304  bool is_bool_func() const override { return true; }
305 
306  longlong val_int() override;
307 
308  bool resolve_type(THD *) override {
309  maybe_null = true;
310  return false;
311  }
312 };
313 
314 /**
315  Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
316 */
318  public:
319  Item_func_json_schema_valid(const POS &pos, Item *a, Item *b);
320  ~Item_func_json_schema_valid() override;
321 
322  const char *func_name() const override { return "json_schema_valid"; }
323 
324  bool val_bool() override;
325 
326  longlong val_int() override { return val_bool() ? 1 : 0; }
327 
328  bool fix_fields(THD *, Item **) override;
329 
330  void cleanup() override;
331 
332  private:
333  // Wrap the object in a unique_ptr so that the relevant rapidjson destructors
334  // are called.
337 };
338 
339 /**
340  Represents the JSON function
341  JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> )
342 */
344  public:
346  PT_item_list *a);
348 
349  const char *func_name() const override {
350  return "json_schema_validation_report";
351  }
352 
353  bool val_json(Json_wrapper *wr) override;
354 
355  bool fix_fields(THD *, Item **) override;
356 
357  void cleanup() override;
358 
359  private:
360  // Wrap the object in a unique_ptr so that the relevant rapidjson destructors
361  // are called.
364 };
365 
366 /**
367  Represents the JSON function JSON_CONTAINS()
368 */
372 
373  public:
375  : Item_int_func(pos, a), m_path_cache(thd, arg_count) {}
376 
377  const char *func_name() const override { return "json_contains"; }
378  enum Functype functype() const override { return JSON_CONTAINS; }
379  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
380  bool gc_subst_analyzer(uchar **) override { return true; }
381 
382  bool is_bool_func() const override { return true; }
383 
384  longlong val_int() override;
385 
386  bool resolve_type(THD *) override {
387  maybe_null = true;
388  return false;
389  }
390 
391  /** Cleanup between executions of the statement */
392  void cleanup() override;
393 
395  return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
396  }
397 };
398 
399 /**
400  Represents the JSON function JSON_CONTAINS_PATH()
401 */
405 
406  // Cache for constant path expressions
408 
409  public:
411  : Item_int_func(pos, a),
413  m_path_cache(thd, arg_count) {}
414 
415  const char *func_name() const override { return "json_contains_path"; }
416 
417  bool is_bool_func() const override { return true; }
418 
419  longlong val_int() override;
420 
421  bool resolve_type(THD *) override {
422  maybe_null = true;
423  return false;
424  }
425 
426  /** Cleanup between executions of the statement */
427  void cleanup() override;
428 
430  return (arg == args[0]) ? CACHE_JSON_VALUE : CACHE_NONE;
431  }
432 };
433 
434 /**
435  Represents the JSON function JSON_TYPE
436 */
439 
440  public:
442 
443  const char *func_name() const override { return "json_type"; }
444 
445  bool resolve_type(THD *) override;
446 
447  String *val_str(String *) override;
448 };
449 
450 /**
451  Represents a "CAST( <value> AS JSON )" coercion.
452 */
454  public:
455  Item_typecast_json(THD *thd, const POS &pos, Item *a)
456  : Item_json_func(thd, pos, a) {}
457 
458  void print(const THD *thd, String *str,
459  enum_query_type query_type) const override;
460  const char *func_name() const override { return "cast_as_json"; }
461  const char *cast_type() const { return "json"; }
462  bool val_json(Json_wrapper *wr) override;
463 };
464 
465 /**
466  Represents the JSON function JSON_LENGTH()
467 */
470 
471  // Cache for constant path expressions
473 
474  public:
476  : Item_int_func(pos, a), m_path_cache(thd, 1) {}
477 
478  Item_func_json_length(THD *thd, const POS &pos, Item *a, Item *b)
479  : Item_int_func(pos, a, b), m_path_cache(thd, 2) {}
480 
481  bool resolve_type(THD *) override {
482  maybe_null = true;
483  return false;
484  }
485 
486  const char *func_name() const override { return "json_length"; }
487 
488  longlong val_int() override;
489 
490  void cleanup() override;
491 };
492 
493 /**
494  Represents the JSON function JSON_DEPTH()
495 */
498 
499  public:
501 
502  const char *func_name() const override { return "json_depth"; }
503 
504  longlong val_int() override;
505 };
506 
507 /**
508  Represents the JSON function JSON_KEYS()
509 */
512 
513  public:
514  Item_func_json_keys(THD *thd, const POS &pos, Item *a)
515  : Item_json_func(thd, pos, a) {}
516 
517  Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
518  : Item_json_func(thd, pos, a, b) {}
519 
520  const char *func_name() const override { return "json_keys"; }
521 
522  bool val_json(Json_wrapper *wr) override;
523 };
524 
525 /**
526  Represents the JSON function JSON_EXTRACT()
527 */
530 
531  public:
533  : Item_json_func(thd, pos, a) {}
534 
535  Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
536  : Item_json_func(thd, pos, a, b) {}
537 
538  const char *func_name() const override { return "json_extract"; }
539 
540  bool val_json(Json_wrapper *wr) override;
541 
542  bool eq(const Item *item, bool binary_cmp) const override;
543 };
544 
545 /**
546  Represents the JSON function JSON_ARRAY_APPEND()
547 */
550 
551  public:
553  : Item_json_func(thd, pos, a) {}
554 
555  const char *func_name() const override { return "json_array_append"; }
556 
557  bool val_json(Json_wrapper *wr) override;
558 };
559 
560 /**
561  Represents the JSON function JSON_INSERT()
562 */
565 
566  public:
568  : Item_json_func(thd, pos, a) {}
569 
570  const char *func_name() const override { return "json_insert"; }
571 
572  bool val_json(Json_wrapper *wr) override;
573 };
574 
575 /**
576  Represents the JSON function JSON_ARRAY_INSERT()
577 */
580 
581  public:
583  : Item_json_func(thd, pos, a) {}
584 
585  const char *func_name() const override { return "json_array_insert"; }
586 
587  bool val_json(Json_wrapper *wr) override;
588 };
589 
590 /**
591  Common base class for JSON_SET() and JSON_REPLACE().
592 */
594  /// True if this is JSON_SET, false if it is JSON_REPLACE.
595  const bool m_json_set;
598  bool can_use_in_partial_update() const override { return true; }
599 
600  protected:
601  template <typename... Args>
602  Item_func_json_set_replace(bool json_set, Args &&... parent_args)
603  : Item_json_func(std::forward<Args>(parent_args)...),
604  m_json_set(json_set) {}
605 
606  public:
607  bool val_json(Json_wrapper *wr) override;
608 };
609 
610 /**
611  Represents the JSON function JSON_SET()
612 */
614  public:
615  template <typename... Args>
616  Item_func_json_set(Args &&... parent_args)
617  : Item_func_json_set_replace(true, std::forward<Args>(parent_args)...) {}
618 
619  const char *func_name() const override { return "json_set"; }
620 };
621 
622 /**
623  Represents the JSON function JSON_REPLACE()
624 */
626  public:
627  template <typename... Args>
628  Item_func_json_replace(Args &&... parent_args)
629  : Item_func_json_set_replace(false, std::forward<Args>(parent_args)...) {}
630 
631  const char *func_name() const override { return "json_replace"; }
632 };
633 
634 /**
635  Represents the JSON function JSON_ARRAY()
636 */
638  public:
639  template <typename... Args>
640  Item_func_json_array(Args &&... parent_args)
641  : Item_json_func(std::forward<Args>(parent_args)...) {}
642 
643  const char *func_name() const override { return "json_array"; }
644 
645  bool val_json(Json_wrapper *wr) override;
646 };
647 
648 /**
649  Represents the JSON function JSON_OBJECT()
650 */
653 
654  public:
656  : Item_json_func(thd, pos, a) {}
657 
658  const char *func_name() const override { return "json_object"; }
659 
660  bool val_json(Json_wrapper *wr) override;
661 };
662 
663 /**
664  Represents the JSON function JSON_SEARCH()
665 */
669 
670  // LIKE machinery
673 
674  public:
675  /**
676  Construct a JSON_SEARCH() node.
677 
678  @param parent_args arguments to pass to Item_json_func's constructor
679  */
680  template <typename... Args>
681  Item_func_json_search(Args &&... parent_args)
682  : Item_json_func(std::forward<Args>(parent_args)...),
684 
685  const char *func_name() const override { return "json_search"; }
686 
687  bool val_json(Json_wrapper *wr) override;
688 
689  /**
690  Bind logic for the JSON_SEARCH() node.
691  */
692  bool fix_fields(THD *, Item **) override;
693 
694  void cleanup() override;
695 };
696 
697 /**
698  Represents the JSON function JSON_REMOVE()
699 */
702  bool can_use_in_partial_update() const override { return true; }
703 
704  public:
705  template <typename... Args>
706  Item_func_json_remove(Args &&... parent_args)
707  : Item_json_func(std::forward<Args>(parent_args)...) {}
708 
709  const char *func_name() const override { return "json_remove"; }
710 
711  bool val_json(Json_wrapper *wr) override;
712 };
713 
714 /**
715  Represents the JSON function JSON_MERGE_PRESERVE.
716 */
718  public:
720  : Item_json_func(thd, pos, a) {}
721 
722  const char *func_name() const override { return "json_merge_preserve"; }
723 
724  bool val_json(Json_wrapper *wr) override;
725 };
726 
727 /**
728  Represents the JSON function JSON_MERGE. It is a deprecated alias
729  for JSON_MERGE_PRESERVE.
730 */
732  public:
733  Item_func_json_merge(THD *thd, const POS &pos, PT_item_list *a);
734 
735  bool is_deprecated() const override { return true; }
736 };
737 
738 /**
739  Represents the JSON function JSON_MERGE_PATCH.
740 */
742  public:
744  : Item_json_func(thd, pos, a) {}
745 
746  const char *func_name() const override { return "json_merge_patch"; }
747 
748  bool val_json(Json_wrapper *wr) override;
749 };
750 
751 /**
752  Represents the JSON function JSON_QUOTE()
753 */
756 
757  public:
759  : Item_str_func(pos, a) {}
760 
761  const char *func_name() const override { return "json_quote"; }
762 
763  bool resolve_type(THD *) override {
764  maybe_null = true;
765 
766  /*
767  Any interior character could be replaced by a 6 character
768  escape sequence. Plus we will add 2 framing quote characters.
769  */
770  uint32 max_char_length = (6 * args[0]->max_char_length()) + 2;
772  return false;
773  }
774 
775  String *val_str(String *tmpspace) override;
776 };
777 
778 /**
779  Represents the JSON function JSON_UNQUOTE()
780 */
783 
784  public:
786  : Item_str_func(pos, a) {}
787 
789 
790  const char *func_name() const override { return "json_unquote"; }
791 
792  bool resolve_type(THD *) override {
793  maybe_null = true;
795  return false;
796  }
797 
798  String *val_str(String *str) override;
799 };
800 
801 /**
802  Represents the JSON_PRETTY function.
803 */
805  public:
807 
808  const char *func_name() const override { return "json_pretty"; }
809 
810  bool resolve_type(THD *) override {
812  return false;
813  }
814 
815  String *val_str(String *str) override;
816 };
817 
818 /**
819  Class that represents the function JSON_STORAGE_SIZE.
820 */
822  public:
824  : Item_int_func(pos, a) {}
825  const char *func_name() const override { return "json_storage_size"; }
826  longlong val_int() override;
827 };
828 
829 /**
830  Class that represents the function JSON_STORAGE_FREE.
831 */
833  public:
835  : Item_int_func(pos, a) {}
836  const char *func_name() const override { return "json_storage_free"; }
837  longlong val_int() override;
838 };
839 
840 enum Cast_target : unsigned char;
841 /**
842  Class that represents CAST(<expr> AS <type> ARRAY)
843 */
844 
846  /// Type to cast to
848  const CHARSET_INFO *cs;
849  /**
850  Whether use of CAST(.. AS .. ARRAY) is allowed
851 
852  Currently use of CAST(.. AS .. ARRAY) is limited only to CREATE
853  TABLE/INDEX. In all other cases an error is thrown. This flag is set to
854  true only for allowed cases to ensure allowed function usage.
855  */
856  bool m_is_allowed{false};
857 
858  /**
859  An array used by #save_in_field_inner() to store the result of an array cast
860  operation. It is cached in the Item in order to avoid the need for
861  reallocation on each row.
862  */
864 
865  public:
866  Item_func_array_cast(const POS &pos, Item *a, Cast_target type, uint len_arg,
867  uint dec_arg, const CHARSET_INFO *cs_arg);
868  ~Item_func_array_cast() override;
869  const char *func_name() const override { return "cast"; }
870  enum Functype functype() const override { return TYPECAST_FUNC; }
871  bool returns_array() const override { return true; }
872  bool val_json(Json_wrapper *wr) override;
873  void print(const THD *thd, String *str,
874  enum_query_type query_type) const override;
875  enum Item_result result_type() const override;
876  bool resolve_type(THD *) override;
877  Field *tmp_table_field(TABLE *table) override;
878  bool fix_fields(THD *thd, Item **ref) override;
879  void cleanup() override;
880  void allow_array_cast() override { m_is_allowed = true; }
882  bool no_conversions) override;
883  // Regular val_x() funcs shouldn't be called
884  /* purecov: begin inspected */
885  longlong val_int() override // For tests only
886  {
887  DBUG_ASSERT(0);
888  return 0; // For tests only
889  }
890  String *val_str(String *) override {
891  DBUG_ASSERT(0);
892  return NULL; // For tests only
893  }
895  DBUG_ASSERT(0); // For tests only
896  return NULL;
897  }
898  virtual double val_real() override {
899  DBUG_ASSERT(0);
900  return 0;
901  }
902  virtual bool get_date(MYSQL_TIME *, my_time_flags_t) override {
903  DBUG_ASSERT(0);
904  return true;
905  }
906  virtual bool get_time(MYSQL_TIME *) override {
907  DBUG_ASSERT(0);
908  return true;
909  }
910  /* purecov: end */
911 };
912 
914  public:
916  : Item_bool_func(pos, a, b) {}
917  const char *func_name() const override { return "json_overlaps"; }
918  enum Functype functype() const override { return JSON_OVERLAPS; }
919  bool gc_subst_analyzer(uchar **) override { return true; }
920  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
921  longlong val_int() override;
922  Item *key_item() const override;
924  return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
925  }
926 };
927 
929  public:
931  : Item_bool_func(pos, a, b) {}
932  const char *func_name() const override { return "member of"; }
933  enum Functype functype() const override { return MEMBER_OF_FUNC; }
934  bool gc_subst_analyzer(uchar **) override { return true; }
935  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
936  longlong val_int() override;
937  void print(const THD *thd, String *str,
938  enum_query_type query_type) const override;
939  Item *key_item() const override { return args[1]; }
941  return (arg == args[1]) ? CACHE_JSON_VALUE
942  : ((arg == args[0]) ? CACHE_JSON_ATOM : CACHE_NONE);
943  }
944 };
945 
946 /**
947  Turn a GEOMETRY value into a JSON value per the GeoJSON specification
948  revison 1.0. This method is implemented in item_geofunc.cc.
949 
950  @param[in,out] wr The wrapper to be stuffed with the JSON value.
951  @param[in] swkb The source GEOMETRY value.
952  @param[in] calling_function Name of user-invoked function (for errors)
953  @param[in] max_decimal_digits See the user documentation for ST_AsGeoJSON.
954  @param[in] add_bounding_box See the user documentation for ST_AsGeoJSON.
955  @param[in] add_short_crs_urn See the user documentation for ST_AsGeoJSON.
956  @param[in] add_long_crs_urn See the user documentation for ST_AsGeoJSON.
957  @param[in,out] geometry_srid Spatial Reference System Identifier to be filled
958  in.
959 
960  @return false if the conversion succeeds, true otherwise
961 */
962 bool geometry_to_json(Json_wrapper *wr, String *swkb,
963  const char *calling_function, int max_decimal_digits,
964  bool add_bounding_box, bool add_short_crs_urn,
965  bool add_long_crs_urn, uint32 *geometry_srid);
966 
967 /**
968  Convert JSON values or MySQL values to JSON. Converts SQL NULL
969  to the JSON null literal.
970 
971  @param[in] args arguments to function
972  @param[in] arg_idx the index of the argument to process
973  @param[in] calling_function name of the calling function
974  @param[in,out] value working area (if the returned Json_wrapper points
975  to a binary value rather than a DOM, this string
976  will end up holding the binary representation, and
977  it must stay alive until the wrapper is destroyed
978  or converted from binary to DOM)
979  @param[in,out] tmp temporary scratch space for converting strings to
980  the correct charset; only used if accept_string is
981  true and conversion is needed
982  @param[in,out] wr the result wrapper
983  @returns false if we found a value or NULL, true otherwise
984 */
985 bool get_atom_null_as_null(Item **args, uint arg_idx,
986  const char *calling_function, String *value,
987  String *tmp, Json_wrapper *wr);
988 
989 /**
990  Helper method for Item_func_json_* methods. Check whether an argument
991  can be converted to a utf8mb4 string.
992 
993  @param[in] arg_item An argument Item
994  @param[out] value Where to materialize the arg_item's string value
995  @param[out] utf8_res Buffer for use by ensure_utf8mb4.
996  @param[out] safep String pointer after any relevant conversion
997  @param[out] safe_length Corresponding string length
998 
999  @returns true if the Item is not a utf8mb4 string
1000 */
1001 bool get_json_string(Item *arg_item, String *value, String *utf8_res,
1002  const char **safep, size_t *safe_length);
1003 using Json_dom_ptr = std::unique_ptr<Json_dom>;
1004 
1005 bool parse_json(const String &res, uint arg_idx, const char *func_name,
1006  Json_dom_ptr *dom, bool require_str_or_json, bool *parse_error);
1007 
1010 
1011 enum class enum_jtc_on : uint16;
1012 bool save_json_to_field(THD *thd, Field *field, enum_jtc_on m_on_error,
1013  const Json_wrapper *w, enum_check_fields warn,
1014  bool set_field_null = false);
1015 #endif /* ITEM_JSON_FUNC_INCLUDED */
Item_func_json_type::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.cc:1206
Item_func_array_cast::fix_fields
bool fix_fields(THD *thd, Item **ref) override
Definition: item_json_func.cc:3581
Json_schema_validator
Json_schema_validator is an object that contains a JSON Schema that can be re-used multiple times.
Definition: json_schema.h:126
Item_func_array_cast::val_str
String * val_str(String *) override
Definition: item_json_func.h:890
Item_func_json_pretty::func_name
const char * func_name() const override
Definition: item_json_func.h:808
Item_func_json_valid::val_int
longlong val_int() override
Definition: item_json_func.cc:548
Item
Definition: item.h:665
Item_func_json_search::m_like_node
Item_func_like * m_like_node
Definition: item_json_func.h:672
Item_func_json_extract::Item_func_json_extract
Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:535
THD
Definition: sql_class.h:764
Item_json_func::m_partial_update_column
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:162
Item_func_json_keys::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1839
Item_func_json_unquote::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:792
Item_func_json_contains::gc_subst_analyzer
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:380
Mem_root_array
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:398
Json_dom
JSON DOM abstract base class.
Definition: json_dom.h:169
Item_func_json_contains::can_cache_json_arg
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:394
Item_func::args
Item ** args
Definition: item_func.h:87
Item::maybe_null
bool maybe_null
True if this item may be null.
Definition: item.h:2720
Item_func_json_valid::Item_func_json_valid
Item_func_json_valid(const POS &pos, Item *a)
Definition: item_json_func.h:300
Item_func_array_cast::cleanup
void cleanup() override
Definition: item_json_func.cc:3744
geometry_to_json
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 revison 1.0.
Definition: item_geofunc.cc:2298
Item_func_json_array_insert
Represents the JSON function JSON_ARRAY_INSERT()
Definition: item_json_func.h:578
Item_func_json_merge_preserve::func_name
const char * func_name() const override
Definition: item_json_func.h:722
Item_func_json_merge_patch::func_name
const char * func_name() const override
Definition: item_json_func.h:746
Item_func_json_set_replace::can_use_in_partial_update
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:598
Item_func_json_search::fix_fields
bool fix_fields(THD *, Item **) override
Bind logic for the JSON_SEARCH() node.
Definition: item_json_func.cc:2719
Item_func_json_remove::can_use_in_partial_update
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:702
Item_func_member_of::key_item
Item * key_item() const override
Definition: item_json_func.h:939
Json_wrapper
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1141
Prealloced_array< Json_path, 8 >
Item_func_json_array_append::Item_func_json_array_append
Item_func_json_array_append(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:552
Json_path_cache::~Json_path_cache
~Json_path_cache()
Definition: item_json_func.cc:486
MAX_BLOB_WIDTH
#define MAX_BLOB_WIDTH
Default width for blob.
Definition: mysql_com.h:849
STRING_RESULT
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:40
Item_func_json_set_replace::Item_func_json_set_replace
Item_func_json_set_replace(bool json_set, Args &&... parent_args)
Definition: item_json_func.h:602
Item_func_json_contains_path::Item_func_json_contains_path
Item_func_json_contains_path(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:410
Item_func_json_contains::m_path_cache
Json_path_cache m_path_cache
Definition: item_json_func.h:371
NULL
#define NULL
Definition: types.h:55
Item_func_json_search
Represents the JSON function JSON_SEARCH()
Definition: item_json_func.h:666
Item_func_json_schema_valid::m_cached_schema_validator
unique_ptr_destroy_only< const Json_schema_validator > m_cached_schema_validator
Definition: item_json_func.h:336
Item_func_member_of::func_name
const char * func_name() const override
Definition: item_json_func.h:932
Item_func_array_cast::m_result_array
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:863
Item_func_json_contains::Item_func_json_contains
Item_func_json_contains(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:374
Item_typecast_json
Represents a "CAST( <value> AS JSON )" coercion.
Definition: item_json_func.h:453
Item_func_json_search::m_doc_value
String m_doc_value
Definition: item_json_func.h:667
Item_func_json_schema_validation_report::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:722
Item_func::TYPECAST_FUNC
@ TYPECAST_FUNC
Definition: item_func.h:168
Item_func_json_pretty
Represents the JSON_PRETTY function.
Definition: item_json_func.h:804
CHARSET_INFO
Definition: m_ctype.h:354
Item_func_json_schema_valid::val_bool
bool val_bool() override
Definition: item_json_func.cc:675
get_json_wrapper
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:1102
Item_func_array_cast::func_name
const char * func_name() const override
Definition: item_json_func.h:869
Item_func_json_valid
Represents the JSON function JSON_VALID( <value> )
Definition: item_json_func.h:296
ooa_all
@ ooa_all
Definition: item_json_func.h:64
Item_func_json_set::func_name
const char * func_name() const override
Definition: item_json_func.h:619
Item_func_json_contains_path::func_name
const char * func_name() const override
Definition: item_json_func.h:415
Item_json_func::val_decimal
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_json_func.cc:1339
Item_func::type
enum Type type() const override
Definition: item_func.h:232
Item_func_json_merge_patch::Item_func_json_merge_patch
Item_func_json_merge_patch(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:743
Item_func_json_schema_validation_report::fix_fields
bool fix_fields(THD *, Item **) override
Definition: item_json_func.cc:703
Item_func_json_contains_path::val_int
longlong val_int() override
Definition: item_json_func.cc:1015
Item_func_json_contains::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:386
Item_func_json_search::func_name
const char * func_name() const override
Definition: item_json_func.h:685
Item_func_json_merge_preserve::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:3174
pos
char * pos
Definition: do_ctype.cc:76
sql_string.h
my_dbug.h
Item::set_data_type_string
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1074
Item_func_json_extract::func_name
const char * func_name() const override
Definition: item_json_func.h:538
Item_func_json_set
Represents the JSON function JSON_SET()
Definition: item_json_func.h:613
String
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:164
Item_func_json_schema_valid
Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
Definition: item_json_func.h:317
Json_path_clone
A lightweight path expression.
Definition: json_path.h:438
Item_func_json_length::cleanup
void cleanup() override
Definition: item_json_func.cc:1763
TABLE
Definition: table.h:1305
Item_json_func::get_date
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_json_func.cc:1303
Item_func_json_replace::func_name
const char * func_name() const override
Definition: item_json_func.h:631
Item_func_json_set::Item_func_json_set
Item_func_json_set(Args &&... parent_args)
Definition: item_json_func.h:616
longlong
long long int longlong
Definition: my_inttypes.h:54
Item_func::OPTIMIZE_KEY
@ OPTIMIZE_KEY
Definition: item_func.h:227
Item_func_array_cast::cs
const CHARSET_INFO * cs
Definition: item_json_func.h:848
Item_func_json_pretty::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:810
result
Definition: result.h:33
Item::CACHE_JSON_VALUE
@ CACHE_JSON_VALUE
Source data is a JSON string, parse and cache result.
Definition: item.h:744
Item_func_json_length::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:481
Item_func_json_schema_valid::func_name
const char * func_name() const override
Definition: item_json_func.h:322
Item_func_json_quote::Item_func_json_quote
Item_func_json_quote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:758
Item_func_array_cast::functype
enum Functype functype() const override
Definition: item_json_func.h:870
Item_func_json_row_object::func_name
const char * func_name() const override
Definition: item_json_func.h:658
Item_func_json_merge::is_deprecated
bool is_deprecated() const override
Definition: item_json_func.h:735
Item_func_json_storage_free::Item_func_json_storage_free
Item_func_json_storage_free(const POS &pos, Item *a)
Definition: item_json_func.h:834
Item_json_func::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:177
value
const string value("\"Value\"")
Item_func_json_keys
Represents the JSON function JSON_KEYS()
Definition: item_json_func.h:510
unique_ptr_destroy_only
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:408
ooa_null
@ ooa_null
Definition: item_json_func.h:65
Item_json_func::cleanup
void cleanup() override
JSON_*() support methods.
Definition: item_json_func.cc:542
Item_func_json_array_insert::func_name
const char * func_name() const override
Definition: item_json_func.h:585
Item_func_json_contains::is_bool_func
bool is_bool_func() const override
Definition: item_json_func.h:382
Item_func_json_keys::Item_func_json_keys
Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:517
Item_func_json_valid::is_bool_func
bool is_bool_func() const override
Definition: item_json_func.h:304
Item_func_json_array_insert::Item_func_json_array_insert
Item_func_json_array_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:582
Item_func_json_set_replace::m_json_set
const bool m_json_set
True if this is JSON_SET, false if it is JSON_REPLACE.
Definition: item_json_func.h:595
Item_func_json_quote
Represents the JSON function JSON_QUOTE()
Definition: item_json_func.h:754
Item_func_json_array_append::m_doc_value
String m_doc_value
Definition: item_json_func.h:549
Item::set_data_type_json
void set_data_type_json()
Set the data type of the Item to be JSON.
Definition: item.h:1206
Json_dom_ptr
std::unique_ptr< Json_dom > Json_dom_ptr
Definition: item_json_func.h:1003
true
#define true
Definition: config_static.h:44
Item_func_json_row_object::Item_func_json_row_object
Item_func_json_row_object(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:655
Item_func_json_contains::cleanup
void cleanup() override
Cleanup between executions of the statement.
Definition: item_json_func.cc:942
prealloced_array.h
Field_json
A field that stores a JSON value.
Definition: field.h:4164
Item_bool_func
Definition: item_cmpfunc.h:276
Item_result
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
item_func.h
Item_func_json_row_object::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:2660
Item_typecast_json::Item_typecast_json
Item_typecast_json(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:455
Item_func_json_replace
Represents the JSON function JSON_REPLACE()
Definition: item_json_func.h:625
Item_func_array_cast::returns_array
bool returns_array() const override
Whether the item returns array of its data type.
Definition: item_json_func.h:871
enum_one_or_all_type
enum_one_or_all_type
For use by JSON_CONTAINS_PATH() and JSON_SEARCH()
Definition: item_json_func.h:62
Json_scalar_holder
A class that is capable of holding objects of any sub-type of Json_scalar.
Definition: json_dom.h:1858
Item_int_func
Definition: item_func.h:841
my_alloc.h
Item_json_func::val_real
double val_real() override
Definition: item_json_func.cc:1330
Item_func_json_array_insert::m_doc_value
String m_doc_value
Definition: item_json_func.h:579
Item_func_array_cast::cast_type
Cast_target cast_type
Type to cast to.
Definition: item_json_func.h:847
Item_func_json_length
Represents the JSON function JSON_LENGTH()
Definition: item_json_func.h:468
Item_string
Definition: item.h:4183
Item_func_json_quote::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:763
Item_func_json_extract::m_doc_value
String m_doc_value
Definition: item_json_func.h:529
Item_func_json_unquote::func_name
const char * func_name() const override
Definition: item_json_func.h:790
Json_path_cache::m_paths
Prealloced_array< Json_path, 8 > m_paths
List of paths.
Definition: item_json_func.h:83
Item_func_json_type::val_str
String * val_str(String *) override
Definition: item_json_func.cc:1256
Item_func_json_overlaps
Definition: item_json_func.h:913
Json_path_cache::parse_and_cache_path
bool parse_and_cache_path(Item **args, uint arg_idx, bool forbid_wildcards)
Parse a path expression if necessary.
Definition: item_json_func.cc:488
enum_query_type.h
Item_func_json_storage_size
Class that represents the function JSON_STORAGE_SIZE.
Definition: item_json_func.h:821
Json_path_cache::Path_cell::m_index
size_t m_index
Definition: item_json_func.h:96
get_json_string
bool get_json_string(Item *arg_item, String *value, String *utf8_res, const char **safep, size_t *safe_length)
Helper method for Item_func_json_* methods.
Definition: item_json_func.cc:272
Item_func_json_storage_size::Item_func_json_storage_size
Item_func_json_storage_size(const POS &pos, Item *a)
Definition: item_json_func.h:823
Item_typecast_json::func_name
const char * func_name() const override
Definition: item_json_func.h:460
Item_str_func
Definition: item_strfunc.h:71
Item_func_array_cast::allow_array_cast
void allow_array_cast() override
A helper funciton to ensure proper usage of CAST(.
Definition: item_json_func.h:880
Item_func_json_contains::select_optimize
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:379
Item::enum_const_item_cache
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:740
my_charset_utf8mb4_bin
CHARSET_INFO my_charset_utf8mb4_bin
Definition: ctype-utf8.cc:8045
Item_json_func::val_str
String * val_str(String *arg) override
Definition: item_json_func.cc:1288
Item_func_json_length::Item_func_json_length
Item_func_json_length(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:475
Json_path_cache::reset_cache
void reset_cache()
Reset the cache for re-use when a statement is re-executed.
Definition: item_json_func.cc:533
Item_typecast_json::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1710
Item_func_json_contains_path::m_cached_ooa
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:404
Item_func_json_contains_path::m_path_cache
Json_path_cache m_path_cache
Definition: item_json_func.h:407
my_inttypes.h
Item_func_json_set_replace::m_doc_value
String m_doc_value
Definition: item_json_func.h:596
Item_func_json_remove::func_name
const char * func_name() const override
Definition: item_json_func.h:709
field.h
Item_func_json_merge_patch
Represents the JSON function JSON_MERGE_PATCH.
Definition: item_json_func.h:741
Item_func_array_cast::result_type
enum Item_result result_type() const override
Definition: item_json_func.cc:3703
Item_func_json_depth
Represents the JSON function JSON_DEPTH()
Definition: item_json_func.h:496
m_ctype.h
Item_func_json_depth::m_doc_value
String m_doc_value
Definition: item_json_func.h:497
Item_typecast_json::print
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:1754
Item_json_func::mark_for_partial_update
void mark_for_partial_update(const Field_json *field)
Mark this expression as used in partial update.
Definition: item_json_func.cc:2359
Sorted_index_array
Prealloced_array< size_t, 16 > Sorted_index_array
Definition: item_json_func.h:1008
Item_func_array_cast::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:3566
Item_func_json_unquote::Item_func_json_unquote
Item_func_json_unquote(const POS &pos, Item *a)
Definition: item_json_func.h:788
Item_func_member_of::val_int
longlong val_int() override
Definition: item_json_func.cc:3894
Item_func_json_keys::Item_func_json_keys
Item_func_json_keys(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:514
Item_func_array_cast::~Item_func_array_cast
~Item_func_array_cast() override
Json_path_cache::m_arg_idx_to_vector_idx
Mem_root_array< Path_cell > m_arg_idx_to_vector_idx
Map argument indexes to indexes into m_paths.
Definition: item_json_func.h:100
Item_func_json_contains_path::can_cache_json_arg
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:429
Json_array
Represents a JSON array container, i.e.
Definition: json_dom.h:518
Item_json_func::m_path_cache
Json_path_cache m_path_cache
Definition: item_json_func.h:156
Item_func_json_valid::m_value
String m_value
Definition: item_json_func.h:297
Item_func_array_cast
Class that represents CAST(<expr> AS <type> ARRAY)
Definition: item_json_func.h:845
Item_func::optimize_type
optimize_type
Definition: item_func.h:225
Item_func_member_of::print
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:3950
Item_func::MEMBER_OF_FUNC
@ MEMBER_OF_FUNC
Definition: item_func.h:222
Cast_target
Cast_target
Definition: item_create.h:53
Item_func_json_merge_preserve::Item_func_json_merge_preserve
Item_func_json_merge_preserve(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:719
Item_func_json_extract
Represents the JSON function JSON_EXTRACT()
Definition: item_json_func.h:528
json_value
bool json_value(Item **args, uint arg_idx, Json_wrapper *result)
Return the JSON value of the argument in a wrapper.
Definition: item_json_func.cc:1085
ensure_utf8mb4
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:72
item_strfunc.h
uint
unsigned int uint
Definition: uca-dump.cc:29
Json_path_cache::enum_path_status::OK_NULL
@ OK_NULL
Json_path_cache::Json_path_cache
Json_path_cache(THD *thd, uint size)
Json_path_cache.
Definition: item_json_func.cc:481
mysql_com.h
Item_func_json_depth::func_name
const char * func_name() const override
Definition: item_json_func.h:502
Item::CACHE_JSON_ATOM
@ CACHE_JSON_ATOM
Source data is SQL scalar, convert and cache result.
Definition: item.h:746
Item_func_json_merge_preserve
Represents the JSON function JSON_MERGE_PRESERVE.
Definition: item_json_func.h:717
Item_func_json_unquote::m_value
String m_value
Definition: item_json_func.h:782
Item_func_json_search::cleanup
void cleanup() override
JSON_*() support methods.
Definition: item_json_func.cc:2781
Item_func_json_contains
Represents the JSON function JSON_CONTAINS()
Definition: item_json_func.h:369
Item_func_json_quote::m_value
String m_value
Definition: item_json_func.h:755
Item_func_json_keys::func_name
const char * func_name() const override
Definition: item_json_func.h:520
Item_func_json_remove::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:3036
Item_func_json_length::Item_func_json_length
Item_func_json_length(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:478
ooa_one
@ ooa_one
Definition: item_json_func.h:63
Item_typecast_json::cast_type
const char * cast_type() const
Definition: item_json_func.h:461
Item_func_json_storage_free::val_int
longlong val_int() override
Definition: item_json_func.cc:3444
get_json_atom_wrapper
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:1636
uchar
unsigned char uchar
Definition: my_inttypes.h:51
Item_json_func
Base class for all item functions that a return JSON value.
Definition: item_json_func.h:143
Item_func_member_of::can_cache_json_arg
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:940
Item_func_json_storage_free
Class that represents the function JSON_STORAGE_FREE.
Definition: item_json_func.h:832
Item_func_member_of::functype
enum Functype functype() const override
Definition: item_json_func.h:933
Item_json_func::cast_to_int_type
Item_result cast_to_int_type() const override
Definition: item_json_func.h:191
Json_path_cache::Path_cell
Struct that points to a cell in m_paths and tells its status.
Definition: item_json_func.h:94
Item_func_member_of::select_optimize
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:935
my_time_flags_t
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:82
Item_func_json_contains::m_doc_value
String m_doc_value
Definition: item_json_func.h:370
my_decimal
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:91
Item_func_json_array::func_name
const char * func_name() const override
Definition: item_json_func.h:643
Item_func_json_schema_validation_report
Represents the JSON function JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> )
Definition: item_json_func.h:343
Item_func_json_remove::m_doc_value
String m_doc_value
Definition: item_json_func.h:701
uint32
uint32_t uint32
Definition: my_inttypes.h:66
Item_func_json_storage_size::val_int
longlong val_int() override
Definition: item_json_func.cc:3405
Json_path_cache::enum_path_status::ERROR
@ ERROR
Item_func_json_contains_path::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:421
Item_func_json_schema_valid::fix_fields
bool fix_fields(THD *, Item **) override
Definition: item_json_func.cc:601
Item_func_json_keys::m_doc_value
String m_doc_value
Definition: item_json_func.h:511
Item_func_member_of::gc_subst_analyzer
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:934
Item_func_json_pretty::val_str
String * val_str(String *str) override
Definition: item_json_func.cc:3382
Item_func_json_row_object
Represents the JSON function JSON_OBJECT()
Definition: item_json_func.h:651
ooa_uninitialized
@ ooa_uninitialized
Definition: item_json_func.h:67
enum_query_type
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
Item_func_json_set_replace::m_path
Json_path_clone m_path
Definition: item_json_func.h:597
Item_func
Definition: item_func.h:83
Item_func_json_overlaps::select_optimize
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:920
Item_func_json_overlaps::can_cache_json_arg
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:923
Item_func_json_extract::Item_func_json_extract
Item_func_json_extract(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:532
Item_func_json_search::m_source_string_item
Item_string * m_source_string_item
Definition: item_json_func.h:671
Item_func_json_insert::m_doc_value
String m_doc_value
Definition: item_json_func.h:564
Item_func_member_of
Definition: item_json_func.h:928
Item_json_func::m_string_buffer
String m_string_buffer
String used for converting a JSON value to text in val_str().
Definition: item_json_func.h:153
Item_func_array_cast::m_is_allowed
bool m_is_allowed
Whether use of CAST(.
Definition: item_json_func.h:856
Item_func_member_of::Item_func_member_of
Item_func_member_of(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:930
item_cmpfunc.h
Item_json_func::supports_partial_update
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:2370
Item_json_func::Item_json_func
Item_json_func(THD *thd, Args &&... parent_args)
Construct an Item_json_func instance.
Definition: item_json_func.h:171
PT_item_list
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:96
Item_func_json_overlaps::val_int
longlong val_int() override
Definition: item_json_func.cc:3800
bool
#define bool
Definition: config_static.h:42
Item_func_json_row_object::tmp_key_value
String tmp_key_value
Definition: item_json_func.h:652
Item_func::JSON_OVERLAPS
@ JSON_OVERLAPS
Definition: item_func.h:221
Item_func_json_overlaps::key_item
Item * key_item() const override
Return field Item that can be used for index lookups.
Definition: item_json_func.cc:3887
Item_func_array_cast::get_time
virtual bool get_time(MYSQL_TIME *) override
Definition: item_json_func.h:906
Item_func_json_length::val_int
longlong val_int() override
Definition: item_json_func.cc:1769
Item_func_array_cast::val_real
virtual double val_real() override
Definition: item_json_func.h:898
Item_func_json_depth::Item_func_json_depth
Item_func_json_depth(const POS &pos, Item *a)
Definition: item_json_func.h:500
Item_func_json_length::func_name
const char * func_name() const override
Definition: item_json_func.h:486
Json_path_cache::enum_path_status::UNINITIALIZED
@ UNINITIALIZED
Item_func_json_contains::val_int
longlong val_int() override
Definition: item_json_func.cc:948
Item_func::JSON_CONTAINS
@ JSON_CONTAINS
Definition: item_func.h:220
Item_func_array_cast::print
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:3599
MYSQL_TIME
Definition: mysql_time.h:81
YYLTYPE
Bison "location" class.
Definition: parse_location.h:43
my_time.h
Item_func_json_type::m_value
String m_value
Definition: item_json_func.h:438
Item_func_json_schema_valid::cleanup
void cleanup() override
Definition: item_json_func.cc:607
uint8
uint8_t uint8
Definition: my_inttypes.h:62
Item_func_json_contains_path::is_bool_func
bool is_bool_func() const override
Definition: item_json_func.h:417
DBUG_ASSERT
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
Item_func_json_unquote::Item_func_json_unquote
Item_func_json_unquote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:785
Item_func_json_array_append::func_name
const char * func_name() const override
Definition: item_json_func.h:555
save_json_to_field
enum enum_jtc_on uint16 bool save_json_to_field(THD *thd, Field *field, enum_jtc_on m_on_error, const Json_wrapper *w, enum_check_fields warn, bool set_field_null=false)
Save JSON to a given field.
Definition: item_json_func.cc:3981
json_path.h
Item_func_json_quote::func_name
const char * func_name() const override
Definition: item_json_func.h:761
Item_func_json_contains::func_name
const char * func_name() const override
Definition: item_json_func.h:377
Item_func_json_storage_free::func_name
const char * func_name() const override
Definition: item_json_func.h:836
Item_func_json_array_append
Represents the JSON function JSON_ARRAY_APPEND()
Definition: item_json_func.h:548
Item_func_json_insert::func_name
const char * func_name() const override
Definition: item_json_func.h:570
Item_func_json_pretty::Item_func_json_pretty
Item_func_json_pretty(const POS &pos, Item *a)
Definition: item_json_func.h:806
Item_func_json_quote::val_str
String * val_str(String *tmpspace) override
Definition: item_json_func.cc:3218
Item_func_json_contains_path::m_doc_value
String m_doc_value
Definition: item_json_func.h:403
get_atom_null_as_null
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:1696
std
Definition: varlen_sort.h:182
Item_func_array_cast::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.cc:3659
Item_func_json_extract::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:1899
Item_func_json_search::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:2877
parse_json
bool parse_json(const String &res, uint arg_idx, const char *func_name, Json_dom_ptr *dom, bool require_str_or_json, bool *parse_error)
Parse a JSON dom out of an argument to a JSON function.
Definition: item_json_func.cc:124
Item_func::arg_count
uint arg_count
Definition: item_func.h:111
Item_func_json_length::m_doc_value
String m_doc_value
Definition: item_json_func.h:469
Item_func_json_schema_validation_report::cleanup
void cleanup() override
JSON_*() support methods.
Definition: item_json_func.cc:709
Item_func_json_array::Item_func_json_array
Item_func_json_array(Args &&... parent_args)
Definition: item_json_func.h:640
Json_path_cache
Path cache for JSON functions.
Definition: item_json_func.h:77
Item_func_array_cast::val_decimal
my_decimal * val_decimal(my_decimal *) override
Definition: item_json_func.h:894
Item_func_json_valid::func_name
const char * func_name() const override
Definition: item_json_func.h:302
Item_func_array_cast::get_date
virtual bool get_date(MYSQL_TIME *, my_time_flags_t) override
Definition: item_json_func.h:902
Item_func_json_schema_valid::~Item_func_json_schema_valid
~Item_func_json_schema_valid() override
INT_RESULT
@ INT_RESULT
double
Definition: udf_registration_types.h:42
Item_func_json_valid::resolve_type
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_json_func.h:308
Item_json_func::m_value
String m_value
String used when reading JSON binary values or JSON text values.
Definition: item_json_func.h:149
Item_func_json_unquote::val_str
String * val_str(String *str) override
Definition: item_json_func.cc:3288
Item_func_json_set_replace
Common base class for JSON_SET() and JSON_REPLACE().
Definition: item_json_func.h:593
Item_func_array_cast::Item_func_array_cast
Item_func_array_cast(const POS &pos, Item *a, Cast_target type, uint len_arg, uint dec_arg, const CHARSET_INFO *cs_arg)
Definition: item_json_func.cc:3552
parse_tree_node_base.h
Item_json_func::m_conversion_buffer
String m_conversion_buffer
String used for converting JSON text values to utf8mb4 charset.
Definition: item_json_func.h:151
Item_func_json_type
Represents the JSON function JSON_TYPE.
Definition: item_json_func.h:437
Item_func_json_unquote
Represents the JSON function JSON_UNQUOTE()
Definition: item_json_func.h:781
uint16
uint16_t uint16
Definition: my_inttypes.h:64
Item_func_json_overlaps::gc_subst_analyzer
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:919
Json_path_cache::Path_cell::m_status
enum_path_status m_status
Definition: item_json_func.h:95
Item_func_json_schema_valid::Item_func_json_schema_valid
Item_func_json_schema_valid(const POS &pos, Item *a, Item *b)
Definition: item_json_func.cc:612
Item_func_json_set_replace::val_json
bool val_json(Json_wrapper *wr) override
Common implementation for JSON_SET and JSON_REPLACE.
Definition: item_json_func.cc:2397
Item_func_json_schema_validation_report::~Item_func_json_schema_validation_report
~Item_func_json_schema_validation_report() override
Item_func_array_cast::val_int
longlong val_int() override
Definition: item_json_func.h:885
Item_func_json_overlaps::functype
enum Functype functype() const override
Definition: item_json_func.h:918
ooa_error
@ ooa_error
Definition: item_json_func.h:66
Item_func_json_search::m_cached_ooa
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:668
Item_func_json_schema_valid::val_int
longlong val_int() override
Definition: item_json_func.h:326
Item_func_array_cast::tmp_table_field
Field * tmp_table_field(TABLE *table) override
Definition: item_json_func.cc:3736
Item_func_json_replace::Item_func_json_replace
Item_func_json_replace(Args &&... parent_args)
Definition: item_json_func.h:628
Item_func_json_contains::functype
enum Functype functype() const override
Definition: item_json_func.h:378
Item_func_json_contains_path::cleanup
void cleanup() override
Cleanup between executions of the statement.
Definition: item_json_func.cc:1008
Field
Definition: field.h:695
udf_registration_types.h
Item_func_json_merge
Represents the JSON function JSON_MERGE.
Definition: item_json_func.h:731
Item_func_json_insert
Represents the JSON function JSON_INSERT()
Definition: item_json_func.h:563
Item_func_json_remove
Represents the JSON function JSON_REMOVE()
Definition: item_json_func.h:700
Item_func_json_schema_validation_report::func_name
const char * func_name() const override
Definition: item_json_func.h:349
Item_func_json_merge::Item_func_json_merge
Item_func_json_merge(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.cc:3167
Item_func_json_depth::val_int
longlong val_int() override
Definition: item_json_func.cc:1818
Item_func_json_storage_size::func_name
const char * func_name() const override
Definition: item_json_func.h:825
Item_func_json_schema_validation_report::Item_func_json_schema_validation_report
Item_func_json_schema_validation_report(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.cc:715
final
#define final(a, b, c)
Definition: hash.c:109
Json_path_cache::m_path_value
String m_path_value
Holder for path strings.
Definition: item_json_func.h:80
Item_func_json_array_insert::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:2221
Item::CACHE_NONE
@ CACHE_NONE
Don't cache.
Definition: item.h:742
Item_func_json_length::m_path_cache
Json_path_cache m_path_cache
Definition: item_json_func.h:472
Json_path_cache::enum_path_status
enum_path_status
Enum that tells the status of a cell in m_paths.
Definition: item_json_func.h:86
Item_func_json_overlaps::func_name
const char * func_name() const override
Definition: item_json_func.h:917
Item_func_json_insert::Item_func_json_insert
Item_func_json_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:567
Json_path_cache::get_path
const Json_path * get_path(uint arg_idx) const
Return an already parsed path expression.
Definition: item_json_func.cc:523
Item_func_json_overlaps::Item_func_json_overlaps
Item_func_json_overlaps(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:915
Item::max_char_length
uint32 max_char_length() const
Definition: item.h:2460
Item_func_like
Definition: item_cmpfunc.h:2146
Item_func_json_extract::eq
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_json_func.cc:1965
Item_func_json_array_append::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:2014
sort_and_remove_dups
bool sort_and_remove_dups(const Json_wrapper &orig, Sorted_index_array *v)
Sort the elements of a JSON array and remove duplicates.
Definition: item_json_func.cc:776
mem_root_array.h
Item_func_json_type::func_name
const char * func_name() const override
Definition: item_json_func.h:443
Item_func_json_type::Item_func_json_type
Item_func_json_type(const POS &pos, Item *a)
Definition: item_json_func.h:441
Item_func_json_merge_patch::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:3470
Item_func::Functype
Functype
Definition: item_func.h:121
mysql_time.h
Item_json_func::val_int
longlong val_int() override
Definition: item_json_func.cc:1321
Json_path
A JSON path expression.
Definition: json_path.h:351
Item_func_json_array::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:2624
Item_func_json_search::Item_func_json_search
Item_func_json_search(Args &&... parent_args)
Construct a JSON_SEARCH() node.
Definition: item_json_func.h:681
Json_path_cache::enum_path_status::OK_NOT_NULL
@ OK_NOT_NULL
enum_jtc_on
enum_jtc_on
Types of ON ERROR/ON EMPTY clause for JSON_TABLE function.
Definition: table_function.h:189
Item_func_json_remove::Item_func_json_remove
Item_func_json_remove(Args &&... parent_args)
Definition: item_json_func.h:706
Item_func_json_contains_path
Represents the JSON function JSON_CONTAINS_PATH()
Definition: item_json_func.h:402
Item_json_func::result_type
enum Item_result result_type() const override
Definition: item_json_func.h:181
type_conversion_status
type_conversion_status
Status when storing a value in a field or converting from one datatype to another.
Definition: field.h:198
Item_func_json_schema_validation_report::m_cached_schema_validator
unique_ptr_destroy_only< const Json_schema_validator > m_cached_schema_validator
Definition: item_json_func.h:363
Item_func_array_cast::save_in_field_inner
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_json_func.cc:3723
Item_func_json_insert::val_json
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_json_func.cc:2098
Item_json_func::get_time
bool get_time(MYSQL_TIME *ltime) override
Definition: item_json_func.cc:1312
false
#define false
Definition: config_static.h:43
Item_json_func::can_use_in_partial_update
virtual bool can_use_in_partial_update() const
Can this function type be used in partial update?
Definition: item_json_func.h:145
Item_func_json_array
Represents the JSON function JSON_ARRAY()
Definition: item_json_func.h:637
item.h