MySQL  8.0.21
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, 2020, 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 <stdint.h>
28 #include <sys/types.h>
29 #include <memory>
30 #include <utility> // std::forward
31 
32 #include "m_ctype.h"
33 #include "my_alloc.h"
34 #include "my_dbug.h"
35 #include "my_inttypes.h"
36 #include "my_time.h"
38 #include "mysql_com.h"
39 #include "mysql_time.h"
40 #include "prealloced_array.h" // Prealloced_array
41 #include "sql/enum_query_type.h"
42 #include "sql/field.h"
43 #include "sql/item.h"
44 #include "sql/item_cmpfunc.h"
45 #include "sql/item_func.h"
46 #include "sql/item_strfunc.h" // Item_str_func
47 #include "sql/json_path.h" // Json_path
48 #include "sql/mem_root_array.h" // Mem_root_array
50 #include "sql_string.h"
51 
53 class Json_array;
54 class Json_dom;
55 class Json_scalar_holder;
56 class Json_wrapper;
57 class PT_item_list;
58 class THD;
59 class my_decimal;
60 enum Cast_target : unsigned char;
61 enum class Json_on_response_type : uint16;
62 struct Cast_type;
63 struct TABLE;
64 
65 /** For use by JSON_CONTAINS_PATH() and JSON_SEARCH() */
72 };
73 
74 /**
75  Path cache for JSON functions. Caches parsed path
76  objects for arguments which are string literals.
77  Maintains a vector of path objects and an array of
78  ints which map path argument numbers to slots in
79  the array.
80 */
82  private:
83  /// Holder for path strings.
85 
86  /// List of paths.
88 
89  /// Enum that tells the status of a cell in m_paths.
90  enum class enum_path_status : uint8 {
91  UNINITIALIZED,
92  OK_NOT_NULL,
93  OK_NULL,
94  ERROR
95  };
96 
97  /// Struct that points to a cell in m_paths and tells its status.
98  struct Path_cell {
99  enum_path_status m_status = enum_path_status::UNINITIALIZED;
100  size_t m_index = 0;
101  };
102 
103  /// Map argument indexes to indexes into m_paths.
105 
106  public:
107  Json_path_cache(THD *thd, uint size);
108  ~Json_path_cache();
109 
110  /**
111  Parse a path expression if necessary. Does nothing if the path
112  expression is constant and it has already been parsed. Assumes that
113  we've already verified that the path expression is not null. Raises an
114  error if the path expression is syntactically incorrect. Raises an
115  error if the path expression contains wildcard tokens but is not
116  supposed to. Otherwise puts the parsed path onto the
117  path vector.
118 
119  @param[in] args Array of args to a JSON function
120  @param[in] arg_idx Index of the path_expression in args
121  @param[in] forbid_wildcards True if the path shouldn't contain * or **
122 
123  @returns false on success (valid path or NULL), true on error
124  */
125  bool parse_and_cache_path(Item **args, uint arg_idx, bool forbid_wildcards);
126 
127  /**
128  Return an already parsed path expression.
129 
130  @param[in] arg_idx Index of the path_expression in the JSON function args
131 
132  @returns the already parsed path, possibly NULL
133  */
134  const Json_path *get_path(uint arg_idx) const;
135 
136  /**
137  Reset the cache for re-use when a statement is re-executed.
138  */
139  void reset_cache();
140 };
141 
142 /* JSON function support */
143 
144 /**
145  Base class for all item functions that a return JSON value
146 */
147 class Item_json_func : public Item_func {
148  /// Can this function type be used in partial update?
149  virtual bool can_use_in_partial_update() const { return false; }
150 
151  protected:
152  /// String used when reading JSON binary values or JSON text values.
154  /// String used for converting JSON text values to utf8mb4 charset.
156  /// String used for converting a JSON value to text in val_str().
158 
159  // Cache for constant path expressions
161 
162  /**
163  Target column for partial update, if this function is used in an
164  update statement and partial update can be used.
165  */
166  const Field_json *m_partial_update_column = nullptr;
167 
168  public:
169  /**
170  Construct an Item_json_func instance.
171  @param thd THD handle
172  @param parent_args arguments to forward to Item_func's constructor
173  */
174  template <typename... Args>
175  Item_json_func(THD *thd, Args &&... parent_args)
176  : Item_func(std::forward<Args>(parent_args)...),
177  m_path_cache(thd, arg_count) {
178  set_data_type_json();
179  }
180 
181  bool resolve_type(THD *) override {
182  maybe_null = true;
183  return false;
184  }
185  enum Item_result result_type() const override { return STRING_RESULT; }
186  String *val_str(String *arg) override;
187  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
188  bool get_time(MYSQL_TIME *ltime) override;
189  longlong val_int() override;
190  double val_real() override;
191  my_decimal *val_decimal(my_decimal *decimal_value) override;
192 
193  void cleanup() override;
194 
195  Item_result cast_to_int_type() const override { return INT_RESULT; }
196 
197  /**
198  Does this function call support partial update of the given JSON column?
199 
200  JSON_SET, JSON_REPLACE and JSON_REMOVE support partial update of a JSON
201  column if the JSON column is the first argument of the function call, or if
202  the first argument is a sequence of nested JSON_SET, JSON_REPLACE and
203  JSON_REMOVE calls in which the JSON column is the first argument of the
204  inner function call.
205 
206  For example, this expression can be used to partially update column
207  `json_col`:
208 
209  JSON_SET(JSON_REPLACE(json_col, path1, val1), path2, val2)
210  */
211  bool supports_partial_update(const Field_json *field) const override;
212 
213  /**
214  Mark this expression as used in partial update. Should only be
215  called if #supports_partial_update returns true.
216  */
217  void mark_for_partial_update(const Field_json *field);
218 };
219 
220 /**
221  Return the JSON value of the argument in a wrapper. Abstracts whether
222  the value comes from a field or a function. Does not handle literals.
223  See also get_json_wrapper.
224 
225  @param[in] args the arguments
226  @param[in] arg_idx the argument index
227  @param[in,out] result the JSON value wrapper
228 
229  @returns false iff the argument is a JSON field or function result
230 */
231 bool json_value(Item **args, uint arg_idx, Json_wrapper *result);
232 
233 /**
234  Return the JSON value of the argument in a wrapper. Abstracts whether
235  the value comes from a field or a function or a valid JSON text.
236 
237  @param[in] args the arguments
238  @param[in] arg_idx the argument index
239  @param[out] str the string buffer
240  @param[in] func_name the name of the function we are executing
241  @param[out] wrapper the JSON value wrapper
242  @returns false if we found a value or NULL, true if not.
243 */
244 bool get_json_wrapper(Item **args, uint arg_idx, String *str,
245  const char *func_name, Json_wrapper *wrapper);
246 
247 /**
248  Convert Json values or MySQL values to JSON.
249 
250  @param[in] args arguments to function
251  @param[in] arg_idx the index of the argument to process
252  @param[in] calling_function name of the calling function
253  @param[in,out] value working area (if the returned Json_wrapper points
254  to a binary value rather than a DOM, this string
255  will end up holding the binary representation, and
256  it must stay alive until the wrapper is destroyed
257  or converted from binary to DOM)
258  @param[in,out] tmp temporary scratch space for converting strings to
259  the correct charset; only used if accept_string is
260  true and conversion is needed
261  @param[in,out] wr the result wrapper
262  @param[in,out] scalar pointer to pre-allocated memory that can be
263  borrowed by the result wrapper if the result is a
264  scalar. If the pointer is NULL, memory for a
265  scalar result will be allocated on the heap.
266  @param[in] accept_string
267  if true, accept MySQL strings as JSON strings
268  by converting them to UTF8, else emit an error
269  @returns false if we found a value or NULL, true otherwise
270 */
271 bool get_json_atom_wrapper(Item **args, uint arg_idx,
272  const char *calling_function, String *value,
273  String *tmp, Json_wrapper *wr,
274  Json_scalar_holder *scalar, bool accept_string);
275 
276 /**
277  Check a non-empty val for character set. If it has character set
278  my_charset_binary, signal error and return false. Else, try to convert to
279  my_charset_utf8mb4_bin. If this fails, signal error and return true, else
280  return false.
281 
282  @param[in] val the string to be checked
283  @param[in,out] buf buffer to hold the converted string
284  @param[out] resptr the resulting, possibly converted string,
285  only set if no error
286  @param[out] reslength the length of resptr
287  @param[in] require_string
288  If true, give error messages if binary string. If we
289  see a conversion error (space), we give error
290  notwithstanding this parameter value
291 
292  @returns True if the string could not be converted. False on success.
293 */
294 bool ensure_utf8mb4(const String &val, String *buf, const char **resptr,
295  size_t *reslength, bool require_string);
296 
297 /**
298  Represents the JSON function JSON_VALID( <value> )
299 */
302 
303  public:
304  Item_func_json_valid(const POS &pos, Item *a) : Item_int_func(pos, a) {}
305 
306  const char *func_name() const override { return "json_valid"; }
307 
308  bool is_bool_func() const override { return true; }
309 
310  longlong val_int() override;
311 
312  bool resolve_type(THD *) override {
313  maybe_null = true;
314  return false;
315  }
316 };
317 
318 /**
319  Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
320 */
322  public:
323  Item_func_json_schema_valid(const POS &pos, Item *a, Item *b);
324  ~Item_func_json_schema_valid() override;
325 
326  const char *func_name() const override { return "json_schema_valid"; }
327 
328  bool val_bool() override;
329 
330  longlong val_int() override { return val_bool() ? 1 : 0; }
331 
332  bool fix_fields(THD *, Item **) override;
333 
334  void cleanup() override;
335 
336  private:
337  // Wrap the object in a unique_ptr so that the relevant rapidjson destructors
338  // are called.
341 };
342 
343 /**
344  Represents the JSON function
345  JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> )
346 */
348  public:
350  PT_item_list *a);
352 
353  const char *func_name() const override {
354  return "json_schema_validation_report";
355  }
356 
357  bool val_json(Json_wrapper *wr) override;
358 
359  bool fix_fields(THD *, Item **) override;
360 
361  void cleanup() override;
362 
363  private:
364  // Wrap the object in a unique_ptr so that the relevant rapidjson destructors
365  // are called.
368 };
369 
370 /**
371  Represents the JSON function JSON_CONTAINS()
372 */
376 
377  public:
379  : Item_int_func(pos, a), m_path_cache(thd, arg_count) {}
380 
381  const char *func_name() const override { return "json_contains"; }
382  enum Functype functype() const override { return JSON_CONTAINS; }
383  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
384  bool gc_subst_analyzer(uchar **) override { return true; }
385 
386  bool is_bool_func() const override { return true; }
387 
388  longlong val_int() override;
389 
390  bool resolve_type(THD *) override {
391  maybe_null = true;
392  return false;
393  }
394 
395  /** Cleanup between executions of the statement */
396  void cleanup() override;
397 
399  return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE;
400  }
401 };
402 
403 /**
404  Represents the JSON function JSON_CONTAINS_PATH()
405 */
409 
410  // Cache for constant path expressions
412 
413  public:
415  : Item_int_func(pos, a),
416  m_cached_ooa(ooa_uninitialized),
417  m_path_cache(thd, arg_count) {}
418 
419  const char *func_name() const override { return "json_contains_path"; }
420 
421  bool is_bool_func() const override { return true; }
422 
423  longlong val_int() override;
424 
425  bool resolve_type(THD *) override {
426  maybe_null = true;
427  return false;
428  }
429 
430  /** Cleanup between executions of the statement */
431  void cleanup() override;
432 
434  return (arg == args[0]) ? CACHE_JSON_VALUE : CACHE_NONE;
435  }
436 };
437 
438 /**
439  Represents the JSON function JSON_TYPE
440 */
443 
444  public:
445  Item_func_json_type(const POS &pos, Item *a) : Item_str_func(pos, a) {}
446 
447  const char *func_name() const override { return "json_type"; }
448 
449  bool resolve_type(THD *) override;
450 
451  String *val_str(String *) override;
452 };
453 
454 /**
455  Represents a "CAST( <value> AS JSON )" coercion.
456 */
458  public:
459  Item_typecast_json(THD *thd, const POS &pos, Item *a)
460  : Item_json_func(thd, pos, a) {}
461 
462  void print(const THD *thd, String *str,
463  enum_query_type query_type) const override;
464  const char *func_name() const override { return "cast_as_json"; }
465  const char *cast_type() const { return "json"; }
466  bool val_json(Json_wrapper *wr) override;
467 };
468 
469 /**
470  Represents the JSON function JSON_LENGTH()
471 */
474 
475  // Cache for constant path expressions
477 
478  public:
480  : Item_int_func(pos, a), m_path_cache(thd, 1) {}
481 
482  Item_func_json_length(THD *thd, const POS &pos, Item *a, Item *b)
483  : Item_int_func(pos, a, b), m_path_cache(thd, 2) {}
484 
485  bool resolve_type(THD *) override {
486  maybe_null = true;
487  return false;
488  }
489 
490  const char *func_name() const override { return "json_length"; }
491 
492  longlong val_int() override;
493 
494  void cleanup() override;
495 };
496 
497 /**
498  Represents the JSON function JSON_DEPTH()
499 */
502 
503  public:
504  Item_func_json_depth(const POS &pos, Item *a) : Item_int_func(pos, a) {}
505 
506  const char *func_name() const override { return "json_depth"; }
507 
508  longlong val_int() override;
509 };
510 
511 /**
512  Represents the JSON function JSON_KEYS()
513 */
516 
517  public:
518  Item_func_json_keys(THD *thd, const POS &pos, Item *a)
519  : Item_json_func(thd, pos, a) {}
520 
521  Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
522  : Item_json_func(thd, pos, a, b) {}
523 
524  const char *func_name() const override { return "json_keys"; }
525 
526  bool val_json(Json_wrapper *wr) override;
527 };
528 
529 /**
530  Represents the JSON function JSON_EXTRACT()
531 */
534 
535  public:
537  : Item_json_func(thd, pos, a) {}
538 
539  Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
540  : Item_json_func(thd, pos, a, b) {}
541 
542  const char *func_name() const override { return "json_extract"; }
543 
544  bool val_json(Json_wrapper *wr) override;
545 
546  bool eq(const Item *item, bool binary_cmp) const override;
547 };
548 
549 /**
550  Represents the JSON function JSON_ARRAY_APPEND()
551 */
554 
555  public:
557  : Item_json_func(thd, pos, a) {}
558 
559  const char *func_name() const override { return "json_array_append"; }
560 
561  bool val_json(Json_wrapper *wr) override;
562 };
563 
564 /**
565  Represents the JSON function JSON_INSERT()
566 */
569 
570  public:
572  : Item_json_func(thd, pos, a) {}
573 
574  const char *func_name() const override { return "json_insert"; }
575 
576  bool val_json(Json_wrapper *wr) override;
577 };
578 
579 /**
580  Represents the JSON function JSON_ARRAY_INSERT()
581 */
584 
585  public:
587  : Item_json_func(thd, pos, a) {}
588 
589  const char *func_name() const override { return "json_array_insert"; }
590 
591  bool val_json(Json_wrapper *wr) override;
592 };
593 
594 /**
595  Common base class for JSON_SET() and JSON_REPLACE().
596 */
598  /// True if this is JSON_SET, false if it is JSON_REPLACE.
599  const bool m_json_set;
602  bool can_use_in_partial_update() const override { return true; }
603 
604  protected:
605  template <typename... Args>
606  Item_func_json_set_replace(bool json_set, Args &&... parent_args)
607  : Item_json_func(std::forward<Args>(parent_args)...),
608  m_json_set(json_set) {}
609 
610  public:
611  bool val_json(Json_wrapper *wr) override;
612 };
613 
614 /**
615  Represents the JSON function JSON_SET()
616 */
618  public:
619  template <typename... Args>
620  Item_func_json_set(Args &&... parent_args)
621  : Item_func_json_set_replace(true, std::forward<Args>(parent_args)...) {}
622 
623  const char *func_name() const override { return "json_set"; }
624 };
625 
626 /**
627  Represents the JSON function JSON_REPLACE()
628 */
630  public:
631  template <typename... Args>
632  Item_func_json_replace(Args &&... parent_args)
633  : Item_func_json_set_replace(false, std::forward<Args>(parent_args)...) {}
634 
635  const char *func_name() const override { return "json_replace"; }
636 };
637 
638 /**
639  Represents the JSON function JSON_ARRAY()
640 */
642  public:
643  template <typename... Args>
644  Item_func_json_array(Args &&... parent_args)
645  : Item_json_func(std::forward<Args>(parent_args)...) {}
646 
647  const char *func_name() const override { return "json_array"; }
648 
649  bool val_json(Json_wrapper *wr) override;
650 };
651 
652 /**
653  Represents the JSON function JSON_OBJECT()
654 */
657 
658  public:
660  : Item_json_func(thd, pos, a) {}
661 
662  const char *func_name() const override { return "json_object"; }
663 
664  bool val_json(Json_wrapper *wr) override;
665 };
666 
667 /**
668  Represents the JSON function JSON_SEARCH()
669 */
673 
674  // LIKE machinery
677 
678  public:
679  /**
680  Construct a JSON_SEARCH() node.
681 
682  @param parent_args arguments to pass to Item_json_func's constructor
683  */
684  template <typename... Args>
685  Item_func_json_search(Args &&... parent_args)
686  : Item_json_func(std::forward<Args>(parent_args)...),
687  m_cached_ooa(ooa_uninitialized) {}
688 
689  const char *func_name() const override { return "json_search"; }
690 
691  bool val_json(Json_wrapper *wr) override;
692 
693  /**
694  Bind logic for the JSON_SEARCH() node.
695  */
696  bool fix_fields(THD *, Item **) override;
697 
698  void cleanup() override;
699 };
700 
701 /**
702  Represents the JSON function JSON_REMOVE()
703 */
706  bool can_use_in_partial_update() const override { return true; }
707 
708  public:
709  template <typename... Args>
710  Item_func_json_remove(Args &&... parent_args)
711  : Item_json_func(std::forward<Args>(parent_args)...) {}
712 
713  const char *func_name() const override { return "json_remove"; }
714 
715  bool val_json(Json_wrapper *wr) override;
716 };
717 
718 /**
719  Represents the JSON function JSON_MERGE_PRESERVE.
720 */
722  public:
724  : Item_json_func(thd, pos, a) {}
725 
726  const char *func_name() const override { return "json_merge_preserve"; }
727 
728  bool val_json(Json_wrapper *wr) override;
729 };
730 
731 /**
732  Represents the JSON function JSON_MERGE. It is a deprecated alias
733  for JSON_MERGE_PRESERVE.
734 */
736  public:
737  Item_func_json_merge(THD *thd, const POS &pos, PT_item_list *a);
738 
739  bool is_deprecated() const override { return true; }
740 };
741 
742 /**
743  Represents the JSON function JSON_MERGE_PATCH.
744 */
746  public:
748  : Item_json_func(thd, pos, a) {}
749 
750  const char *func_name() const override { return "json_merge_patch"; }
751 
752  bool val_json(Json_wrapper *wr) override;
753 };
754 
755 /**
756  Represents the JSON function JSON_QUOTE()
757 */
760 
761  public:
763  : Item_str_func(pos, a) {}
764 
765  const char *func_name() const override { return "json_quote"; }
766 
767  bool resolve_type(THD *) override {
768  maybe_null = true;
769 
770  /*
771  Any interior character could be replaced by a 6 character
772  escape sequence. Plus we will add 2 framing quote characters.
773  */
774  uint32 max_char_length = (6 * args[0]->max_char_length()) + 2;
775  set_data_type_string(max_char_length, &my_charset_utf8mb4_bin);
776  return false;
777  }
778 
779  String *val_str(String *tmpspace) override;
780 };
781 
782 /**
783  Represents the JSON function JSON_UNQUOTE()
784 */
787 
788  public:
790  : Item_str_func(pos, a) {}
791 
793 
794  const char *func_name() const override { return "json_unquote"; }
795 
796  bool resolve_type(THD *) override {
797  maybe_null = true;
798  set_data_type_string(args[0]->max_char_length(), &my_charset_utf8mb4_bin);
799  return false;
800  }
801 
802  String *val_str(String *str) override;
803 };
804 
805 /**
806  Represents the JSON_PRETTY function.
807 */
809  public:
810  Item_func_json_pretty(const POS &pos, Item *a) : Item_str_func(pos, a) {}
811 
812  const char *func_name() const override { return "json_pretty"; }
813 
814  bool resolve_type(THD *) override {
815  set_data_type_string(MAX_BLOB_WIDTH, &my_charset_utf8mb4_bin);
816  return false;
817  }
818 
819  String *val_str(String *str) override;
820 };
821 
822 /**
823  Class that represents the function JSON_STORAGE_SIZE.
824 */
826  public:
828  : Item_int_func(pos, a) {}
829  const char *func_name() const override { return "json_storage_size"; }
830  longlong val_int() override;
831 };
832 
833 /**
834  Class that represents the function JSON_STORAGE_FREE.
835 */
837  public:
839  : Item_int_func(pos, a) {}
840  const char *func_name() const override { return "json_storage_free"; }
841  longlong val_int() override;
842 };
843 
844 /**
845  Class that represents CAST(<expr> AS <type> ARRAY)
846 */
847 
849  /// Type to cast to
851  /**
852  Whether use of CAST(.. AS .. ARRAY) is allowed
853 
854  Currently use of CAST(.. AS .. ARRAY) is limited only to CREATE
855  TABLE/INDEX. In all other cases an error is thrown. This flag is set to
856  true only for allowed cases to ensure allowed function usage.
857  */
858  bool m_is_allowed{false};
859 
860  /**
861  An array used by #save_in_field_inner() to store the result of an array cast
862  operation. It is cached in the Item in order to avoid the need for
863  reallocation on each row.
864  */
866 
867  public:
868  Item_func_array_cast(const POS &pos, Item *a, Cast_target type, uint len_arg,
869  uint dec_arg, const CHARSET_INFO *cs_arg);
870  ~Item_func_array_cast() override;
871  const char *func_name() const override { return "cast_as_array"; }
872  enum Functype functype() const override { return TYPECAST_FUNC; }
873  bool returns_array() const override { return true; }
874  bool val_json(Json_wrapper *wr) override;
875  void print(const THD *thd, String *str,
876  enum_query_type query_type) const override;
877  enum Item_result result_type() const override;
878  bool resolve_type(THD *) override;
879  Field *tmp_table_field(TABLE *table) override;
880  bool fix_fields(THD *thd, Item **ref) override;
881  void allow_array_cast() override { m_is_allowed = true; }
882  type_conversion_status save_in_field_inner(Field *field,
883  bool no_conversions) override;
884  // Regular val_x() funcs shouldn't be called
885  /* purecov: begin inspected */
886  longlong val_int() override {
887  DBUG_ASSERT(false);
888  return 0;
889  }
890  String *val_str(String *) override {
891  DBUG_ASSERT(false);
892  return nullptr;
893  }
895  DBUG_ASSERT(false);
896  return nullptr;
897  }
898  double val_real() override {
899  DBUG_ASSERT(false);
900  return 0;
901  }
902  bool get_date(MYSQL_TIME *, my_time_flags_t) override {
903  DBUG_ASSERT(false);
904  return true;
905  }
906  bool get_time(MYSQL_TIME *) override {
907  DBUG_ASSERT(false);
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  Class implementing the JSON_VALUE function.
948 
949  Functionality-wise it's a combination of CAST, JSON_UNQUOTE and JSON_EXTRACT,
950  but with additional functionality for flexible handling of empty values and
951  conversion errors.
952 */
954  public:
955  Item_func_json_value(const POS &pos, Item *arg, Item *path,
956  const Cast_type &cast_type, unsigned length,
957  unsigned precision, Json_on_response_type on_empty_type,
958  Item *on_empty_default,
959  Json_on_response_type on_error_type,
960  Item *on_error_default);
961  ~Item_func_json_value() override;
962  const char *func_name() const override { return "json_value"; }
963  enum Item_result result_type() const override;
964  bool resolve_type(THD *) override;
965  bool fix_fields(THD *thd, Item **ref) override;
966  void print(const THD *thd, String *str,
967  enum_query_type query_type) const override;
968  bool eq(const Item *item, bool binary_cmp) const override;
969  bool val_json(Json_wrapper *wr) override;
970  String *val_str(String *buffer) override;
971  double val_real() override;
972  longlong val_int() override;
973  my_decimal *val_decimal(my_decimal *value) override;
974  bool get_date(MYSQL_TIME *ltime, my_time_flags_t flags) override;
975  bool get_time(MYSQL_TIME *ltime) override;
976 
977  private:
978  /// Represents a default value given in JSON_VALUE's DEFAULT xxx ON EMPTY or
979  /// DEFAULT xxx ON ERROR clause.
981 
982  /// Parsed path.
984  /// Type of the ON EMPTY clause.
986  /// Type of the ON ERROR clause.
988  /// The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
990  /// The default value for ON EMPTY (if not ERROR or NULL ON EMPTY).
992  /// The target data type.
994 
995  /**
996  Creates a Json_value_default object representing the default value given in
997  a DEFAULT xxx ON EMPTY clause or a DEFAULT xxx ON ERROR clause.
998 
999  @param thd the current session
1000  @param item the Item that represents the default value expression
1001  @return a pointer to the created object on success, nullptr on error
1002  */
1003  unique_ptr_destroy_only<Default_value> create_json_value_default(THD *thd,
1004  Item *item);
1005 
1006  /**
1007  Extracts the JSON value at the given path.
1008 
1009  @param[out] json the extracted JSON value, if the path matched exactly
1010  one value; empty otherwise
1011  @param[out] return_default the default value to return if a
1012  DEFAULT ... ON EMPTY or DEFAULT ... ON ERROR clause was invoked,
1013  or nullptr if no DEFAULT clause was invoked
1014  @return true if an error was raised, false otherwise
1015  */
1016  bool extract_json_value(Json_wrapper *json,
1017  const Default_value **return_default);
1018 
1019  /// Implements val_int() for RETURNING SIGNED and RETURNING UNSIGNED.
1020  int64_t extract_integer_value();
1021  /// Implements get_date() for RETURNING DATE.
1022  bool extract_date_value(MYSQL_TIME *ltime);
1023  /// Implements get_time() for RETURNING TIME.
1024  bool extract_time_value(MYSQL_TIME *ltime);
1025  /// Implements get_date() for RETURNING DATETIME.
1026  bool extract_datetime_value(MYSQL_TIME *ltime);
1027  /// Implements val_decimal() for RETURNING DECIMAL.
1028  my_decimal *extract_decimal_value(my_decimal *value);
1029  /// Implements val_str() for RETURNING CHAR and RETURNING BINARY.
1030  String *extract_string_value(String *buffer);
1031  /// Implements val_real() for RETURNING FLOAT/REAL/DOUBLE.
1032  double extract_real_value();
1033 };
1034 
1035 /**
1036  Turn a GEOMETRY value into a JSON value per the GeoJSON specification
1037  revison 1.0. This method is implemented in item_geofunc.cc.
1038 
1039  @param[in,out] wr The wrapper to be stuffed with the JSON value.
1040  @param[in] swkb The source GEOMETRY value.
1041  @param[in] calling_function Name of user-invoked function (for errors)
1042  @param[in] max_decimal_digits See the user documentation for ST_AsGeoJSON.
1043  @param[in] add_bounding_box See the user documentation for ST_AsGeoJSON.
1044  @param[in] add_short_crs_urn See the user documentation for ST_AsGeoJSON.
1045  @param[in] add_long_crs_urn See the user documentation for ST_AsGeoJSON.
1046  @param[in,out] geometry_srid Spatial Reference System Identifier to be filled
1047  in.
1048 
1049  @return false if the conversion succeeds, true otherwise
1050 */
1051 bool geometry_to_json(Json_wrapper *wr, String *swkb,
1052  const char *calling_function, int max_decimal_digits,
1053  bool add_bounding_box, bool add_short_crs_urn,
1054  bool add_long_crs_urn, uint32 *geometry_srid);
1055 
1056 /**
1057  Convert JSON values or MySQL values to JSON. Converts SQL NULL
1058  to the JSON null literal.
1059 
1060  @param[in] args arguments to function
1061  @param[in] arg_idx the index of the argument to process
1062  @param[in] calling_function name of the calling function
1063  @param[in,out] value working area (if the returned Json_wrapper points
1064  to a binary value rather than a DOM, this string
1065  will end up holding the binary representation, and
1066  it must stay alive until the wrapper is destroyed
1067  or converted from binary to DOM)
1068  @param[in,out] tmp temporary scratch space for converting strings to
1069  the correct charset; only used if accept_string is
1070  true and conversion is needed
1071  @param[in,out] wr the result wrapper
1072  @returns false if we found a value or NULL, true otherwise
1073 */
1074 bool get_atom_null_as_null(Item **args, uint arg_idx,
1075  const char *calling_function, String *value,
1076  String *tmp, Json_wrapper *wr);
1077 
1078 /**
1079  Helper method for Item_func_json_* methods. Check whether an argument
1080  can be converted to a utf8mb4 string.
1081 
1082  @param[in] arg_item An argument Item
1083  @param[out] value Where to materialize the arg_item's string value
1084  @param[out] utf8_res Buffer for use by ensure_utf8mb4.
1085  @param[out] safep String pointer after any relevant conversion
1086  @param[out] safe_length Corresponding string length
1087 
1088  @returns true if the Item is not a utf8mb4 string
1089 */
1090 bool get_json_string(Item *arg_item, String *value, String *utf8_res,
1091  const char **safep, size_t *safe_length);
1092 using Json_dom_ptr = std::unique_ptr<Json_dom>;
1093 
1094 bool parse_json(const String &res, uint arg_idx, const char *func_name,
1095  Json_dom_ptr *dom, bool require_str_or_json, bool *parse_error);
1096 
1099 
1100 bool save_json_to_field(THD *thd, Field *field, const Json_wrapper *w,
1101  bool no_error);
1102 #endif /* ITEM_JSON_FUNC_INCLUDED */
Definition: item_json_func.h:71
Represents the JSON function JSON_EXTRACT()
Definition: item_json_func.h:532
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:1705
bool is_bool_func() const override
Definition: item_json_func.h:386
longlong val_int() override
Definition: item_json_func.h:886
String m_value
Definition: item_json_func.h:786
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1143
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:131
Definition: result.h:29
const char * func_name() const override
Definition: item_json_func.h:542
static void print(const char *key, int keylen, const char *val, int vallen)
Print the key value pair.
Definition: mcstat.c:106
unsigned char uchar
Definition: my_inttypes.h:51
Our own string classes, used pervasively throughout the executor.
Item_func_json_row_object(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:659
Item_func_json_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:571
Represents the JSON function JSON_VALID( <value> )
Definition: item_json_func.h:300
optimize_type
Definition: item_func.h:232
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
const char * func_name() const override
Definition: item_json_func.h:689
not valid for UDFs
Definition: udf_registration_types.h:40
Cast_target m_cast_target
The target data type.
Definition: item_json_func.h:993
Represents the JSON function JSON_LENGTH()
Definition: item_json_func.h:472
enum_path_status
Enum that tells the status of a cell in m_paths.
Definition: item_json_func.h:90
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:312
Json_on_response_type m_on_error
Type of the ON ERROR clause.
Definition: item_json_func.h:987
bool returns_array() const override
Whether the item returns array of its data type.
Definition: item_json_func.h:873
const char * func_name() const override
Definition: item_json_func.h:794
A lightweight path expression.
Definition: json_path.h:438
Item_func_json_keys(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:518
Item_func_like * m_like_node
Definition: item_json_func.h:676
Json_path_clone m_path
Definition: item_json_func.h:601
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:767
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
longlong val_int() override
Definition: item_json_func.h:330
const char * func_name() const override
Definition: item_json_func.h:589
unique_ptr_destroy_only< const Json_schema_validator > m_cached_schema_validator
Definition: item_json_func.h:367
static void reset_cache()
Definition: xcom_cache.cc:228
Some integer typedefs for easier portability.
Represents the JSON function JSON_DEPTH()
Definition: item_json_func.h:500
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:1077
A class that is capable of holding objects of any sub-type of Json_scalar.
Definition: json_dom.h:1879
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:989
Class that represents the function JSON_STORAGE_SIZE.
Definition: item_json_func.h:825
Definition: field.h:694
String m_doc_value
Definition: item_json_func.h:501
String m_conversion_buffer
String used for converting JSON text values to utf8mb4 charset.
Definition: item_json_func.h:155
Represents the JSON function JSON_QUOTE()
Definition: item_json_func.h:758
Class that represents CAST(<expr> AS <type> ARRAY)
Definition: item_json_func.h:848
Definition: item_func.h:84
std::unique_ptr< Json_dom > Json_dom_ptr
Definition: item_json_func.h:1092
const char * func_name() const override
Definition: item_json_func.h:447
String m_doc_value
Definition: item_json_func.h:533
Definition: item.h:4495
Class implementing the JSON_VALUE function.
Definition: item_json_func.h:953
Item_func_json_overlaps(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:915
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:1094
Json_on_response_type m_on_empty
Type of the ON EMPTY clause.
Definition: item_json_func.h:985
Item_func_json_type(const POS &pos, Item *a)
Definition: item_json_func.h:445
double val_real() override
Definition: item_json_func.h:898
String m_doc_value
Definition: item_json_func.h:705
const char * cast_type() const
Definition: item_json_func.h:465
Item_result cast_to_int_type() const override
Definition: item_json_func.h:195
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
Represents the JSON function JSON_ARRAY_APPEND()
Definition: item_json_func.h:552
Definition: varlen_sort.h:182
const char * func_name() const override
Definition: item_json_func.h:840
Item_func_json_unquote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:789
Represents the JSON function JSON_REPLACE()
Definition: item_json_func.h:629
String m_doc_value
Definition: item_json_func.h:600
String m_value
String used when reading JSON binary values or JSON text values.
Definition: item_json_func.h:153
String m_doc_value
Definition: item_json_func.h:515
String m_value
Definition: item_json_func.h:759
const char * func_name() const override
Definition: item_json_func.h:353
uint32 max_char_length() const
Definition: item.h:2687
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:99
Json_path m_path_json
Parsed path.
Definition: item_json_func.h:980
Represents a "CAST( <value> AS JSON )" coercion.
Definition: item_json_func.h:457
Prealloced_array< size_t, 16 > Sorted_index_array
Definition: item_json_func.h:1097
Item_json_func(THD *thd, Args &&... parent_args)
Construct an Item_json_func instance.
Definition: item_json_func.h:175
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
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:796
String m_string_buffer
String used for converting a JSON value to text in val_str().
Definition: item_json_func.h:157
#define MAX_BLOB_WIDTH
Default width for blob.
Definition: mysql_com.h:856
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:164
Definition: item_json_func.h:69
const char * func_name() const override
Definition: item_json_func.h:812
Represents the JSON function JSON_MERGE_PATCH.
Definition: item_json_func.h:745
Mem_root_array< Path_cell > m_arg_idx_to_vector_idx
Map argument indexes to indexes into m_paths.
Definition: item_json_func.h:104
const char * func_name() const override
Definition: item_json_func.h:381
unique_ptr_destroy_only< const Json_schema_validator > m_cached_schema_validator
Definition: item_json_func.h:340
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:398
Item_func_json_merge_patch(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:747
enum_one_or_all_type
For use by JSON_CONTAINS_PATH() and JSON_SEARCH()
Definition: item_json_func.h:66
String m_value
Definition: item_json_func.h:301
Definition: table.h:1313
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
Common definition between mysql server & client.
bool get_time(MYSQL_TIME *) override
Definition: item_json_func.h:906
const char * func_name() const override
Definition: item_json_func.h:647
Represents a JSON array container, i.e.
Definition: json_dom.h:519
Base class for all item functions that a return JSON value.
Definition: item_json_func.h:147
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:251
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:920
Definition: item_cmpfunc.h:290
#define DBUG_ASSERT(A)
Definition: my_dbug.h:199
const char * func_name() const override
Definition: item_json_func.h:662
bool is_deprecated() const override
Definition: item_json_func.h:739
Item_func_json_search(Args &&... parent_args)
Construct a JSON_SEARCH() node.
Definition: item_json_func.h:685
type_conversion_status
Status when storing a value in a field or converting from one datatype to another.
Definition: field.h:199
Item_func_json_depth(const POS &pos, Item *a)
Definition: item_json_func.h:504
String m_doc_value
Definition: item_json_func.h:553
char * pos
Definition: do_ctype.cc:76
Item_func_json_merge_preserve(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:723
Item * key_item() const override
Definition: item_json_func.h:939
Bison "location" class.
Definition: parse_location.h:43
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:390
const char * func_name() const override
Definition: item_json_func.h:829
Item_func_json_storage_size(const POS &pos, Item *a)
Definition: item_json_func.h:827
Represents the JSON function JSON_CONTAINS_PATH()
Definition: item_json_func.h:406
const char * func_name() const override
Definition: item_json_func.h:623
const char * func_name() const override
Definition: item_json_func.h:932
Definition: item_json_func.cc:4161
Json_path_cache m_path_cache
Definition: item_json_func.h:375
String m_doc_value
Definition: item_json_func.h:568
const char * func_name() const override
Definition: item_json_func.h:765
Json_path_cache m_path_cache
Definition: item_json_func.h:476
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:768
Item_func_json_length(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:479
Item_func_json_quote(const POS &pos, PT_item_list *a)
Definition: item_json_func.h:762
my_decimal class limits &#39;decimal_t&#39; type to what we need in MySQL.
Definition: my_decimal.h:91
const bool m_json_set
True if this is JSON_SET, false if it is JSON_REPLACE.
Definition: item_json_func.h:599
Definition: item_cmpfunc.h:2215
const char * func_name() const override
Definition: item_json_func.h:464
Functype
Definition: item_func.h:122
Item_func_json_pretty(const POS &pos, Item *a)
Definition: item_json_func.h:810
double
Definition: udf_registration_types.h:42
Represents the JSON function JSON_OBJECT()
Definition: item_json_func.h:655
Definition: item_json_func.h:68
Item_func_json_unquote(const POS &pos, Item *a)
Definition: item_json_func.h:792
static char * path
Definition: mysqldump.cc:131
bool is_bool_func() const override
Definition: item_json_func.h:308
Item_func_member_of(const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:930
uint16_t uint16
Definition: my_inttypes.h:64
Definition: item.h:741
unsigned int uint
Definition: uca-dump.cc:29
#define final(a, b, c)
Definition: hash.c:109
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:2301
#define true
Definition: config_static.h:44
long long int longlong
Definition: my_inttypes.h:54
const char * func_name() const override
Definition: item_json_func.h:574
Definition: item_strfunc.h:71
Item_func_json_contains_path(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:414
Item_string * m_source_string_item
Definition: item_json_func.h:675
uint32_t uint32
Definition: my_inttypes.h:66
Item_func_json_set_replace(bool json_set, Args &&... parent_args)
Definition: item_json_func.h:606
Item_typecast_json(THD *thd, const POS &pos, Item *a)
Definition: item_json_func.h:459
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:602
Definition: item_json_func.h:67
Represents the JSON function JSON_REMOVE()
Definition: item_json_func.h:704
Definition: item_func.h:837
Cast_target cast_type
Type to cast to.
Definition: item_json_func.h:850
Definition: m_ctype.h:359
uint8_t uint8
Definition: my_inttypes.h:62
String m_doc_value
Definition: item_json_func.h:671
Item_func_json_contains(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:378
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:389
Item_func_json_extract(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:536
Represents the JSON function JSON_SCHEMA_VALIDATION_REPORT( <json schema>, <json doc> ) ...
Definition: item_json_func.h:347
Item_func_json_array(Args &&... parent_args)
Definition: item_json_func.h:644
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:934
Prealloced_array< Json_path, 8 > m_paths
List of paths.
Definition: item_json_func.h:87
my_decimal * val_decimal(my_decimal *) override
Definition: item_json_func.h:894
Definition: item_json_func.h:928
Definition: parser_yystype.h:86
const char * func_name() const override
Definition: item_json_func.h:713
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:1645
virtual bool can_use_in_partial_update() const
Can this function type be used in partial update?
Definition: item_json_func.h:149
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:4049
Json_on_response_type
Types of ON EMPTY/ON ERROR clauses for JSON_TABLE and JSON_VALUE.
Definition: table_function.h:189
String m_path_value
Holder for path strings.
Definition: item_json_func.h:84
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:408
void allow_array_cast() override
A helper funciton to ensure proper usage of CAST(.
Definition: item_json_func.h:881
const char * func_name() const override
Definition: item_json_func.h:917
Represents the JSON function JSON_TYPE.
Definition: item_json_func.h:441
Item_func_json_length(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:482
bool is_bool_func() const override
Definition: item_json_func.h:421
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:79
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:82
const char * func_name() const override
Definition: item_json_func.h:559
Path cache for JSON functions.
Definition: item_json_func.h:81
Represents the JSON function JSON_INSERT()
Definition: item_json_func.h:567
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:181
Definition: mysql_time.h:81
String m_doc_value
Definition: item_json_func.h:473
Represents the JSON function JSON_ARRAY()
Definition: item_json_func.h:641
Definition: item_json_func.h:70
Represents the JSON function JSON_SCHEMA_VALID( <json schema>, <json doc> )
Definition: item_json_func.h:321
Item_func_json_storage_free(const POS &pos, Item *a)
Definition: item_json_func.h:838
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:935
Item_func_json_extract(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:539
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:672
Represents the JSON_PRETTY function.
Definition: item_json_func.h:808
const char * func_name() const override
Definition: item_json_func.h:490
bool get_date(MYSQL_TIME *, my_time_flags_t) override
Definition: item_json_func.h:902
const char * func_name() const override
Definition: item_json_func.h:726
Item_func_json_array_append(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:556
Represents the JSON function JSON_MERGE.
Definition: item_json_func.h:735
Json_schema_validator is an object that contains a JSON Schema that can be re-used multiple times...
Definition: json_schema.h:126
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:384
const char * func_name() const override
Definition: item_json_func.h:326
void get_date(char *to, int flag, time_t date)
Store textual representation of date in a character array.
Definition: my_systime.cc:107
const char * func_name() const override
Definition: item_json_func.h:506
Item_func_json_remove(Args &&... parent_args)
Definition: item_json_func.h:710
CHARSET_INFO my_charset_utf8mb4_bin
Definition: ctype-utf8.cc:7832
Represents the JSON function JSON_MERGE_PRESERVE.
Definition: item_json_func.h:721
Represents the JSON function JSON_CONTAINS()
Definition: item_json_func.h:373
Time declarations shared between the server and client API: you should not add anything to this heade...
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:485
Represents the JSON function JSON_ARRAY_INSERT()
Definition: item_json_func.h:582
A field that stores a JSON value.
Definition: field.h:4038
const char * func_name() const override
Definition: item_json_func.h:419
const char * func_name() const override
Definition: item_json_func.h:962
A better implementation of the UNIX ctype(3) library.
String m_doc_value
Definition: item_json_func.h:407
Represents the JSON function JSON_KEYS()
Definition: item_json_func.h:514
Item_func_json_keys(THD *thd, const POS &pos, Item *a, Item *b)
Definition: item_json_func.h:521
Struct that points to a cell in m_paths and tells its status.
Definition: item_json_func.h:98
Item_func_json_array_insert(THD *thd, const POS &pos, PT_item_list *a)
Definition: item_json_func.h:586
const string value("\alue\)
Represents the JSON function JSON_SEARCH()
Definition: item_json_func.h:670
Interface for low level time utilities.
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:815
String * val_str(String *) override
Definition: item_json_func.h:890
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:991
const char * func_name() const override
Definition: item_json_func.h:635
const char * func_name() const override
Definition: item_json_func.h:524
Json_path_cache m_path_cache
Definition: item_json_func.h:411
optimize_type select_optimize(const THD *) override
Definition: item_json_func.h:383
const char * func_name() const override
Definition: item_json_func.h:871
static int flags[50]
Definition: hp_test1.cc:39
JSON DOM abstract base class.
Definition: json_dom.h:170
A JSON path expression.
Definition: json_path.h:351
Item_func_json_valid(const POS &pos, Item *a)
Definition: item_json_func.h:304
String m_doc_value
Definition: item_json_func.h:583
const char * func_name() const override
Definition: item_json_func.h:750
Definition: item_json_func.h:913
String tmp_key_value
Definition: item_json_func.h:656
bool can_use_in_partial_update() const override
Can this function type be used in partial update?
Definition: item_json_func.h:706
Represents the JSON function JSON_SET()
Definition: item_json_func.h:617
Json_path_cache m_path_cache
Definition: item_json_func.h:160
const char * func_name() const override
Definition: item_json_func.h:306
#define false
Definition: config_static.h:43
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:75
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:425
Item_func_json_set(Args &&... parent_args)
Definition: item_json_func.h:620
enum_one_or_all_type m_cached_ooa
Definition: item_json_func.h:408
Class that represents the function JSON_STORAGE_FREE.
Definition: item_json_func.h:836
This file contains interface support for the JSON path abstraction.
Cast_target
Definition: item_create.h:54
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:865
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_json_func.h:919
Common base class for JSON_SET() and JSON_REPLACE().
Definition: item_json_func.h:597
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_json_func.h:814
String m_doc_value
Definition: item_json_func.h:374
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:799
String m_value
Definition: item_json_func.h:442
Item_func_json_replace(Args &&... parent_args)
Definition: item_json_func.h:632
Represents the JSON function JSON_UNQUOTE()
Definition: item_json_func.h:785