MySQL  8.0.27
Source Code Documentation
item_geofunc.h
Go to the documentation of this file.
1 #ifndef ITEM_GEOFUNC_INCLUDED
2 #define ITEM_GEOFUNC_INCLUDED
3 
4 /* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is 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 <assert.h>
27 #include <sys/types.h>
28 
29 #include <cstddef>
30 #include <vector>
31 
32 #include "field_types.h" // MYSQL_TYPE_BLOB
33 
34 #include "my_inttypes.h"
35 #include "my_sys.h"
37 #include "mysql_com.h"
38 #include "mysqld_error.h"
39 #include "prealloced_array.h"
40 #include "sql/enum_query_type.h"
41 #include "sql/field.h"
42 #include "sql/gis/buffer_strategies.h" // gis::buffer_strategies
43 #include "sql/gis/srid.h"
44 #include "sql/parse_location.h" // POS
45 /* This file defines all spatial functions */
46 #include "sql/inplace_vector.h"
47 #include "sql/item.h"
48 #include "sql/item_cmpfunc.h" // Item_bool_func2
49 #include "sql/item_func.h"
50 #include "sql/item_json_func.h" // Item_json_func
51 #include "sql/item_strfunc.h" // Item_str_func
52 #include "sql/spatial.h" // gis_wkb_raw_free
53 #include "sql_string.h"
54 
55 class Json_array;
56 class Json_dom;
57 class Json_object;
58 class Json_wrapper;
59 class PT_item_list;
60 class THD;
61 struct Parse_context;
62 struct TABLE;
63 
64 enum class enum_json_type;
65 
66 namespace dd {
67 class Spatial_reference_system;
68 } // namespace dd
69 
70 namespace gis {
71 class Geometry;
72 class Point;
73 } // namespace gis
74 
75 /**
76  We have to hold result buffers in functions that return a GEOMETRY string,
77  because such a function's result geometry's buffer is directly used and
78  set to String result object. We have to release them properly manually
79  since they won't be released when the String result is destroyed.
80 */
83 
84  public:
86 
90  }
91 
93 
94  void forget_buffer(void *buf) {
95  if (bg_result_buf == buf) bg_result_buf = nullptr;
97  }
98 
99  /* Free intermediate result buffers accumulated during GIS calculation. */
103  itr != bg_results.end(); ++itr)
104  gis_wkb_raw_free(*itr);
105  bg_results.clear();
106  }
107 
108  // Free the final result buffer, should be called after the result used.
111  bg_result_buf = nullptr;
112  }
113 
114  void set_result_buffer(void *buf) {
115  bg_result_buf = buf;
117  }
118 
119  private:
120  /*
121  Hold data buffer of this set operation's final result geometry which is
122  freed next time val_str is called since it can be used by upper Item nodes.
123  */
125 
126  /*
127  Result buffers for intermediate set operation results, which are freed
128  before val_str returns.
129  */
131 };
132 
133 class Item_func_st_union;
134 
135 /**
136  A utility class to flatten any hierarchy of geometry collection into one
137  with no nested geometry collections. All components are stored separately
138  and all their data stored in this class, in order to easily manipulate them.
139  */
144  std::vector<Geometry *> m_geos;
147 
148  public:
149  typedef std::vector<Geometry *> Geometry_list;
150 
152 
153  bool is_comp_no_overlapped() const { return comp_no_overlapped; }
154 
156 
157  gis::srid_t get_srid() const { return m_srid; }
158 
159  void set_srid(gis::srid_t srid) { m_srid = srid; }
160 
161  bool fill(const Geometry *geo, bool break_multi_geom = false) {
162  return store_geometry(geo, break_multi_geom);
163  }
164 
165  const Geometry_list &get_geometries() const { return m_geos; }
166 
168 
169  bool all_isolated() const { return m_num_isolated == m_geos.size(); }
170 
171  size_t num_isolated() const { return m_num_isolated; }
172 
174  /**
175  Merge all components as appropriate so that the object contains only
176  components that don't overlap.
177 
178  @tparam Coordsys Coordinate system type, specified using those defined in
179  boost::geometry::cs.
180  @param[out] pnull_value takes back null_value set during the operation.
181  */
182  private:
183  bool store_geometry(const Geometry *geo, bool break_multi_geom);
184  Geometry *store(const Geometry *geo);
185 };
186 
188  public:
190 
193 
196  : Item_str_func(pos, a, b) {}
197 
198  Item_geometry_func(Item *a, Item *b, Item *c) : Item_str_func(a, b, c) {}
199  Item_geometry_func(const POS &pos, Item *a, Item *b, Item *c)
200  : Item_str_func(pos, a, b, c) {}
201  Item_geometry_func(const POS &pos, PT_item_list *list);
202 
203  bool resolve_type(THD *) override;
204  Field *tmp_table_field(TABLE *t_arg) override;
205 };
206 
208  public:
209  enum class Functype {
214  GEOMFROMTEXT,
215  LINEFROMTEXT,
224  POLYFROMTEXT,
226  };
227 
228  private:
231  /**
232  Get the type of geometry that this Item can return.
233 
234  @return The geometry type
235  */
237  /**
238  Check if a geometry type is a valid return type for this Item.
239 
240  @param type The type to check
241 
242  @retval true The geometry type is allowed
243  @retval false The geometry type is not allowed
244  */
246 
247  public:
252  : Item_geometry_func(pos, a, srid), m_functype(functype) {}
254  Item *option, Functype functype)
255  : Item_geometry_func(pos, a, srid, option), m_functype(functype) {}
256 
257  bool itemize(Parse_context *pc, Item **res) override;
258  const char *func_name() const override;
259  String *val_str(String *) override;
260  bool resolve_type(THD *thd) override {
261  if (param_type_is_default(thd, 0, 1)) return true;
262  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true;
263  if (param_type_is_default(thd, 2, 3)) return true;
265  }
266 };
267 
269  public:
270  enum class Functype {
274  GEOMFROMWKB,
275  LINEFROMWKB,
277  MLINEFROMWKB,
279  MPOLYFROMWKB,
283  POINTFROMWKB,
284  POLYFROMWKB,
286  };
287 
288  private:
292  /**
293  Get the type of geometry that this Item can return.
294 
295  @return The geometry type
296  */
298  /**
299  Check if a geometry type is a valid return type for this Item.
300 
301  @param type The type to check
302 
303  @retval true The geometry type is allowed
304  @retval false The geometry type is not allowed
305  */
307  bool resolve_type(THD *thd) override {
308  if (param_type_is_default(thd, 0, 1)) return true;
309  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true;
310  if (param_type_is_default(thd, 2, 3)) return true;
312  }
313 
314  public:
319  : Item_geometry_func(pos, a, srid), m_functype(functype) {}
320  Item_func_geometry_from_wkb(const POS &pos, Item *a, Item *srid, Item *option,
322  : Item_geometry_func(pos, a, srid, option), m_functype(functype) {}
323 
324  bool itemize(Parse_context *pc, Item **res) override;
325  const char *func_name() const override;
326  String *val_str(String *) override;
327 };
328 
330  public:
332  Item_func_as_wkt(const POS &pos, Item *a, Item *b)
333  : Item_str_ascii_func(pos, a, b) {}
334  const char *func_name() const override { return "st_astext"; }
335  String *val_str_ascii(String *) override;
336  bool resolve_type(THD *) override;
337 };
338 
340  public:
342  Item_func_as_wkb(const POS &pos, Item *a, Item *b)
343  : Item_geometry_func(pos, a, b) {}
344  const char *func_name() const override { return "st_aswkb"; }
345  String *val_str(String *) override;
346  bool resolve_type(THD *thd) override {
347  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
348  if (param_type_is_default(thd, 1, 2)) return true;
349  if (Item_geometry_func::resolve_type(thd)) return true;
351  return false;
352  }
353 };
354 
356  public:
358  : Item_str_ascii_func(pos, a) {}
359  String *val_str_ascii(String *) override;
360  const char *func_name() const override { return "st_geometrytype"; }
361  bool resolve_type(THD *thd) override {
362  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
363  // "MultiLinestring" is the longest
365  set_nullable(true);
366  return false;
367  }
368 };
369 
370 /**
371  This handles one function:
372 
373  @<geometry@> = ST_GEOMFROMGEOJSON(@<string@>[, @<options@>[, @<srid@>]])
374 
375  Options is an integer argument which determines how positions with higher
376  coordinate dimension than MySQL support should be handled. The function will
377  accept both single objects, geometry collections and feature objects and
378  collections. All "properties" members of GeoJSON feature objects is ignored.
379 
380  The implementation conforms with GeoJSON revision 1.0 described at
381  http://geojson.org/geojson-spec.html.
382 */
384  public:
385  /**
386  Describing how coordinate dimensions higher than supported in MySQL
387  should be handled.
388  */
394  };
395  Item_func_geomfromgeojson(const POS &pos, Item *json_string)
396  : Item_geometry_func(pos, json_string),
398  m_user_provided_srid(false),
401  : Item_geometry_func(pos, json_string, options),
402  m_user_provided_srid(false),
405  Item *srid)
406  : Item_geometry_func(pos, json_string, options, srid),
408  String *val_str(String *) override;
409  bool fix_fields(THD *, Item **ref) override;
410  const char *func_name() const override { return "st_geomfromgeojson"; }
411  Geometry::wkbType get_wkbtype(const char *typestring);
412  bool get_positions(const Json_array *coordinates, Gis_point *point);
413  bool get_linestring(const Json_array *data_array,
414  Gis_line_string *linestring);
415  bool get_polygon(const Json_array *data_array, Gis_polygon *polygon);
416  bool parse_object(const Json_object *object, bool *rollback, String *buffer,
417  bool is_parent_featurecollection, Geometry **geometry);
419  bool *rollback, String *buffer,
420  bool is_parent_featurecollection,
421  Geometry **geometry);
422  static bool check_argument_valid_integer(Item *argument);
423  bool parse_crs_object(const Json_object *crs_object);
424  bool is_member_valid(const Json_dom *member, const char *member_name,
425  enum_json_type expected_type, bool allow_null,
426  bool *was_null);
427  const Json_dom *my_find_member_ncase(const Json_object *object,
428  const char *member_name);
429 
430  static const char *TYPE_MEMBER;
431  static const char *CRS_MEMBER;
432  static const char *GEOMETRY_MEMBER;
433  static const char *PROPERTIES_MEMBER;
434  static const char *FEATURES_MEMBER;
435  static const char *GEOMETRIES_MEMBER;
436  static const char *COORDINATES_MEMBER;
437  static const char *CRS_NAME_MEMBER;
438  static const char *NAMED_CRS;
439  static const char *SHORT_EPSG_PREFIX;
440  static const char *LONG_EPSG_PREFIX;
441  static const char *CRS84_URN;
442  static const char *POINT_TYPE;
443  static const char *MULTIPOINT_TYPE;
444  static const char *LINESTRING_TYPE;
445  static const char *MULTILINESTRING_TYPE;
446  static const char *POLYGON_TYPE;
447  static const char *MULTIPOLYGON_TYPE;
448  static const char *GEOMETRYCOLLECTION_TYPE;
449  static const char *FEATURE_TYPE;
450  static const char *FEATURECOLLECTION_TYPE;
451 
452  private:
453  /**
454  How higher coordinate dimensions than currently supported should be handled.
455  */
457  /// Is set to true if user provided a SRID as an argument.
459  /// The SRID user provided as an argument.
461  /**
462  The SRID value of the document CRS, if one is found. Otherwise, this value
463  defaults to -1.
464  */
466  /// The minimum allowed longitude value (non-inclusive).
467  double m_min_longitude = -180.0;
468  /// The maximum allowed longitude (inclusive).
469  double m_max_longitude = 180.0;
470  /// The minimum allowed latitude value (inclusive).
471  double m_min_latitude = -90.0;
472  /// The maximum allowed latitude (inclusive).
473  double m_max_latitude = 90.0;
474  /// True if we're currently parsing the top-level object.
475  bool m_toplevel = true;
476 };
477 
478 /// Max width of long CRS URN supported + max width of SRID + '\0'.
479 static const int MAX_CRS_WIDTH = (22 + MAX_INT_WIDTH + 1);
480 
481 /**
482  This class handles the following function:
483 
484  @<json@> = ST_ASGEOJSON(@<geometry@>[, @<maxdecimaldigits@>[, @<options@>]])
485 
486  It converts a GEOMETRY into a valid GeoJSON string. If maxdecimaldigits is
487  specified, the coordinates written are rounded to the number of decimals
488  specified (e.g with decimaldigits = 3: 10.12399 => 10.124).
489 
490  Options is a bitmask with the following flags:
491  0 No options (default values).
492  1 Add a bounding box to the output.
493  2 Add a short CRS URN to the output. The default format is a
494  short format ("EPSG:<srid>").
495  4 Add a long format CRS URN ("urn:ogc:def:crs:EPSG::<srid>"). This
496  implies 2. This means that, e.g., bitmask 5 and 7 mean the
497  same: add a bounding box and a long format CRS URN.
498 */
500  private:
501  /// Maximum number of decimal digits in printed coordinates.
503  /// If true, the output GeoJSON has a bounding box for each GEOMETRY.
505  /**
506  If true, the output GeoJSON has a CRS object in the short
507  form (e.g "EPSG:4326").
508  */
510  /**
511  If true, the output GeoJSON has a CRS object in the long
512  form (e.g "urn:ogc:def:crs:EPSG::4326").
513  */
515  /// The SRID found in the input GEOMETRY.
517 
518  public:
519  Item_func_as_geojson(THD *thd, const POS &pos, Item *geometry)
520  : Item_json_func(thd, pos, geometry),
521  m_add_bounding_box(false),
522  m_add_short_crs_urn(false),
523  m_add_long_crs_urn(false) {}
524  Item_func_as_geojson(THD *thd, const POS &pos, Item *geometry,
525  Item *maxdecimaldigits)
526  : Item_json_func(thd, pos, geometry, maxdecimaldigits),
527  m_add_bounding_box(false),
528  m_add_short_crs_urn(false),
529  m_add_long_crs_urn(false) {}
530  Item_func_as_geojson(THD *thd, const POS &pos, Item *geometry,
531  Item *maxdecimaldigits, Item *options)
532  : Item_json_func(thd, pos, geometry, maxdecimaldigits, options),
533  m_add_bounding_box(false),
534  m_add_short_crs_urn(false),
535  m_add_long_crs_urn(false) {}
536  bool fix_fields(THD *thd, Item **ref) override;
537  bool val_json(Json_wrapper *wr) override;
538  const char *func_name() const override { return "st_asgeojson"; }
539  bool parse_options_argument();
541 };
542 
543 /**
544  This class handles two forms of the same function:
545 
546  @<string@> = ST_GEOHASH(@<point@>, @<maxlength@>);
547  @<string@> = ST_GEOHASH(@<longitude@>, @<latitude@>, @<maxlength@>)
548 
549  It returns an encoded geohash string, no longer than @<maxlength@> characters
550  long. Note that it might be shorter than @<maxlength@>.
551 */
553  private:
554  /// The latitude argument supplied by the user (directly or by a POINT).
555  double latitude;
556  /// The longitude argument supplied by the user (directly or by a POINT).
557  double longitude;
558  /// The maximum output length of the geohash, supplied by the user.
560 
561  /**
562  The maximum input latitude. For now, this is set to 90.0. It can be
563  changed to support a different range than the normal [90, -90].
564  */
565  const double max_latitude;
566 
567  /**
568  The minimum input latitude. For now, this is set to -90.0. It can be
569  changed to support a different range than the normal [90, -90].
570  */
571  const double min_latitude;
572 
573  /**
574  The maximum input longitude. For now, this is set to 180.0. It can be
575  changed to support a different range than the normal [180, -180].
576  */
577  const double max_longitude;
578 
579  /**
580  The minimum input longitude. For now, this is set to -180.0. It can be
581  changed to support a different range than the normal [180, -180].
582  */
583  const double min_longitude;
584 
585  /**
586  The absolute upper limit of geohash output length. User will get an error
587  if they supply a max geohash length argument greater than this.
588  */
590 
591  public:
593  : Item_str_ascii_func(pos, point, length),
594  max_latitude(90.0),
595  min_latitude(-90.0),
596  max_longitude(180.0),
597  min_longitude(-180.0),
600  Item *length)
602  max_latitude(90.0),
603  min_latitude(-90.0),
604  max_longitude(180.0),
605  min_longitude(-180.0),
607  String *val_str_ascii(String *) override;
608  bool resolve_type(THD *) override;
609  bool fix_fields(THD *thd, Item **ref) override;
610  const char *func_name() const override { return "st_geohash"; }
611  char char_to_base32(char char_input);
612  void encode_bit(double *upper_value, double *lower_value, double target_value,
613  char *char_value, int bit_number);
614  bool fill_and_check_fields();
616 };
617 
618 /**
619  This is a superclass for Item_func_longfromgeohash and
620  Item_func_latfromgeohash, since they share almost all code.
621 */
623  private:
624  /**
625  The lower limit for latitude output value. Normally, this will be
626  set to -90.0.
627  */
628  const double lower_latitude;
629 
630  /**
631  The upper limit for latitude output value. Normally, this will be
632  set to 90.0.
633  */
634  const double upper_latitude;
635 
636  /**
637  The lower limit for longitude output value. Normally, this will
638  be set to -180.0.
639  */
640  const double lower_longitude;
641 
642  /**
643  The upper limit for longitude output value. Normally, this will
644  be set to 180.0.
645  */
646  const double upper_longitude;
647 
648  /**
649  If this is set to true the algorithm will start decoding on the first bit,
650  which decodes a longitude value. If it is false, it will start on the
651  second bit which decodes a latitude value.
652  */
653  const bool start_on_even_bit;
654 
655  public:
657  double upper_latitude, double lower_longitude,
658  double upper_longitude,
659  bool start_on_even_bit_arg)
660  : Item_real_func(pos, a),
665  start_on_even_bit(start_on_even_bit_arg) {}
666  double val_real() override;
667  bool resolve_type(THD *thd) override;
668  bool fix_fields(THD *thd, Item **ref) override;
669  static bool decode_geohash(String *geohash, double upper_latitude,
670  double lower_latitude, double upper_longitude,
671  double lower_longitude, double *result_latitude,
672  double *result_longitude);
673  static double round_latlongitude(double latlongitude, double error_range,
674  double lower_limit, double upper_limit);
675  static bool check_geohash_argument_valid_type(Item *item);
676 };
677 
678 /**
679  This handles the @<double@> = ST_LATFROMGEOHASH(@<string@>) function.
680  It returns the latitude-part of a geohash, in the range of [-90, 90].
681 */
683  public:
685  : Item_func_latlongfromgeohash(pos, a, -90.0, 90.0, -180.0, 180.0,
686  false) {}
687 
688  const char *func_name() const override { return "ST_LATFROMGEOHASH"; }
689 };
690 
691 /**
692  This handles the @<double@> = ST_LONGFROMGEOHASH(@<string@>) function.
693  It returns the longitude-part of a geohash, in the range of [-180, 180].
694 */
696  public:
698  : Item_func_latlongfromgeohash(pos, a, -90.0, 90.0, -180.0, 180.0, true) {
699  }
700 
701  const char *func_name() const override { return "ST_LONGFROMGEOHASH"; }
702 };
703 
706 
707  template <typename Coordsys>
708  bool bg_centroid(const Geometry *geom, String *ptwkb);
709 
710  public:
712  const char *func_name() const override { return "st_centroid"; }
713  String *val_str(String *) override;
714  Field::geometry_type get_geometry_type() const override;
715  bool resolve_type(THD *thd) override {
716  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
718  }
719 };
720 
723 
724  template <typename Coordsys>
725  bool bg_convex_hull(const Geometry *geom, String *wkb);
726 
727  public:
729  const char *func_name() const override { return "st_convexhull"; }
730  String *val_str(String *) override;
731  Field::geometry_type get_geometry_type() const override;
732  bool resolve_type(THD *thd) override {
733  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
735  }
736 };
737 
739  public:
741  const char *func_name() const override { return "st_envelope"; }
742  String *val_str(String *) override;
743  Field::geometry_type get_geometry_type() const override;
744  bool resolve_type(THD *thd) override {
745  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
747  }
748 };
749 
751  public:
753  : Item_geometry_func(pos, a, b) {}
754  const char *func_name() const override { return "st_makeenvelope"; }
755  String *val_str(String *) override;
756  Field::geometry_type get_geometry_type() const override;
757  bool resolve_type(THD *thd) override {
758  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
760  }
761 };
762 
765 
766  public:
768  const char *func_name() const override { return "st_validate"; }
769  bool resolve_type(THD *thd) override {
770  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
772  }
773  String *val_str(String *) override;
774 };
775 
776 /// Item that implements function ST_Simplify, which simplifies a geometry using
777 /// the Douglas-Peucker algorithm.
779  public:
781  : Item_geometry_func(pos, a, b) {}
782  bool resolve_type(THD *thd) override {
783  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
784  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_DOUBLE)) return true;
786  }
787  String *val_str(String *) override;
788 
789  const char *func_name() const override { return "st_simplify"; }
790 };
791 
793  public:
794  Item_func_point(const POS &pos, Item *a, Item *b)
795  : Item_geometry_func(pos, a, b) {}
796  const char *func_name() const override { return "point"; }
797  String *val_str(String *) override;
798  Field::geometry_type get_geometry_type() const override;
799  bool resolve_type(THD *thd) override {
800  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_DOUBLE)) return true;
802  }
803 };
804 
805 /**
806  This handles the @<point@> = ST_POINTFROMGEOHASH(@<string@>, @<srid@>)
807  function.
808 
809  It returns a point containing the decoded geohash value, where X is the
810  longitude in the range of [-180, 180] and Y is the latitude in the range
811  of [-90, 90].
812 */
814  private:
815  /// The maximum output latitude value when decoding the geohash value.
816  const double upper_latitude;
817 
818  /// The minimum output latitude value when decoding the geohash value.
819  const double lower_latitude;
820 
821  /// The maximum output longitude value when decoding the geohash value.
822  const double upper_longitude;
823 
824  /// The minimum output longitude value when decoding the geohash value.
825  const double lower_longitude;
826 
827  public:
829  : Item_geometry_func(pos, a, b),
830  upper_latitude(90.0),
831  lower_latitude(-90.0),
832  upper_longitude(180.0),
833  lower_longitude(-180.0) {}
834  const char *func_name() const override { return "st_pointfromgeohash"; }
835  String *val_str(String *) override;
836  bool fix_fields(THD *thd, Item **ref) override;
837  bool resolve_type(THD *thd) override;
839  return Field::GEOM_POINT;
840  }
841 };
842 
844  enum Functype decomp_func;
845  bool resolve_type(THD *thd) override {
846  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
848  }
849 
850  public:
852  : Item_geometry_func(pos, a) {
853  decomp_func = ft;
854  }
855  const char *func_name() const override {
856  switch (decomp_func) {
857  case SP_STARTPOINT:
858  return "st_startpoint";
859  case SP_ENDPOINT:
860  return "st_endpoint";
861  case SP_EXTERIORRING:
862  return "st_exteriorring";
863  default:
864  assert(0); // Should never happened
865  return "spatial_decomp_unknown";
866  }
867  }
868  String *val_str(String *) override;
869 };
870 
872  enum Functype decomp_func_n;
873  bool resolve_type(THD *thd) override {
874  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
875  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true;
877  }
878 
879  public:
882  : Item_geometry_func(pos, a, b) {
883  decomp_func_n = ft;
884  }
885  const char *func_name() const override {
886  switch (decomp_func_n) {
887  case SP_POINTN:
888  return "st_pointn";
889  case SP_GEOMETRYN:
890  return "st_geometryn";
891  case SP_INTERIORRINGN:
892  return "st_interiorringn";
893  default:
894  assert(0); // Should never happened
895  return "spatial_decomp_n_unknown";
896  }
897  }
898  String *val_str(String *) override;
899 };
900 
905 
906  public:
908  enum Geometry::wkbType ct,
909  enum Geometry::wkbType it)
910  : Item_geometry_func(pos, list) {
911  coll_type = ct;
912  item_type = it;
913  }
914  String *val_str(String *) override;
915  bool resolve_type(THD *thd) override {
916  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
917  if (Item_geometry_func::resolve_type(thd)) return true;
918  for (unsigned int i = 0; i < arg_count; ++i) {
919  if (args[i]->fixed && args[i]->data_type() != MYSQL_TYPE_GEOMETRY) {
920  String str;
921  args[i]->print(thd, &str, QT_NO_DATA_EXPANSION);
922  str.append('\0');
923  my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "non geometric", str.ptr());
924  return true;
925  }
926  }
927  return false;
928  }
929 
930  const char *func_name() const override;
931 };
932 
933 /*
934  Spatial relations
935 */
936 
938  enum Functype spatial_rel;
939 
940  public:
942  : Item_bool_func2(a, b) {
943  spatial_rel = sp_rel;
944  }
946  enum Functype sp_rel)
947  : Item_bool_func2(pos, a, b) {
948  spatial_rel = sp_rel;
949  }
950  longlong val_int() override;
951  enum Functype functype() const override { return spatial_rel; }
952  enum Functype rev_functype() const override {
953  switch (spatial_rel) {
954  case SP_CONTAINS_FUNC:
955  return SP_WITHIN_FUNC;
956  case SP_WITHIN_FUNC:
957  return SP_CONTAINS_FUNC;
958  default:
959  return spatial_rel;
960  }
961  }
962 
963  const char *func_name() const override;
964  void print(const THD *thd, String *str,
965  enum_query_type query_type) const override {
966  Item_func::print(thd, str, query_type);
967  }
968  bool resolve_type(THD *) override {
969  set_nullable(true);
970  return false;
971  }
972  bool is_null() override {
973  val_int();
974  return null_value;
975  }
976 };
977 
979  public:
981  : Item_bool_func2(pos, a, b) {}
982  bool resolve_type(THD *thd) override {
983  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
984  // Spatial relation functions may return NULL if either parameter is NULL or
985  // an empty geometry. Since we can't check for empty geometries at resolve
986  // time, this item is always nullable.
987  set_nullable(true);
988  return false;
989  }
990  void print(const THD *thd, String *str,
991  enum_query_type query_type) const override {
992  Item_func::print(thd, str, query_type);
993  }
994  longlong val_int() override;
995  bool is_null() override {
996  // The superclass implementation only checks is_null on the item's
997  // arguments. However, relational functions may return NULL even if the
998  // arguments are not NULL, e.g., if one or more argument is an empty
999  // geometry. Therefore, we must evaluate the item to find out if it is NULL
1000  // or not.
1001  val_int();
1002  return null_value;
1003  }
1004 
1005  /**
1006  Evaluate the spatial relation function.
1007 
1008  @param[in] srs Spatial reference system common to both g1 and g2.
1009  @param[in] g1 First geometry.
1010  @param[in] g2 Second geometry.
1011  @param[out] result Result of the relational operation.
1012  @param[out] null True if the function should return NULL, false otherwise.
1013 
1014  @retval true An error has occurred and has been reported with my_error.
1015  @retval false Success.
1016  */
1017  virtual bool eval(const dd::Spatial_reference_system *srs,
1018  const gis::Geometry *g1, const gis::Geometry *g2,
1019  bool *result, bool *null) = 0;
1020 };
1021 
1023  public:
1025  : Item_func_spatial_relation(pos, a, b) {}
1026  enum Functype functype() const override { return SP_CONTAINS_FUNC; }
1027  enum Functype rev_functype() const override { return SP_WITHIN_FUNC; }
1028  const char *func_name() const override { return "st_contains"; }
1029  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1030  const gis::Geometry *g2, bool *result, bool *null) override;
1031 };
1032 
1034  public:
1036  : Item_func_spatial_relation(pos, a, b) {}
1037  enum Functype functype() const override { return SP_CROSSES_FUNC; }
1038  enum Functype rev_functype() const override { return SP_CROSSES_FUNC; }
1039  const char *func_name() const override { return "st_crosses"; }
1040  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1041  const gis::Geometry *g2, bool *result, bool *null) override;
1042 };
1043 
1045  public:
1047  : Item_func_spatial_relation(pos, a, b) {}
1048  enum Functype functype() const override { return SP_DISJOINT_FUNC; }
1049  enum Functype rev_functype() const override { return SP_DISJOINT_FUNC; }
1050  const char *func_name() const override { return "st_disjoint"; }
1051  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1052  const gis::Geometry *g2, bool *result, bool *null) override;
1053 };
1054 
1056  public:
1058  : Item_func_spatial_relation(pos, a, b) {}
1059  enum Functype functype() const override { return SP_EQUALS_FUNC; }
1060  enum Functype rev_functype() const override { return SP_EQUALS_FUNC; }
1061  const char *func_name() const override { return "st_equals"; }
1062  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1063  const gis::Geometry *g2, bool *result, bool *null) override;
1064 };
1065 
1067  public:
1069  : Item_func_spatial_relation(pos, a, b) {}
1070  enum Functype functype() const override { return SP_INTERSECTS_FUNC; }
1071  enum Functype rev_functype() const override { return SP_INTERSECTS_FUNC; }
1072  const char *func_name() const override { return "st_intersects"; }
1073  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1074  const gis::Geometry *g2, bool *result, bool *null) override;
1075 };
1076 
1078  public:
1080  : Item_func_spatial_relation(pos, a, b) {}
1081  enum Functype functype() const override { return SP_CONTAINS_FUNC; }
1082  enum Functype rev_functype() const override { return SP_WITHIN_FUNC; }
1083  const char *func_name() const override { return "mbrcontains"; }
1084  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1085  const gis::Geometry *g2, bool *result, bool *null) override;
1086 };
1087 
1089  public:
1091  : Item_func_spatial_relation(pos, a, b) {}
1092  enum Functype functype() const override { return SP_COVEREDBY_FUNC; }
1093  enum Functype rev_functype() const override { return SP_COVERS_FUNC; }
1094  const char *func_name() const override { return "mbrcoveredby"; }
1095  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1096  const gis::Geometry *g2, bool *result, bool *null) override;
1097 };
1098 
1100  public:
1102  : Item_func_spatial_relation(pos, a, b) {}
1103  enum Functype functype() const override { return SP_COVERS_FUNC; }
1104  enum Functype rev_functype() const override { return SP_COVEREDBY_FUNC; }
1105  const char *func_name() const override { return "mbrcovers"; }
1106  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1107  const gis::Geometry *g2, bool *result, bool *null) override;
1108 };
1109 
1111  public:
1113  : Item_func_spatial_relation(pos, a, b) {}
1114  enum Functype functype() const override { return SP_DISJOINT_FUNC; }
1115  enum Functype rev_functype() const override { return SP_DISJOINT_FUNC; }
1116  const char *func_name() const override { return "mbrdisjoint"; }
1117  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1118  const gis::Geometry *g2, bool *result, bool *null) override;
1119 };
1120 
1122  public:
1124  : Item_func_spatial_relation(pos, a, b) {}
1125  enum Functype functype() const override { return SP_EQUALS_FUNC; }
1126  enum Functype rev_functype() const override { return SP_EQUALS_FUNC; }
1127  const char *func_name() const override { return "mbrequals"; }
1128  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1129  const gis::Geometry *g2, bool *result, bool *null) override;
1130 };
1131 
1133  public:
1135  : Item_func_spatial_relation(pos, a, b) {}
1136  enum Functype functype() const override { return SP_INTERSECTS_FUNC; }
1137  enum Functype rev_functype() const override { return SP_INTERSECTS_FUNC; }
1138  const char *func_name() const override { return "mbrintersects"; }
1139  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1140  const gis::Geometry *g2, bool *result, bool *null) override;
1141 };
1142 
1144  public:
1146  : Item_func_spatial_relation(pos, a, b) {}
1147  enum Functype functype() const override { return SP_OVERLAPS_FUNC; }
1148  enum Functype rev_functype() const override { return SP_OVERLAPS_FUNC; }
1149  const char *func_name() const override { return "mbroverlaps"; }
1150  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1151  const gis::Geometry *g2, bool *result, bool *null) override;
1152 };
1153 
1155  public:
1157  : Item_func_spatial_relation(pos, a, b) {}
1158  enum Functype functype() const override { return SP_TOUCHES_FUNC; }
1159  enum Functype rev_functype() const override { return SP_TOUCHES_FUNC; }
1160  const char *func_name() const override { return "mbrtouches"; }
1161  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1162  const gis::Geometry *g2, bool *result, bool *null) override;
1163 };
1164 
1166  public:
1168  : Item_func_spatial_relation(pos, a, b) {}
1169  enum Functype functype() const override { return SP_WITHIN_FUNC; }
1170  enum Functype rev_functype() const override { return SP_CONTAINS_FUNC; }
1171  const char *func_name() const override { return "mbrwithin"; }
1172  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1173  const gis::Geometry *g2, bool *result, bool *null) override;
1174 };
1175 
1177  public:
1179  : Item_func_spatial_relation(pos, a, b) {}
1180  enum Functype functype() const override { return SP_OVERLAPS_FUNC; }
1181  enum Functype rev_functype() const override { return SP_OVERLAPS_FUNC; }
1182  const char *func_name() const override { return "st_overlaps"; }
1183  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1184  const gis::Geometry *g2, bool *result, bool *null) override;
1185 };
1186 
1188  public:
1190  : Item_func_spatial_relation(pos, a, b) {}
1191  enum Functype functype() const override { return SP_TOUCHES_FUNC; }
1192  enum Functype rev_functype() const override { return SP_TOUCHES_FUNC; }
1193  const char *func_name() const override { return "st_touches"; }
1194  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1195  const gis::Geometry *g2, bool *result, bool *null) override;
1196 };
1197 
1199  public:
1201  : Item_func_spatial_relation(pos, a, b) {}
1202  enum Functype functype() const override { return SP_WITHIN_FUNC; }
1203  enum Functype rev_functype() const override { return SP_CONTAINS_FUNC; }
1204  const char *func_name() const override { return "st_within"; }
1205  bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1,
1206  const gis::Geometry *g2, bool *result, bool *null) override;
1207 };
1208 
1209 /**
1210  Spatial operations
1211 */
1213  protected:
1215  : Item_geometry_func(pos, a, b) {}
1216 
1217  private:
1218  bool resolve_type(THD *thd) override {
1219  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1221  }
1222 };
1223 
1225  public:
1227  : Item_func_spatial_operation(pos, a, b) {}
1228  String *val_str(String *) override;
1229  const char *func_name() const override { return "st_difference"; }
1230 };
1231 
1233  public:
1235  : Item_func_spatial_operation(pos, a, b) {}
1236  String *val_str(String *) override;
1237  const char *func_name() const override { return "st_intersection"; }
1238 };
1239 
1241  public:
1243  : Item_func_spatial_operation(pos, a, b) {}
1244  String *val_str(String *) override;
1245  const char *func_name() const override { return "st_symdifference"; }
1246 };
1247 
1249  public:
1251  : Item_func_spatial_operation(pos, a, b) {}
1252  String *val_str(String *) override;
1253  const char *func_name() const override { return "st_union"; }
1254 };
1255 
1257  public:
1258  /*
1259  There are five types of buffer strategies, this is an enumeration of them.
1260  */
1266  // The two below are not parameterized.
1269  };
1270 
1271  /*
1272  For each type of strategy listed above, there are several options/values
1273  for it, this is an enumeration of all such options/values for all types of
1274  strategies.
1275  */
1285 
1286  // Distance and side strategies are fixed, so no need to implement
1287  // parameterization for them.
1288  };
1289 
1290  /*
1291  A piece of strategy setting. User can specify 0 to 3 different strategy
1292  settings in any order to ST_Buffer(), which must be of different
1293  strategy types. Default strategies are used if not explicitly specified.
1294  */
1297  // This field is only effective for end_round, join_round, join_mit,
1298  // and point_circle.
1299  double value;
1300  };
1301 
1302  private:
1306  /*
1307  end_xxx stored in settings[end_strategy];
1308  join_xxx stored in settings[join_strategy];
1309  point_xxx stored in settings[point_strategy].
1310  */
1312  String tmp_value; // Stores current buffer result.
1314  void set_strategies();
1315  bool resolve_type(THD *thd) override {
1316  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1317  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_DOUBLE)) return true;
1318  if (param_type_is_default(thd, 2, -1)) return true;
1320  }
1321 
1322  public:
1323  Item_func_buffer(const POS &pos, PT_item_list *ilist);
1324  const char *func_name() const override { return "st_buffer"; }
1325 };
1326 
1328  private:
1329  friend class Item_func_buffer;
1331  char tmp_buffer[16]; // The buffer for tmp_value.
1332  public:
1334  const char *func_name() const override { return "st_buffer_strategy"; }
1335  String *val_str(String *) override;
1336  bool resolve_type(THD *thd) override;
1337 };
1338 
1340  public:
1342  longlong val_int() override;
1343  optimize_type select_optimize(const THD *) override { return OPTIMIZE_NONE; }
1344  const char *func_name() const override { return "st_isempty"; }
1345  bool resolve_type(THD *thd) override {
1346  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1347  set_nullable(true);
1348  return false;
1349  }
1350 };
1351 
1353  public:
1355  longlong val_int() override;
1356  const char *func_name() const override { return "st_issimple"; }
1357  bool resolve_type(THD *thd) override {
1358  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1359  return Item_bool_func::resolve_type(thd);
1360  }
1361 };
1362 
1364  public:
1366  longlong val_int() override;
1367  optimize_type select_optimize(const THD *) override { return OPTIMIZE_NONE; }
1368  const char *func_name() const override { return "st_isclosed"; }
1369  bool resolve_type(THD *thd) override {
1370  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1371  set_nullable(true);
1372  return false;
1373  }
1374 };
1375 
1377  public:
1379  longlong val_int() override;
1380  optimize_type select_optimize(const THD *) override { return OPTIMIZE_NONE; }
1381  const char *func_name() const override { return "st_isvalid"; }
1382  bool resolve_type(THD *thd) override {
1383  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1384  return Item_bool_func::resolve_type(thd);
1385  }
1386 };
1387 
1390 
1391  public:
1393  longlong val_int() override;
1394  const char *func_name() const override { return "st_dimension"; }
1395  bool resolve_type(THD *thd) override {
1396  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1397  max_length = 10;
1398  set_nullable(true);
1399  return false;
1400  }
1401 };
1402 
1403 /// The abstract superclass for all geometry coordinate mutator functions (ST_X,
1404 /// ST_Y, ST_Latitude and ST_Longitude with two parameters).
1405 ///
1406 /// @see Item_func_coordinate_observer
1408  public:
1410  bool geographic_only)
1411  : Item_geometry_func(pos, a, b), m_geographic_only(geographic_only) {}
1412  String *val_str(String *) override;
1413 
1414  protected:
1415  const char *func_name() const override = 0;
1416  /// Returns the coordinate number accessed by this item.
1417  ///
1418  /// @param[in] srs The spatial reference system of the point.
1419  ///
1420  /// @return The coordinate number to access.
1421  virtual int coordinate_number(
1422  const dd::Spatial_reference_system *srs) const = 0;
1423  bool resolve_type(THD *thd) override {
1424  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1425  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_DOUBLE)) return true;
1427  }
1428 
1429  private:
1430  /// Whether this item will accept only geographic geometries/SRSs.
1432 };
1433 
1434 /// The abstract superclass for all geometry coordinate oberserver functions
1435 /// (ST_X, ST_Y, ST_Latitude, ST_Longitude with one parameter).
1436 ///
1437 /// @see Item_func_coordinate_mutator
1439  public:
1440  Item_func_coordinate_observer(const POS &pos, Item *a, bool geographic_only)
1441  : Item_real_func(pos, a), m_geographic_only(geographic_only) {}
1442  double val_real() override;
1443 
1444  protected:
1445  const char *func_name() const override = 0;
1446  /// Returns the coordinate number accessed by this item.
1447  ///
1448  /// @param[in] srs The spatial reference system of the point.
1449  ///
1450  /// @return The coordinate number to access.
1451  virtual int coordinate_number(
1452  const dd::Spatial_reference_system *srs) const = 0;
1453  bool resolve_type(THD *thd) override {
1454  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1455  return Item_real_func::resolve_type(thd);
1456  }
1457 
1458  private:
1459  /// Whether this item will accept only geographic geometries/SRSs.
1461 };
1462 
1463 /// This class implements the two-parameter ST_Latitude function which sets the
1464 /// latitude of a geographic point.
1466  : public Item_func_coordinate_mutator {
1467  public:
1469  : Item_func_coordinate_mutator(pos, a, b, true) {}
1470 
1471  protected:
1472  const char *func_name() const override { return "st_latitude"; }
1473  int coordinate_number(const dd::Spatial_reference_system *) const override {
1474  return 1;
1475  }
1476 };
1477 
1478 /// This class implements the one-parameter ST_Latitude function which returns
1479 /// the latitude coordinate of a geographic point.
1482  public:
1484  : Item_func_coordinate_observer(pos, a, true) {}
1485 
1486  protected:
1487  const char *func_name() const override { return "st_latitude"; }
1488  int coordinate_number(const dd::Spatial_reference_system *) const override {
1489  return 1;
1490  }
1491 };
1492 
1493 /// This class implements the two-parameter ST_Longitude function which sets the
1494 /// longitude coordinate of a point.
1496  : public Item_func_coordinate_mutator {
1497  public:
1499  : Item_func_coordinate_mutator(pos, a, b, true) {}
1500 
1501  protected:
1502  const char *func_name() const override { return "st_longitude"; }
1503  int coordinate_number(const dd::Spatial_reference_system *) const override {
1504  return 0;
1505  }
1506 };
1507 
1508 /// This class implements the one-parameter ST_Longitude function which returns
1509 /// the longitude coordinate of a geographic point.
1512  public:
1514  : Item_func_coordinate_observer(pos, a, true) {}
1515 
1516  protected:
1517  const char *func_name() const override { return "st_longitude"; }
1518  int coordinate_number(const dd::Spatial_reference_system *) const override {
1519  return 0;
1520  }
1521 };
1522 
1523 /// This class implements the two-parameter ST_X function which sets the X
1524 /// coordinate of a point.
1526  public:
1528  : Item_func_coordinate_mutator(pos, a, b, false) {}
1529 
1530  protected:
1531  const char *func_name() const override { return "st_x"; }
1532  int coordinate_number(const dd::Spatial_reference_system *srs) const override;
1533 };
1534 
1535 /// This class implements the one-parameter ST_X function which returns the X
1536 /// coordinate of a point.
1538  public:
1540  : Item_func_coordinate_observer(pos, a, false) {}
1541 
1542  protected:
1543  const char *func_name() const override { return "st_x"; }
1544  int coordinate_number(const dd::Spatial_reference_system *srs) const override;
1545 };
1546 
1547 /// This class implements the two-parameter ST_Y function which sets the Y
1548 /// coordinate of a point.
1550  public:
1552  : Item_func_coordinate_mutator(pos, a, b, false) {}
1553 
1554  protected:
1555  const char *func_name() const override { return "st_y"; }
1556  int coordinate_number(const dd::Spatial_reference_system *srs) const override;
1557 };
1558 
1559 /// This class implements the one-parameter ST_Y function which returns the Y
1560 /// coordinate of a point.
1562  public:
1564  : Item_func_coordinate_observer(pos, a, false) {}
1565 
1566  protected:
1567  const char *func_name() const override { return "st_y"; }
1568  int coordinate_number(const dd::Spatial_reference_system *srs) const override;
1569 };
1570 
1572  bool resolve_type(THD *thd) override {
1573  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1575  }
1576 
1577  public:
1579  const char *func_name() const override { return "st_swapxy"; }
1580  String *val_str(String *) override;
1581 };
1582 
1585 
1586  public:
1588  longlong val_int() override;
1589  const char *func_name() const override { return "st_numgeometries"; }
1590  bool resolve_type(THD *thd) override {
1591  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1592  max_length = 10;
1593  set_nullable(true);
1594  return false;
1595  }
1596 };
1597 
1600 
1601  public:
1603  longlong val_int() override;
1604  const char *func_name() const override { return "st_numinteriorrings"; }
1605  bool resolve_type(THD *thd) override {
1606  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1607  max_length = 10;
1608  set_nullable(true);
1609  return false;
1610  }
1611 };
1612 
1615 
1616  public:
1618  longlong val_int() override;
1619  const char *func_name() const override { return "st_numpoints"; }
1620  bool resolve_type(THD *thd) override {
1621  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1622  max_length = 10;
1623  set_nullable(true);
1624  return false;
1625  }
1626 };
1627 
1629  public:
1631  double val_real() override;
1632  const char *func_name() const override { return "st_area"; }
1633  bool resolve_type(THD *thd) override {
1634  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1635  // ST_Area returns NULL if the geometry is empty.
1636  set_nullable(true);
1637  return false;
1638  }
1639 };
1640 
1642  public:
1643  /// Parses strategy stored in String object, and sets values in strats.
1644  bool parse_strategy(String *arg, gis::BufferStrategies &strats);
1645 
1647  : Item_geometry_func(pos, ilist) {}
1648 
1649  String *val_str(String *) override;
1650  const char *func_name() const override { return "st_buffer"; }
1651  bool resolve_type(THD *thd) override {
1652  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1653  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_DOUBLE)) return true;
1654  if (param_type_is_default(thd, 2, -1))
1655  return true; // Does nothing with the strategy args
1657  }
1658 };
1659 
1662 
1663  public:
1665  : Item_real_func(pos, ilist) {}
1666  double val_real() override;
1667  const char *func_name() const override { return "st_length"; }
1668  bool resolve_type(THD *thd) override {
1669  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1670  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1671  if (Item_real_func::resolve_type(thd)) return true;
1672  set_nullable(true);
1673  return false;
1674  }
1675 };
1676 
1677 /// This class implements the two-parameter ST_SRID function which sets
1678 /// the SRID of a geometry.
1680  public:
1682  : Item_geometry_func(pos, a, b) {}
1683  String *val_str(String *) override;
1684  const char *func_name() const override { return "st_srid"; }
1685  bool resolve_type(THD *thd) override {
1686  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1687  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true;
1689  }
1690 };
1691 
1692 /// This class implements the one-parameter ST_SRID function which
1693 /// returns the SRID of a geometry.
1695  public:
1697  longlong val_int() override;
1698  const char *func_name() const override { return "st_srid"; }
1699  bool resolve_type(THD *thd) override {
1700  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1701  bool error = Item_int_func::resolve_type(thd);
1702  max_length = 10;
1703  return error;
1704  }
1705 };
1706 
1708  double geometry_collection_distance(const Geometry *g1, const Geometry *g2);
1709 
1710  template <typename Coordsys, typename BG_geometry>
1711  double distance_dispatch_second_geometry(const BG_geometry &bg1,
1712  const Geometry *g2);
1713 
1714  public:
1715  template <typename Coordsys>
1716  double bg_distance(const Geometry *g1, const Geometry *g2);
1717 
1719  : Item_real_func(pos, ilist) {
1720  /*
1721  Either operand can be an empty geometry collection, and it's meaningless
1722  for a distance between them.
1723  */
1724  set_nullable(true);
1725  }
1726 
1727  bool resolve_type(THD *thd) override {
1728  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_GEOMETRY)) return true;
1729  set_nullable(true);
1730  return false;
1731  }
1732 
1733  double val_real() override;
1734  const char *func_name() const override { return "st_distance"; }
1735 };
1736 
1738  public:
1740  : Item_real_func(pos, ilist) {}
1741  double val_real() override;
1742  const char *func_name() const override { return "st_frechetdistance"; }
1743  bool resolve_type(THD *thd) override {
1745  if (Item_real_func::resolve_type(thd)) return true;
1746  set_nullable(true);
1747  return false;
1748  }
1749 };
1750 
1752  public:
1754  : Item_real_func(pos, ilist) {}
1755  double val_real() override;
1756  const char *func_name() const override { return "st_hausdorffdistance"; }
1757  bool resolve_type(THD *thd) override {
1759  if (Item_real_func::resolve_type(thd)) return true;
1760  set_nullable(true);
1761  return false;
1762  }
1763 };
1764 
1766  public:
1768  : Item_real_func(pos, ilist) {}
1769  double val_real() override;
1770  const char *func_name() const override { return "st_distance_sphere"; }
1771  bool resolve_type(THD *thd) override {
1772  if (param_type_is_default(thd, 0, 2, MYSQL_TYPE_GEOMETRY)) return true;
1773  if (param_type_is_default(thd, 2, 3, MYSQL_TYPE_DOUBLE)) return true;
1774  return Item_real_func::resolve_type(thd);
1775  }
1776 };
1777 
1778 // The abstract superclass for interpolating point(s) along a line.
1780  public:
1782  : Item_geometry_func(pos, a, b) {}
1783  String *val_str(String *str) override;
1784 
1785  protected:
1786  virtual bool isFractionalDistance() const = 0;
1787  virtual bool returnMultiplePoints() const = 0;
1788  bool resolve_type(THD *thd) override {
1789  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_GEOMETRY)) return true;
1790  if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_DOUBLE)) return true;
1792  }
1793 };
1794 
1796  public:
1798  : Item_func_lineinterpolate(pos, a, b) {}
1799 
1800  protected:
1801  const char *func_name() const override { return "st_lineinterpolatepoint"; }
1802  bool isFractionalDistance() const override { return true; }
1803  bool returnMultiplePoints() const override { return false; }
1804 };
1805 
1807  public:
1809  : Item_func_lineinterpolate(pos, a, b) {}
1810 
1811  protected:
1812  const char *func_name() const override { return "st_lineinterpolatepoints"; }
1813  bool isFractionalDistance() const override { return true; }
1814  bool returnMultiplePoints() const override { return true; }
1815 };
1816 
1818  public:
1820  : Item_func_lineinterpolate(pos, a, b) {}
1821 
1822  protected:
1823  const char *func_name() const override { return "st_pointatdistance"; }
1824  bool isFractionalDistance() const override { return false; }
1825  bool returnMultiplePoints() const override { return false; }
1826 };
1827 
1828 /// This class implements ST_Transform function that transforms a geometry from
1829 /// one SRS to another.
1831  public:
1833  : Item_geometry_func(pos, a, b) {}
1834  String *val_str(String *str) override;
1835 
1836  private:
1837  const char *func_name() const override { return "st_transform"; }
1838 };
1839 
1840 // This is an abstract class that is inherited by geometry cast items.
1842  public:
1844  : Item_geometry_func(pos, a) {}
1845  String *val_str(String *str) override;
1846  void print(const THD *thd, String *str,
1847  enum_query_type query_type) const override = 0;
1848  const char *func_name() const override = 0;
1849  enum Functype functype() const override { return TYPECAST_FUNC; }
1851  bool resolve_type(THD *thd) override {
1854  }
1855 
1856  /// Casts certain geometry types to certain target geometry types.
1857  ///
1858  /// @param[in] srs The srs of the geometry being cast.
1859  /// @param[in] source_geometry The geometry being cast.
1860  /// @param[out] target_geometry The result geometry of the cast.
1861  ///
1862  /// @retval false Success.
1863  /// @retval true An error has occurred. The error has been reported with
1864  /// my_error().
1865 
1866  virtual bool cast(const dd::Spatial_reference_system *srs,
1867  std::unique_ptr<gis::Geometry> *source_geometry,
1868  std::unique_ptr<gis::Geometry> *target_geometry) const = 0;
1869 };
1870 
1871 // This class implements CAST from certain geometries to POINT type.
1873  public:
1875  : Item_typecast_geometry(pos, a) {}
1876  void print(const THD *thd, String *str,
1877  enum_query_type query_type) const override;
1878  const char *func_name() const override { return "cast_as_point"; }
1879  Field::geometry_type get_geometry_type() const override;
1880  bool cast(const dd::Spatial_reference_system *,
1881  std::unique_ptr<gis::Geometry> *source_geometry,
1882  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1883 };
1884 
1885 // This class implements CAST from certain geometries to LINESTRING type.
1887  public:
1889  : Item_typecast_geometry(pos, a) {}
1890  void print(const THD *thd, String *str,
1891  enum_query_type query_type) const override;
1892  const char *func_name() const override { return "cast_as_linestring"; }
1893  Field::geometry_type get_geometry_type() const override;
1894  bool cast(const dd::Spatial_reference_system *,
1895  std::unique_ptr<gis::Geometry> *source_geometry,
1896  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1897 };
1898 
1899 // This class implements CAST from certain geometries to POLYGON type.
1901  public:
1903  : Item_typecast_geometry(pos, a) {}
1904  void print(const THD *thd, String *str,
1905  enum_query_type query_type) const override;
1906  const char *func_name() const override { return "cast_as_polygon"; }
1907  Field::geometry_type get_geometry_type() const override;
1908  bool cast(const dd::Spatial_reference_system *srs,
1909  std::unique_ptr<gis::Geometry> *source_geometry,
1910  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1911 };
1912 
1913 // This class implements CAST from certain geometries to MULTIPOINT type.
1915  public:
1917  : Item_typecast_geometry(pos, a) {}
1918  void print(const THD *thd, String *str,
1919  enum_query_type query_type) const override;
1920  const char *func_name() const override { return "cast_as_multipoint"; }
1921  Field::geometry_type get_geometry_type() const override;
1922  bool cast(const dd::Spatial_reference_system *,
1923  std::unique_ptr<gis::Geometry> *source_geometry,
1924  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1925 };
1926 
1927 // This class implements CAST from certain geometries to MULTILINESTRING type.
1929  public:
1931  : Item_typecast_geometry(pos, a) {}
1932  void print(const THD *thd, String *str,
1933  enum_query_type query_type) const override;
1934  const char *func_name() const override { return "cast_as_multilinestring"; }
1935  Field::geometry_type get_geometry_type() const override;
1936  bool cast(const dd::Spatial_reference_system *,
1937  std::unique_ptr<gis::Geometry> *source_geometry,
1938  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1939 };
1940 
1941 // This class implements CAST from certain geometries to MULTIPOLYGON type.
1943  public:
1945  : Item_typecast_geometry(pos, a) {}
1946  void print(const THD *thd, String *str,
1947  enum_query_type query_type) const override;
1948  const char *func_name() const override { return "cast_as_multipolygon"; }
1949  Field::geometry_type get_geometry_type() const override;
1950  bool cast(const dd::Spatial_reference_system *srs,
1951  std::unique_ptr<gis::Geometry> *source_geometry,
1952  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1953 };
1954 
1955 // This class implements CAST from certain geometries to GEOMETRYCOLLECTION
1956 // type.
1958  public:
1960  : Item_typecast_geometry(pos, a) {}
1961  void print(const THD *thd, String *str,
1962  enum_query_type query_type) const override;
1963  const char *func_name() const override {
1964  return "cast_as_geometrycollection";
1965  }
1966  Field::geometry_type get_geometry_type() const override;
1967  bool cast(const dd::Spatial_reference_system *,
1968  std::unique_ptr<gis::Geometry> *source_geometry,
1969  std::unique_ptr<gis::Geometry> *target_geometry) const override;
1970 };
1971 
1972 #endif /*ITEM_GEOFUNC_INCLUDED*/
This file implements a struct that is used to hold information that decide how to compute the buffer ...
A utility class to flatten any hierarchy of geometry collection into one with no nested geometry coll...
Definition: item_geofunc.h:140
void set_comp_no_overlapped(bool b)
Definition: item_geofunc.h:155
size_t m_num_isolated
Definition: item_geofunc.h:143
const Geometry_list & get_geometries() const
Definition: item_geofunc.h:165
std::vector< Geometry * > Geometry_list
Definition: item_geofunc.h:149
gis::srid_t get_srid() const
Definition: item_geofunc.h:157
gis::srid_t m_srid
Definition: item_geofunc.h:142
Geometry * store(const Geometry *geo)
Store a geometry of GEOMETRY format into this collection.
Definition: item_geofunc.cc:4627
Inplace_vector< String > m_geosdata
Definition: item_geofunc.h:146
bool fill(const Geometry *geo, bool break_multi_geom=false)
Definition: item_geofunc.h:161
bool store_geometry(const Geometry *geo, bool break_multi_geom)
Merge all components as appropriate so that the object contains only components that don't overlap.
Definition: item_geofunc.cc:4569
size_t num_isolated() const
Definition: item_geofunc.h:171
bool comp_no_overlapped
Definition: item_geofunc.h:141
BG_geometry_collection()
Definition: item_geofunc.cc:4530
bool is_comp_no_overlapped() const
Definition: item_geofunc.h:153
std::vector< Geometry * > m_geos
Definition: item_geofunc.h:144
Inplace_vector< Geometry_buffer > m_geobufs
Definition: item_geofunc.h:145
Geometry_list & get_geometries()
Definition: item_geofunc.h:167
Gis_geometry_collection * as_geometry_collection(String *geodata) const
Convert this into a Gis_geometry_collection object.
Definition: item_geofunc.cc:4542
bool all_isolated() const
Definition: item_geofunc.h:169
void set_srid(gis::srid_t srid)
Definition: item_geofunc.h:159
We have to hold result buffers in functions that return a GEOMETRY string, because such a function's ...
Definition: item_geofunc.h:81
~BG_result_buf_mgr()
Definition: item_geofunc.h:87
void add_buffer(void *buf)
Definition: item_geofunc.h:92
void * bg_result_buf
Definition: item_geofunc.h:124
void set_result_buffer(void *buf)
Definition: item_geofunc.h:114
BG_result_buf_mgr()
Definition: item_geofunc.h:85
void free_intermediate_result_buffers()
Definition: item_geofunc.h:100
void forget_buffer(void *buf)
Definition: item_geofunc.h:94
Prealloced_buffers bg_results
Definition: item_geofunc.h:130
void free_result_buffer()
Definition: item_geofunc.h:109
Prealloced_array< void *, 64 > Prealloced_buffers
Definition: item_geofunc.h:82
Definition: field.h:590
static constexpr size_t MAX_LONG_BLOB_WIDTH
Definition: field.h:752
geometry_type
Definition: field.h:733
@ GEOM_POINT
Definition: field.h:735
Definition: spatial.h:214
wkbType
Definition: spatial.h:291
Definition: spatial.h:2404
Definition: spatial.h:2094
Definition: spatial.h:1147
Definition: spatial.h:2182
Base class for functions that usually take two arguments, which are possibly strings,...
Definition: item_cmpfunc.h:621
Definition: item_cmpfunc.h:287
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.h:321
This class handles the following function:
Definition: item_geofunc.h:499
bool val_json(Json_wrapper *wr) override
Create a GeoJSON object, according to GeoJSON specification revision 1.0.
Definition: item_geofunc.cc:2360
Item_func_as_geojson(THD *thd, const POS &pos, Item *geometry, Item *maxdecimaldigits)
Definition: item_geofunc.h:524
bool m_add_short_crs_urn
If true, the output GeoJSON has a CRS object in the short form (e.g "EPSG:4326").
Definition: item_geofunc.h:509
bool parse_maxdecimaldigits_argument()
Parse the value in maxdecimaldigits argument.
Definition: item_geofunc.cc:2450
Item_func_as_geojson(THD *thd, const POS &pos, Item *geometry, Item *maxdecimaldigits, Item *options)
Definition: item_geofunc.h:530
int m_max_decimal_digits
Maximum number of decimal digits in printed coordinates.
Definition: item_geofunc.h:502
bool m_add_bounding_box
If true, the output GeoJSON has a bounding box for each GEOMETRY.
Definition: item_geofunc.h:504
Item_func_as_geojson(THD *thd, const POS &pos, Item *geometry)
Definition: item_geofunc.h:519
bool parse_options_argument()
Parse the value in options argument.
Definition: item_geofunc.cc:2413
uint32 m_geometry_srid
The SRID found in the input GEOMETRY.
Definition: item_geofunc.h:516
bool fix_fields(THD *thd, Item **ref) override
Perform type checking on all arguments.
Definition: item_geofunc.cc:2483
const char * func_name() const override
Definition: item_geofunc.h:538
bool m_add_long_crs_urn
If true, the output GeoJSON has a CRS object in the long form (e.g "urn:ogc:def:crs:EPSG::4326").
Definition: item_geofunc.h:514
Definition: item_geofunc.h:339
Item_func_as_wkb(const POS &pos, Item *a)
Definition: item_geofunc.h:341
const char * func_name() const override
Definition: item_geofunc.h:344
String * val_str(String *) override
Definition: item_geofunc.cc:3253
Item_func_as_wkb(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:342
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:346
Definition: item_geofunc.h:329
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.cc:3244
const char * func_name() const override
Definition: item_geofunc.h:334
String * val_str_ascii(String *) override
Definition: item_geofunc.cc:3134
Item_func_as_wkt(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:332
Item_func_as_wkt(const POS &pos, Item *a)
Definition: item_geofunc.h:331
Definition: item_geofunc.h:1327
char tmp_buffer[16]
Definition: item_geofunc.h:1331
const char * func_name() const override
Definition: item_geofunc.h:1334
String tmp_value
Definition: item_geofunc.h:1330
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc_buffer.cc:178
String * val_str(String *) override
Definition: item_geofunc_buffer.cc:186
Item_func_buffer_strategy(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc_buffer.cc:170
Definition: item_geofunc.h:1256
String tmp_value
Definition: item_geofunc.h:1312
String * strategies[side_strategy+1]
Definition: item_geofunc.h:1305
BG_result_buf_mgr bg_resbuf_mgr
Definition: item_geofunc.h:1303
void set_strategies()
Definition: item_geofunc_buffer.cc:118
enum_buffer_strategies
Definition: item_geofunc.h:1276
@ max_strategy
Definition: item_geofunc.h:1284
@ end_round
Definition: item_geofunc.h:1278
@ point_circle
Definition: item_geofunc.h:1282
@ join_round
Definition: item_geofunc.h:1280
@ point_square
Definition: item_geofunc.h:1283
@ join_miter
Definition: item_geofunc.h:1281
@ invalid_strategy
Definition: item_geofunc.h:1277
@ end_flat
Definition: item_geofunc.h:1279
String m_tmp_geombuf
Definition: item_geofunc.h:1313
const char * func_name() const override
Definition: item_geofunc.h:1324
Item_func_buffer(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc_buffer.cc:341
enum_buffer_strategy_types
Definition: item_geofunc.h:1261
@ join_strategy
Definition: item_geofunc.h:1264
@ point_strategy
Definition: item_geofunc.h:1265
@ invalid_strategy_type
Definition: item_geofunc.h:1262
@ end_strategy
Definition: item_geofunc.h:1263
@ distance_strategy
Definition: item_geofunc.h:1267
@ side_strategy
Definition: item_geofunc.h:1268
int num_strats
Definition: item_geofunc.h:1304
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1315
Definition: item_geofunc.h:704
const char * func_name() const override
Definition: item_geofunc.h:712
bool bg_centroid(const Geometry *geom, String *ptwkb)
Definition: item_geofunc.cc:3824
String * val_str(String *) override
Definition: item_geofunc.cc:3607
Item_func_centroid(const POS &pos, Item *a)
Definition: item_geofunc.h:711
BG_result_buf_mgr bg_resbuf_mgr
Definition: item_geofunc.h:705
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:715
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:3603
Definition: item_geofunc.h:721
BG_result_buf_mgr bg_resbuf_mgr
Definition: item_geofunc.h:722
bool bg_convex_hull(const Geometry *geom, String *wkb)
Definition: item_geofunc.cc:3930
const char * func_name() const override
Definition: item_geofunc.h:729
String * val_str(String *) override
Definition: item_geofunc.cc:3894
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:732
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:3890
Item_func_convex_hull(const POS &pos, Item *a)
Definition: item_geofunc.h:728
The abstract superclass for all geometry coordinate mutator functions (ST_X, ST_Y,...
Definition: item_geofunc.h:1407
virtual int coordinate_number(const dd::Spatial_reference_system *srs) const =0
Returns the coordinate number accessed by this item.
Item_func_coordinate_mutator(const POS &pos, Item *a, Item *b, bool geographic_only)
Definition: item_geofunc.h:1409
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1423
bool m_geographic_only
Whether this item will accept only geographic geometries/SRSs.
Definition: item_geofunc.h:1431
const char * func_name() const override=0
String * val_str(String *) override
Definition: item_geofunc.cc:4920
The abstract superclass for all geometry coordinate oberserver functions (ST_X, ST_Y,...
Definition: item_geofunc.h:1438
double val_real() override
Definition: item_geofunc.cc:4992
bool m_geographic_only
Whether this item will accept only geographic geometries/SRSs.
Definition: item_geofunc.h:1460
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1453
Item_func_coordinate_observer(const POS &pos, Item *a, bool geographic_only)
Definition: item_geofunc.h:1440
virtual int coordinate_number(const dd::Spatial_reference_system *srs) const =0
Returns the coordinate number accessed by this item.
const char * func_name() const override=0
Definition: item_geofunc.h:1388
String value
Definition: item_geofunc.h:1389
longlong val_int() override
Definition: item_geofunc.cc:4844
Item_func_dimension(const POS &pos, Item *a)
Definition: item_geofunc.h:1392
const char * func_name() const override
Definition: item_geofunc.h:1394
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1395
Definition: item_geofunc.h:1707
double val_real() override
Definition: item_geofunc.cc:5667
double geometry_collection_distance(const Geometry *g1, const Geometry *g2)
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1727
const char * func_name() const override
Definition: item_geofunc.h:1734
double bg_distance(const Geometry *g1, const Geometry *g2)
double distance_dispatch_second_geometry(const BG_geometry &bg1, const Geometry *g2)
Item_func_distance(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc.h:1718
Definition: item_geofunc.h:738
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:744
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:3566
String * val_str(String *) override
Definition: item_geofunc.cc:3570
Item_func_envelope(const POS &pos, Item *a)
Definition: item_geofunc.h:740
const char * func_name() const override
Definition: item_geofunc.h:741
This class handles two forms of the same function:
Definition: item_geofunc.h:552
char char_to_base32(char char_input)
Converts a char value to it's base32 representation, where 0 = a, 1 = b, ...
Definition: item_geofunc.cc:2861
uint geohash_max_output_length
The maximum output length of the geohash, supplied by the user.
Definition: item_geofunc.h:559
Item_func_geohash(const POS &pos, Item *longitude, Item *latitude, Item *length)
Definition: item_geofunc.h:599
String * val_str_ascii(String *) override
Encodes a pair of longitude and latitude values into a geohash string.
Definition: item_geofunc.cc:2668
double longitude
The longitude argument supplied by the user (directly or by a POINT).
Definition: item_geofunc.h:557
bool fill_and_check_fields()
Populate member variables with values from arguments.
Definition: item_geofunc.cc:2576
const double min_latitude
The minimum input latitude.
Definition: item_geofunc.h:571
bool fix_fields(THD *thd, Item **ref) override
Here we check for valid types.
Definition: item_geofunc.cc:2735
void encode_bit(double *upper_value, double *lower_value, double target_value, char *char_value, int bit_number)
Sets the bit number in char_value, determined by following formula:
Definition: item_geofunc.cc:2836
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.cc:2725
bool check_valid_latlong_type(Item *ref)
Checks if supplied item is a valid latitude or longitude, based on which type it is.
Definition: item_geofunc.cc:2526
const char * func_name() const override
Definition: item_geofunc.h:610
const uint upper_limit_output_length
The absolute upper limit of geohash output length.
Definition: item_geofunc.h:589
const double min_longitude
The minimum input longitude.
Definition: item_geofunc.h:583
double latitude
The latitude argument supplied by the user (directly or by a POINT).
Definition: item_geofunc.h:555
const double max_latitude
The maximum input latitude.
Definition: item_geofunc.h:565
const double max_longitude
The maximum input longitude.
Definition: item_geofunc.h:577
Item_func_geohash(const POS &pos, Item *point, Item *length)
Definition: item_geofunc.h:592
Definition: item_geofunc.h:207
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:260
Item_func_geometry_from_text(const POS &pos, Item *a, Item *srid, Item *option, Functype functype)
Definition: item_geofunc.h:253
Functype
Definition: item_geofunc.h:209
Functype m_functype
Definition: item_geofunc.h:230
Item_func_geometry_from_text(const POS &pos, Item *a, Functype functype)
Definition: item_geofunc.h:248
Geometry::wkbType allowed_wkb_type() const
Get the type of geometry that this Item can return.
Definition: item_geofunc.cc:362
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_geofunc.cc:313
String * val_str(String *) override
Parses a WKT string to produce a geometry encoded with an SRID prepending its WKB bytes,...
Definition: item_geofunc.cc:420
const char * func_name() const override
Definition: item_geofunc.cc:322
Item_geometry_func super
Definition: item_geofunc.h:229
bool is_allowed_wkb_type(Geometry::wkbType type) const
Check if a geometry type is a valid return type for this Item.
Definition: item_geofunc.cc:394
Item_func_geometry_from_text(const POS &pos, Item *a, Item *srid, Functype functype)
Definition: item_geofunc.h:250
Definition: item_geofunc.h:268
Item_geometry_func super
Definition: item_geofunc.h:289
Functype
Definition: item_geofunc.h:270
Item_func_geometry_from_wkb(const POS &pos, Item *a, Item *srid, Item *option, Functype functype)
Definition: item_geofunc.h:320
Item_func_geometry_from_wkb(const POS &pos, Item *a, Item *srid, Functype functype)
Definition: item_geofunc.h:317
String tmp_value
Definition: item_geofunc.h:290
Functype m_functype
Definition: item_geofunc.h:291
String * val_str(String *) override
Parses a WKB string to produce a geometry encoded with an SRID prepending its WKB bytes,...
Definition: item_geofunc.cc:677
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_geofunc.cc:573
Item_func_geometry_from_wkb(const POS &pos, Item *a, Functype functype)
Definition: item_geofunc.h:315
const char * func_name() const override
Definition: item_geofunc.cc:582
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:307
Geometry::wkbType allowed_wkb_type() const
Get the type of geometry that this Item can return.
Definition: item_geofunc.cc:620
bool is_allowed_wkb_type(Geometry::wkbType type) const
Check if a geometry type is a valid return type for this Item.
Definition: item_geofunc.cc:651
Definition: item_geofunc.h:355
Item_func_geometry_type(const POS &pos, Item *a)
Definition: item_geofunc.h:357
const char * func_name() const override
Definition: item_geofunc.h:360
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:361
String * val_str_ascii(String *) override
Definition: item_geofunc.cc:3360
This handles one function:
Definition: item_geofunc.h:383
bool m_toplevel
True if we're currently parsing the top-level object.
Definition: item_geofunc.h:475
static const char * TYPE_MEMBER
Definition of various string constants used for writing and reading GeoJSON data.
Definition: item_geofunc.h:430
static const char * FEATURECOLLECTION_TYPE
Definition: item_geofunc.h:450
bool parse_object(const Json_object *object, bool *rollback, String *buffer, bool is_parent_featurecollection, Geometry **geometry)
Takes a JSON object as input, and parses the data to a Geometry object.
Definition: item_geofunc.cc:1064
static const char * SHORT_EPSG_PREFIX
Definition: item_geofunc.h:439
static const char * CRS_NAME_MEMBER
Definition: item_geofunc.h:437
bool is_member_valid(const Json_dom *member, const char *member_name, enum_json_type expected_type, bool allow_null, bool *was_null)
Checks if a JSON member is valid based on input criteria.
Definition: item_geofunc.cc:1780
static const char * LINESTRING_TYPE
Definition: item_geofunc.h:444
bool parse_object_array(const Json_array *points, Geometry::wkbType type, bool *rollback, String *buffer, bool is_parent_featurecollection, Geometry **geometry)
Takes a JSON array as input, does a recursive parsing and returns a Geometry object.
Definition: item_geofunc.cc:1351
longlong m_srid_found_in_document
The SRID value of the document CRS, if one is found.
Definition: item_geofunc.h:465
double m_min_latitude
The minimum allowed latitude value (inclusive).
Definition: item_geofunc.h:471
static const char * MULTIPOLYGON_TYPE
Definition: item_geofunc.h:447
bool parse_crs_object(const Json_object *crs_object)
Takes a GeoJSON CRS object as input and parses it into a SRID.
Definition: item_geofunc.cc:1660
const Json_dom * my_find_member_ncase(const Json_object *object, const char *member_name)
Case insensitive lookup of a member in a JSON object.
Definition: item_geofunc.cc:1035
bool m_user_provided_srid
Is set to true if user provided a SRID as an argument.
Definition: item_geofunc.h:458
static const char * GEOMETRIES_MEMBER
Definition: item_geofunc.h:435
double m_min_longitude
The minimum allowed longitude value (non-inclusive).
Definition: item_geofunc.h:467
static const char * LONG_EPSG_PREFIX
Definition: item_geofunc.h:440
enum_handle_coordinate_dimension m_handle_coordinate_dimension
How higher coordinate dimensions than currently supported should be handled.
Definition: item_geofunc.h:456
static const char * COORDINATES_MEMBER
Definition: item_geofunc.h:436
static const char * FEATURE_TYPE
Definition: item_geofunc.h:449
String * val_str(String *) override
<geometry> = ST_GEOMFROMGEOJSON(<string>[, <options>[, <srid>]])
Definition: item_geofunc.cc:862
gis::srid_t m_user_srid
The SRID user provided as an argument.
Definition: item_geofunc.h:460
bool get_linestring(const Json_array *data_array, Gis_line_string *linestring)
Create a Gis_line_string from a JSON array.
Definition: item_geofunc.cc:1513
bool get_positions(const Json_array *coordinates, Gis_point *point)
Parse an array of coordinates to a Gis_point.
Definition: item_geofunc.cc:1251
const char * func_name() const override
Definition: item_geofunc.h:410
double m_max_longitude
The maximum allowed longitude (inclusive).
Definition: item_geofunc.h:469
double m_max_latitude
The maximum allowed latitude (inclusive).
Definition: item_geofunc.h:473
Item_func_geomfromgeojson(const POS &pos, Item *json_string, Item *options)
Definition: item_geofunc.h:400
static const char * CRS84_URN
Definition: item_geofunc.h:441
Geometry::wkbType get_wkbtype(const char *typestring)
Converts GeoJSON type string to a wkbType.
Definition: item_geofunc.cc:1623
static bool check_argument_valid_integer(Item *argument)
Checks if the supplied argument is a valid integer type.
Definition: item_geofunc.cc:1833
bool get_polygon(const Json_array *data_array, Gis_polygon *polygon)
Create a Gis_polygon from a JSON array.
Definition: item_geofunc.cc:1545
static const char * MULTIPOINT_TYPE
Definition: item_geofunc.h:443
Item_func_geomfromgeojson(const POS &pos, Item *json_string, Item *options, Item *srid)
Definition: item_geofunc.h:404
static const char * POINT_TYPE
Definition: item_geofunc.h:442
static const char * CRS_MEMBER
Definition: item_geofunc.h:431
bool fix_fields(THD *, Item **ref) override
Do type checking on all provided arguments.
Definition: item_geofunc.cc:1855
static const char * NAMED_CRS
Definition: item_geofunc.h:438
static const char * PROPERTIES_MEMBER
Definition: item_geofunc.h:433
Item_func_geomfromgeojson(const POS &pos, Item *json_string)
Definition: item_geofunc.h:395
static const char * GEOMETRYCOLLECTION_TYPE
Definition: item_geofunc.h:448
enum_handle_coordinate_dimension
Describing how coordinate dimensions higher than supported in MySQL should be handled.
Definition: item_geofunc.h:389
@ strip_now_reject_future
Definition: item_geofunc.h:392
@ reject_document
Definition: item_geofunc.h:390
@ strip_now_accept_future
Definition: item_geofunc.h:391
@ strip_now_strip_future
Definition: item_geofunc.h:393
static const char * FEATURES_MEMBER
Definition: item_geofunc.h:434
static const char * POLYGON_TYPE
Definition: item_geofunc.h:446
static const char * MULTILINESTRING_TYPE
Definition: item_geofunc.h:445
static const char * GEOMETRY_MEMBER
Definition: item_geofunc.h:432
Definition: item_geofunc.h:1363
longlong val_int() override
Definition: item_geofunc.cc:4781
Item_func_isclosed(const POS &pos, Item *a)
Definition: item_geofunc.h:1365
optimize_type select_optimize(const THD *) override
Definition: item_geofunc.h:1367
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1369
const char * func_name() const override
Definition: item_geofunc.h:1368
Definition: item_geofunc.h:1339
const char * func_name() const override
Definition: item_geofunc.h:1344
Item_func_isempty(const POS &pos, Item *a)
Definition: item_geofunc.h:1341
optimize_type select_optimize(const THD *) override
Definition: item_geofunc.h:1343
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1345
longlong val_int() override
Definition: item_geofunc.cc:4717
Definition: item_geofunc.h:1376
Item_func_isvalid(const POS &pos, Item *a)
Definition: item_geofunc.h:1378
optimize_type select_optimize(const THD *) override
Definition: item_geofunc.h:1380
const char * func_name() const override
Definition: item_geofunc.h:1381
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1382
longlong val_int() override
Definition: item_geofunc.cc:4803
This handles the <double> = ST_LATFROMGEOHASH(<string>) function.
Definition: item_geofunc.h:682
const char * func_name() const override
Definition: item_geofunc.h:688
Item_func_latfromgeohash(const POS &pos, Item *a)
Definition: item_geofunc.h:684
This is a superclass for Item_func_longfromgeohash and Item_func_latfromgeohash, since they share alm...
Definition: item_geofunc.h:622
const double lower_latitude
The lower limit for latitude output value.
Definition: item_geofunc.h:628
bool fix_fields(THD *thd, Item **ref) override
Definition: item_geofunc.cc:2882
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.cc:2876
Item_func_latlongfromgeohash(const POS &pos, Item *a, double lower_latitude, double upper_latitude, double lower_longitude, double upper_longitude, bool start_on_even_bit_arg)
Definition: item_geofunc.h:656
const bool start_on_even_bit
If this is set to true the algorithm will start decoding on the first bit, which decodes a longitude ...
Definition: item_geofunc.h:653
static bool decode_geohash(String *geohash, double upper_latitude, double lower_latitude, double upper_longitude, double lower_longitude, double *result_latitude, double *result_longitude)
Decodes a geohash string into longitude and latitude.
Definition: item_geofunc.cc:2947
const double upper_longitude
The upper limit for longitude output value.
Definition: item_geofunc.h:646
static double round_latlongitude(double latlongitude, double error_range, double lower_limit, double upper_limit)
Rounds a latitude or longitude value.
Definition: item_geofunc.cc:3061
static bool check_geohash_argument_valid_type(Item *item)
Checks if geohash arguments is of valid type.
Definition: item_geofunc.cc:2906
const double upper_latitude
The upper limit for latitude output value.
Definition: item_geofunc.h:634
const double lower_longitude
The lower limit for longitude output value.
Definition: item_geofunc.h:640
double val_real() override
Decodes a geohash into longitude if start_on_even_bit == true, or latitude if start_on_even_bit == fa...
Definition: item_geofunc.cc:3104
Definition: item_geofunc.h:1779
Item_func_lineinterpolate(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1781
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1788
String * val_str(String *str) override
Definition: item_geofunc.cc:5895
virtual bool returnMultiplePoints() const =0
virtual bool isFractionalDistance() const =0
Definition: item_geofunc.h:1795
bool isFractionalDistance() const override
Definition: item_geofunc.h:1802
Item_func_lineinterpolatepoint(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1797
const char * func_name() const override
Definition: item_geofunc.h:1801
bool returnMultiplePoints() const override
Definition: item_geofunc.h:1803
Definition: item_geofunc.h:1806
bool isFractionalDistance() const override
Definition: item_geofunc.h:1813
Item_func_lineinterpolatepoints(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1808
const char * func_name() const override
Definition: item_geofunc.h:1812
bool returnMultiplePoints() const override
Definition: item_geofunc.h:1814
This handles the <double> = ST_LONGFROMGEOHASH(<string>) function.
Definition: item_geofunc.h:695
Item_func_longfromgeohash(const POS &pos, Item *a)
Definition: item_geofunc.h:697
const char * func_name() const override
Definition: item_geofunc.h:701
Definition: item_geofunc.h:750
String * val_str(String *) override
Definition: item_geofunc.cc:3425
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:757
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:3421
const char * func_name() const override
Definition: item_geofunc.h:754
Item_func_make_envelope(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:752
Definition: item_geofunc.h:1077
Item_func_mbrcontains(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1079
const char * func_name() const override
Definition: item_geofunc.h:1083
enum Functype functype() const override
Definition: item_geofunc.h:1081
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:154
enum Functype rev_functype() const override
Definition: item_geofunc.h:1082
Definition: item_geofunc.h:1088
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:161
enum Functype rev_functype() const override
Definition: item_geofunc.h:1093
const char * func_name() const override
Definition: item_geofunc.h:1094
Item_func_mbrcoveredby(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1090
enum Functype functype() const override
Definition: item_geofunc.h:1092
Definition: item_geofunc.h:1099
enum Functype rev_functype() const override
Definition: item_geofunc.h:1104
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:168
Item_func_mbrcovers(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1101
enum Functype functype() const override
Definition: item_geofunc.h:1103
const char * func_name() const override
Definition: item_geofunc.h:1105
Definition: item_geofunc.h:1110
enum Functype functype() const override
Definition: item_geofunc.h:1114
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:174
const char * func_name() const override
Definition: item_geofunc.h:1116
Item_func_mbrdisjoint(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1112
enum Functype rev_functype() const override
Definition: item_geofunc.h:1115
Definition: item_geofunc.h:1121
Item_func_mbrequals(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1123
enum Functype functype() const override
Definition: item_geofunc.h:1125
enum Functype rev_functype() const override
Definition: item_geofunc.h:1126
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:181
const char * func_name() const override
Definition: item_geofunc.h:1127
Definition: item_geofunc.h:1132
const char * func_name() const override
Definition: item_geofunc.h:1138
enum Functype functype() const override
Definition: item_geofunc.h:1136
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:187
enum Functype rev_functype() const override
Definition: item_geofunc.h:1137
Item_func_mbrintersects(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1134
Definition: item_geofunc.h:1143
const char * func_name() const override
Definition: item_geofunc.h:1149
enum Functype functype() const override
Definition: item_geofunc.h:1147
Item_func_mbroverlaps(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1145
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:194
enum Functype rev_functype() const override
Definition: item_geofunc.h:1148
Definition: item_geofunc.h:1154
const char * func_name() const override
Definition: item_geofunc.h:1160
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:201
Item_func_mbrtouches(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1156
enum Functype functype() const override
Definition: item_geofunc.h:1158
enum Functype rev_functype() const override
Definition: item_geofunc.h:1159
Definition: item_geofunc.h:1165
Item_func_mbrwithin(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1167
enum Functype functype() const override
Definition: item_geofunc.h:1169
enum Functype rev_functype() const override
Definition: item_geofunc.h:1170
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:208
const char * func_name() const override
Definition: item_geofunc.h:1171
Definition: item_geofunc.h:1583
longlong val_int() override
Definition: item_geofunc.cc:4882
String value
Definition: item_geofunc.h:1584
Item_func_numgeometries(const POS &pos, Item *a)
Definition: item_geofunc.h:1587
const char * func_name() const override
Definition: item_geofunc.h:1589
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1590
Definition: item_geofunc.h:1598
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1605
Item_func_numinteriorring(const POS &pos, Item *a)
Definition: item_geofunc.h:1602
const char * func_name() const override
Definition: item_geofunc.h:1604
String value
Definition: item_geofunc.h:1599
longlong val_int() override
Definition: item_geofunc.cc:4863
Definition: item_geofunc.h:1613
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1620
const char * func_name() const override
Definition: item_geofunc.h:1619
longlong val_int() override
Definition: item_geofunc.cc:4901
String value
Definition: item_geofunc.h:1614
Item_func_numpoints(const POS &pos, Item *a)
Definition: item_geofunc.h:1617
Definition: item_geofunc.h:792
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:799
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:4212
String * val_str(String *) override
Definition: item_geofunc.cc:4216
const char * func_name() const override
Definition: item_geofunc.h:796
Item_func_point(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:794
This handles the <point> = ST_POINTFROMGEOHASH(<string>, <srid>) function.
Definition: item_geofunc.h:813
const double upper_latitude
The maximum output latitude value when decoding the geohash value.
Definition: item_geofunc.h:816
const double lower_longitude
The minimum output longitude value when decoding the geohash value.
Definition: item_geofunc.h:825
const double lower_latitude
The minimum output latitude value when decoding the geohash value.
Definition: item_geofunc.h:819
String * val_str(String *) override
Definition: item_geofunc.cc:4301
Item_func_pointfromgeohash(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:828
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.cc:4295
const double upper_longitude
The maximum output longitude value when decoding the geohash value.
Definition: item_geofunc.h:822
bool fix_fields(THD *thd, Item **ref) override
This will check if arguments passed (geohash and SRID) are of valid types.
Definition: item_geofunc.cc:4249
const char * func_name() const override
Definition: item_geofunc.h:834
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.h:838
Definition: item_geofunc.h:901
Item_func_spatial_collection(const POS &pos, PT_item_list *list, enum Geometry::wkbType ct, enum Geometry::wkbType it)
Definition: item_geofunc.h:907
enum Geometry::wkbType item_type
Definition: item_geofunc.h:904
String tmp_value
Definition: item_geofunc.h:902
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:915
enum Geometry::wkbType coll_type
Definition: item_geofunc.h:903
String * val_str(String *) override
Concatenates various items into various collections with checkings for valid wkb type of items.
Definition: item_geofunc.cc:4384
const char * func_name() const override
Definition: item_geofunc.cc:4344
Definition: item_geofunc.h:871
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:873
String * val_str(String *) override
Definition: item_geofunc.cc:4155
Item_func_spatial_decomp_n(const POS &pos, Item *a, Item *b, Item_func::Functype ft)
Definition: item_geofunc.h:880
const char * func_name() const override
Definition: item_geofunc.h:885
enum Functype decomp_func_n
Definition: item_geofunc.h:872
Definition: item_geofunc.h:843
const char * func_name() const override
Definition: item_geofunc.h:855
enum Functype decomp_func
Definition: item_geofunc.h:844
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:845
Item_func_spatial_decomp(const POS &pos, Item *a, Item_func::Functype ft)
Definition: item_geofunc.h:851
String * val_str(String *) override
Definition: item_geofunc.cc:4111
Definition: item_geofunc.h:937
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.h:964
enum Functype rev_functype() const override
Definition: item_geofunc.h:952
enum Functype spatial_rel
Definition: item_geofunc.h:938
enum Functype functype() const override
Definition: item_geofunc.h:951
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:968
Item_func_spatial_mbr_rel(Item *a, Item *b, enum Functype sp_rel)
Definition: item_geofunc.h:941
Item_func_spatial_mbr_rel(const POS &pos, Item *a, Item *b, enum Functype sp_rel)
Definition: item_geofunc.h:945
longlong val_int() override
const char * func_name() const override
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_geofunc.h:972
Spatial operations.
Definition: item_geofunc.h:1212
Item_func_spatial_operation(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1214
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1218
Definition: item_geofunc.h:978
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_geofunc.h:995
longlong val_int() override
Definition: item_geofunc_relchecks.cc:67
virtual bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null)=0
Evaluate the spatial relation function.
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.h:990
Item_func_spatial_relation(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:980
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:982
Definition: item_geofunc.h:1628
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1633
double val_real() override
Definition: item_geofunc.cc:5103
const char * func_name() const override
Definition: item_geofunc.h:1632
Item_func_st_area(const POS &pos, Item *a)
Definition: item_geofunc.h:1630
Definition: item_geofunc.h:1641
Item_func_st_buffer(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc.h:1646
String * val_str(String *) override
Definition: item_geofunc.cc:5154
bool parse_strategy(String *arg, gis::BufferStrategies &strats)
Parses strategy stored in String object, and sets values in strats.
Definition: item_geofunc.cc:5212
const char * func_name() const override
Definition: item_geofunc.h:1650
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1651
Definition: item_geofunc.h:1022
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:120
const char * func_name() const override
Definition: item_geofunc.h:1028
enum Functype rev_functype() const override
Definition: item_geofunc.h:1027
Item_func_st_contains(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1024
enum Functype functype() const override
Definition: item_geofunc.h:1026
Definition: item_geofunc.h:1033
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:127
enum Functype rev_functype() const override
Definition: item_geofunc.h:1038
const char * func_name() const override
Definition: item_geofunc.h:1039
enum Functype functype() const override
Definition: item_geofunc.h:1037
Item_func_st_crosses(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1035
Definition: item_geofunc.h:1224
String * val_str(String *) override
Definition: item_geofunc.cc:5602
const char * func_name() const override
Definition: item_geofunc.h:1229
Item_func_st_difference(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1226
Definition: item_geofunc.h:1044
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:134
const char * func_name() const override
Definition: item_geofunc.h:1050
enum Functype functype() const override
Definition: item_geofunc.h:1048
Item_func_st_disjoint(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1046
enum Functype rev_functype() const override
Definition: item_geofunc.h:1049
Definition: item_geofunc.h:1765
const char * func_name() const override
Definition: item_geofunc.h:1770
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1771
Item_func_st_distance_sphere(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc.h:1767
double val_real() override
Definition: item_geofunc.cc:5734
Definition: item_geofunc.h:1055
enum Functype rev_functype() const override
Definition: item_geofunc.h:1060
enum Functype functype() const override
Definition: item_geofunc.h:1059
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:141
Item_func_st_equals(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1057
const char * func_name() const override
Definition: item_geofunc.h:1061
Definition: item_geofunc.h:1737
Item_func_st_frechet_distance(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc.h:1739
const char * func_name() const override
Definition: item_geofunc.h:1742
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1743
double val_real() override
Definition: item_geofunc.cc:5474
Definition: item_geofunc.h:1751
Item_func_st_hausdorff_distance(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc.h:1753
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1757
double val_real() override
Definition: item_geofunc.cc:5538
const char * func_name() const override
Definition: item_geofunc.h:1756
Definition: item_geofunc.h:1232
String * val_str(String *) override
Definition: item_geofunc.cc:5831
const char * func_name() const override
Definition: item_geofunc.h:1237
Item_func_st_intersection(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1234
Definition: item_geofunc.h:1066
enum Functype functype() const override
Definition: item_geofunc.h:1070
enum Functype rev_functype() const override
Definition: item_geofunc.h:1071
const char * func_name() const override
Definition: item_geofunc.h:1072
Item_func_st_intersects(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1068
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:147
Definition: item_geofunc.h:1352
longlong val_int() override
Definition: item_geofunc.cc:4735
const char * func_name() const override
Definition: item_geofunc.h:1356
Item_func_st_issimple(const POS &pos, Item *a)
Definition: item_geofunc.h:1354
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1357
This class implements the two-parameter ST_Latitude function which sets the latitude of a geographic ...
Definition: item_geofunc.h:1466
Item_func_st_latitude_mutator(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1468
int coordinate_number(const dd::Spatial_reference_system *) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.h:1473
const char * func_name() const override
Definition: item_geofunc.h:1472
This class implements the one-parameter ST_Latitude function which returns the latitude coordinate of...
Definition: item_geofunc.h:1481
Item_func_st_latitude_observer(const POS &pos, Item *a)
Definition: item_geofunc.h:1483
const char * func_name() const override
Definition: item_geofunc.h:1487
int coordinate_number(const dd::Spatial_reference_system *) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.h:1488
Definition: item_geofunc.h:1660
String value
Definition: item_geofunc.h:1661
const char * func_name() const override
Definition: item_geofunc.h:1667
Item_func_st_length(const POS &pos, PT_item_list *ilist)
Definition: item_geofunc.h:1664
double val_real() override
Definition: item_geofunc.cc:5333
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1668
This class implements the two-parameter ST_Longitude function which sets the longitude coordinate of ...
Definition: item_geofunc.h:1496
Item_func_st_longitude_mutator(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1498
const char * func_name() const override
Definition: item_geofunc.h:1502
int coordinate_number(const dd::Spatial_reference_system *) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.h:1503
This class implements the one-parameter ST_Longitude function which returns the longitude coordinate ...
Definition: item_geofunc.h:1511
const char * func_name() const override
Definition: item_geofunc.h:1517
int coordinate_number(const dd::Spatial_reference_system *) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.h:1518
Item_func_st_longitude_observer(const POS &pos, Item *a)
Definition: item_geofunc.h:1513
Definition: item_geofunc.h:1176
Item_func_st_overlaps(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1178
enum Functype functype() const override
Definition: item_geofunc.h:1180
enum Functype rev_functype() const override
Definition: item_geofunc.h:1181
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:214
const char * func_name() const override
Definition: item_geofunc.h:1182
Definition: item_geofunc.h:1817
const char * func_name() const override
Definition: item_geofunc.h:1823
Item_func_st_pointatdistance(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1819
bool returnMultiplePoints() const override
Definition: item_geofunc.h:1825
bool isFractionalDistance() const override
Definition: item_geofunc.h:1824
Item that implements function ST_Simplify, which simplifies a geometry using the Douglas-Peucker algo...
Definition: item_geofunc.h:778
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:782
const char * func_name() const override
Definition: item_geofunc.h:789
String * val_str(String *) override
Definition: item_geofunc.cc:4064
Item_func_st_simplify(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:780
This class implements the two-parameter ST_SRID function which sets the SRID of a geometry.
Definition: item_geofunc.h:1679
String * val_str(String *) override
Definition: item_geofunc.cc:5428
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1685
const char * func_name() const override
Definition: item_geofunc.h:1684
Item_func_st_srid_mutator(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1681
This class implements the one-parameter ST_SRID function which returns the SRID of a geometry.
Definition: item_geofunc.h:1694
Item_func_st_srid_observer(const POS &pos, Item *a)
Definition: item_geofunc.h:1696
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1699
const char * func_name() const override
Definition: item_geofunc.h:1698
longlong val_int() override
Definition: item_geofunc.cc:5388
Definition: item_geofunc.h:1240
String * val_str(String *) override
Definition: item_geofunc.cc:5966
Item_func_st_symdifference(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1242
const char * func_name() const override
Definition: item_geofunc.h:1245
Definition: item_geofunc.h:1187
enum Functype functype() const override
Definition: item_geofunc.h:1191
Item_func_st_touches(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1189
const char * func_name() const override
Definition: item_geofunc.h:1193
enum Functype rev_functype() const override
Definition: item_geofunc.h:1192
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:221
This class implements ST_Transform function that transforms a geometry from one SRS to another.
Definition: item_geofunc.h:1830
String * val_str(String *str) override
Definition: item_geofunc.cc:6031
const char * func_name() const override
Definition: item_geofunc.h:1837
Item_func_st_transform(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1832
Definition: item_geofunc.h:1248
Item_func_st_union(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1250
String * val_str(String *) override
Definition: item_geofunc.cc:4652
const char * func_name() const override
Definition: item_geofunc.h:1253
Definition: item_geofunc.h:1198
bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override
Evaluate the spatial relation function.
Definition: item_geofunc_relchecks.cc:228
enum Functype rev_functype() const override
Definition: item_geofunc.h:1203
const char * func_name() const override
Definition: item_geofunc.h:1204
enum Functype functype() const override
Definition: item_geofunc.h:1202
Item_func_st_within(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1200
This class implements the two-parameter ST_X function which sets the X coordinate of a point.
Definition: item_geofunc.h:1525
int coordinate_number(const dd::Spatial_reference_system *srs) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.cc:5046
Item_func_st_x_mutator(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1527
const char * func_name() const override
Definition: item_geofunc.h:1531
This class implements the one-parameter ST_X function which returns the X coordinate of a point.
Definition: item_geofunc.h:1537
int coordinate_number(const dd::Spatial_reference_system *srs) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.cc:5052
Item_func_st_x_observer(const POS &pos, Item *a)
Definition: item_geofunc.h:1539
const char * func_name() const override
Definition: item_geofunc.h:1543
This class implements the two-parameter ST_Y function which sets the Y coordinate of a point.
Definition: item_geofunc.h:1549
int coordinate_number(const dd::Spatial_reference_system *srs) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.cc:5058
Item_func_st_y_mutator(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:1551
const char * func_name() const override
Definition: item_geofunc.h:1555
This class implements the one-parameter ST_Y function which returns the Y coordinate of a point.
Definition: item_geofunc.h:1561
int coordinate_number(const dd::Spatial_reference_system *srs) const override
Returns the coordinate number accessed by this item.
Definition: item_geofunc.cc:5064
const char * func_name() const override
Definition: item_geofunc.h:1567
Item_func_st_y_observer(const POS &pos, Item *a)
Definition: item_geofunc.h:1563
Definition: item_geofunc.h:1571
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1572
String * val_str(String *) override
Definition: item_geofunc.cc:5070
const char * func_name() const override
Definition: item_geofunc.h:1579
Item_func_swap_xy(const POS &pos, Item *a)
Definition: item_geofunc.h:1578
Definition: item_geofunc.h:763
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:769
String * val_str(String *) override
Definition: item_geofunc.cc:3381
const char * func_name() const override
Definition: item_geofunc.h:768
Item_func_validate(const POS &pos, Item *a)
Definition: item_geofunc.h:767
String arg_val
Definition: item_geofunc.h:764
Item ** args
Array of pointers to arguments.
Definition: item_func.h:100
virtual enum Functype functype() const
Definition: item_func.h:305
Functype
Definition: item_func.h:178
@ SP_CROSSES_FUNC
Definition: item_func.h:205
@ SP_EXTERIORRING
Definition: item_func.h:213
@ SP_EQUALS_FUNC
Definition: item_func.h:201
@ SP_COVEREDBY_FUNC
Definition: item_func.h:208
@ SP_TOUCHES_FUNC
Definition: item_func.h:204
@ SP_DISJOINT_FUNC
Definition: item_func.h:202
@ SP_STARTPOINT
Definition: item_func.h:211
@ SP_POINTN
Definition: item_func.h:214
@ SP_GEOMETRYN
Definition: item_func.h:215
@ TYPECAST_FUNC
Definition: item_func.h:225
@ SP_WITHIN_FUNC
Definition: item_func.h:206
@ SP_INTERIORRINGN
Definition: item_func.h:216
@ SP_INTERSECTS_FUNC
Definition: item_func.h:203
@ SP_COVERS_FUNC
Definition: item_func.h:209
@ SP_CONTAINS_FUNC
Definition: item_func.h:207
@ SP_ENDPOINT
Definition: item_func.h:212
@ SP_OVERLAPS_FUNC
Definition: item_func.h:210
optimize_type
Definition: item_func.h:297
@ OPTIMIZE_NONE
Definition: item_func.h:298
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:590
enum Type type() const override
Definition: item_func.h:304
bool param_type_is_default(THD *thd, uint start, uint end, uint step, enum_field_types def)
For arguments of this Item_func ("args" array), in range [start, start+step, start+2*step,...
Definition: item_func.cc:508
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:712
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:123
Definition: item_geofunc.h:187
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_geofunc.cc:296
Item_geometry_func(Item *a, Item *b)
Definition: item_geofunc.h:194
Item_geometry_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_geofunc.h:199
Item_geometry_func(Item *a)
Definition: item_geofunc.h:191
Item_geometry_func(Item *a, Item *b, Item *c)
Definition: item_geofunc.h:198
Item_geometry_func(const POS &pos, Item *a)
Definition: item_geofunc.h:192
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.cc:305
Item_geometry_func()
Definition: item_geofunc.h:189
Item_geometry_func(const POS &pos, Item *a, Item *b)
Definition: item_geofunc.h:195
Definition: item_func.h:896
Base class for all item functions that a return JSON value.
Definition: item_json_func.h:149
Definition: item_func.h:708
Definition: item_strfunc.h:141
Definition: item_strfunc.h:75
Definition: item_geofunc.h:1841
enum Functype functype() const override
Definition: item_geofunc.h:1849
const char * func_name() const override=0
Item_typecast_geometry(const POS &pos, Item *a)
Definition: item_geofunc.h:1843
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_geofunc.h:1851
String * val_str(String *str) override
Definition: item_geofunc.cc:6099
virtual bool cast(const dd::Spatial_reference_system *srs, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const =0
Casts certain geometry types to certain target geometry types.
void print(const THD *thd, String *str, enum_query_type query_type) const override=0
This method is used for to:
Field::geometry_type get_geometry_type() const override=0
Definition: item_geofunc.h:1957
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:7038
bool cast(const dd::Spatial_reference_system *, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6983
Item_typecast_geometrycollection(const POS &pos, Item *a)
Definition: item_geofunc.h:1959
const char * func_name() const override
Definition: item_geofunc.h:1963
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:7033
Definition: item_geofunc.h:1886
Item_typecast_linestring(const POS &pos, Item *a)
Definition: item_geofunc.h:1888
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:6341
bool cast(const dd::Spatial_reference_system *, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6220
const char * func_name() const override
Definition: item_geofunc.h:1892
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:6337
Definition: item_geofunc.h:1928
Item_typecast_multilinestring(const POS &pos, Item *a)
Definition: item_geofunc.h:1930
bool cast(const dd::Spatial_reference_system *, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6674
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:6811
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:6807
const char * func_name() const override
Definition: item_geofunc.h:1934
Definition: item_geofunc.h:1914
Item_typecast_multipoint(const POS &pos, Item *a)
Definition: item_geofunc.h:1916
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:6667
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:6663
const char * func_name() const override
Definition: item_geofunc.h:1920
bool cast(const dd::Spatial_reference_system *, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6573
Definition: item_geofunc.h:1942
Item_typecast_multipolygon(const POS &pos, Item *a)
Definition: item_geofunc.h:1944
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:6976
bool cast(const dd::Spatial_reference_system *srs, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6818
const char * func_name() const override
Definition: item_geofunc.h:1948
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:6972
Definition: item_geofunc.h:1872
bool cast(const dd::Spatial_reference_system *, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6147
const char * func_name() const override
Definition: item_geofunc.h:1878
Item_typecast_point(const POS &pos, Item *a)
Definition: item_geofunc.h:1874
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:6213
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:6209
Definition: item_geofunc.h:1900
Field::geometry_type get_geometry_type() const override
Definition: item_geofunc.cc:6562
const char * func_name() const override
Definition: item_geofunc.h:1906
Item_typecast_polygon(const POS &pos, Item *a)
Definition: item_geofunc.h:1902
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_geofunc.cc:6566
bool cast(const dd::Spatial_reference_system *srs, std::unique_ptr< gis::Geometry > *source_geometry, std::unique_ptr< gis::Geometry > *target_geometry) const override
Casts certain geometry types to certain target geometry types.
Definition: item_geofunc.cc:6348
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
void set_nullable(bool nullable)
Definition: item.h:3328
static const CHARSET_INFO * default_charset()
Definition: item.cc:1568
void set_data_type_blob(uint32 max_l)
Set the Item to be of BLOB type.
Definition: item.h:1470
virtual void print(const THD *, String *str, enum_query_type) const
This method is used for to:
Definition: item.h:2228
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1297
bool fixed
True if item has been resolved.
Definition: item.h:3316
bool null_value
True if item is null.
Definition: item.h:3353
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1388
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:3270
Represents a JSON array container, i.e.
Definition: json_dom.h:520
JSON DOM abstract base class.
Definition: json_dom.h:171
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:369
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1167
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:101
void error(Context *pc, const POS &pos) const
syntax_error() function replacement for deferred reporting of syntax errors
Definition: parse_tree_node_base.h:169
size_type erase_unique(const value_type &val)
Similar to std::set<>::erase() Removes a single element from the array by value.
Definition: prealloced_array.h:440
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:600
void * * iterator
Definition: prealloced_array.h:115
std::pair< iterator, bool > insert_unique(const value_type &val)
Similar to std::set<>::insert() Extends the array by inserting a new element, but only if it cannot b...
Definition: prealloced_array.h:420
iterator begin()
begin : Returns a pointer to the first element in the array.
Definition: prealloced_array.h:253
iterator end()
Definition: prealloced_array.h:254
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:165
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
Definition: spatial_reference_system.h:52
Abstract superclass for all geometric objects.
Definition: geometries.h:99
Dialog Client Authentication nullptr
Definition: dialog.cc:352
char * pos
Definition: do_ctype.cc:76
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
@ QT_NO_DATA_EXPANSION
If an expression is constant, print the expression, not the value it evaluates to.
Definition: enum_query_type.h:75
This file contains the field type.
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:65
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:90
@ MYSQL_TYPE_DOUBLE
Definition: field_types.h:62
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:215
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:42
static const int MAX_CRS_WIDTH
Max width of long CRS URN supported + max width of SRID + '\0'.
Definition: item_geofunc.h:479
enum_json_type
Json values in MySQL comprises the stand set of JSON values plus a MySQL specific set.
Definition: json_dom.h:107
Some integer typedefs for easier portability.
long long int longlong
Definition: my_inttypes.h:54
#define MYF(v)
Definition: my_inttypes.h:96
uint32_t uint32
Definition: my_inttypes.h:66
Common header for many mysys elements.
Common definition between mysql server & client.
#define MAX_INT_WIDTH
Max width for a LONG w.o.
Definition: mysql_com.h:897
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1056
Definition: buf0block_hint.cc:29
PT & ref(PT *tp)
Definition: tablespace_impl.cc:358
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
Definition: area.cc:46
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
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:32
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:391
Definition: options.cc:45
Performance schema instrumentation interface.
void gis_wkb_raw_free(void *p)
Definition: spatial.h:212
static bool rollback(THD *thd)
Abort the current statement and transaction.
Definition: sql_cmd_srs.cc:139
Our own string classes, used pervasively throughout the executor.
Definition: item_geofunc.h:1295
enum_buffer_strategies strategy
Definition: item_geofunc.h:1296
double value
Definition: item_geofunc.h:1299
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:90
Definition: table.h:1394
Bison "location" class.
Definition: parse_location.h:42
Definition: buffer_strategies.h:44
Definition: result.h:29
Definition: dbug.cc:186
unsigned int uint
Definition: uca-dump.cc:29