diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-07-10 07:17:25 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-07-10 07:17:25 +0400 |
commit | e37d7a37151f1aa53e102d24af5d234c2ccfa392 (patch) | |
tree | f7a701296bb2a421091100bc297fd1a5bf653e88 /sql | |
parent | aca5532113714836e7d015c135a7f1a7ee8ca9d4 (diff) | |
download | mariadb-git-e37d7a37151f1aa53e102d24af5d234c2ccfa392.tar.gz |
MDEV-20006 Move geometry specific code in Field_blob::get_key_image() to Field_geom
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 35 | ||||
-rw-r--r-- | sql/field.h | 7 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_geofunc.h | 2 | ||||
-rw-r--r-- | sql/spatial.cc | 27 | ||||
-rw-r--r-- | sql/spatial.h | 1 | ||||
-rw-r--r-- | sql/sql_type_geom.cc | 12 | ||||
-rw-r--r-- | sql/sql_type_geom.h | 1 |
8 files changed, 51 insertions, 36 deletions
diff --git a/sql/field.cc b/sql/field.cc index 10994ecd885..834d627441d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8414,41 +8414,10 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr, /* The following is used only when comparing a key */ -uint Field_blob::get_key_image(uchar *buff,uint length, imagetype type_arg) +uint Field_blob::get_key_image_itRAW(uchar *buff, uint length) { size_t blob_length= get_length(ptr); - uchar *blob; - -#ifdef HAVE_SPATIAL - if (type_arg == itMBR) - { - const char *dummy; - MBR mbr; - Geometry_buffer buffer; - Geometry *gobj; - const uint image_length= SIZEOF_STORED_DOUBLE*4; - - if (blob_length < SRID_SIZE) - { - bzero(buff, image_length); - return image_length; - } - blob= get_ptr(); - gobj= Geometry::construct(&buffer, (char*) blob, (uint32)blob_length); - if (!gobj || gobj->get_mbr(&mbr, &dummy)) - bzero(buff, image_length); - else - { - float8store(buff, mbr.xmin); - float8store(buff+8, mbr.xmax); - float8store(buff+16, mbr.ymin); - float8store(buff+24, mbr.ymax); - } - return image_length; - } -#endif /*HAVE_SPATIAL*/ - - blob= get_ptr(); + uchar *blob= get_ptr(); size_t local_char_length= length / field_charset->mbmaxlen; local_char_length= my_charpos(field_charset, blob, blob + blob_length, local_char_length); diff --git a/sql/field.h b/sql/field.h index 0923e2786e9..978ce734187 100644 --- a/sql/field.h +++ b/sql/field.h @@ -3929,6 +3929,7 @@ protected: static void do_copy_blob(Copy_field *copy); static void do_conv_blob(Copy_field *copy); + uint get_key_image_itRAW(uchar *buff, uint length); public: Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg, @@ -4104,7 +4105,11 @@ public: set_ptr_offset(0, length, data); } int copy_value(Field_blob *from); - uint get_key_image(uchar *buff,uint length, imagetype type); + uint get_key_image(uchar *buff, uint length, imagetype type) + { + DBUG_ASSERT(type == itRAW); + return get_key_image_itRAW(buff, length); + } void set_key_image(const uchar *buff,uint length); Field *new_key_field(MEM_ROOT *root, TABLE *new_table, uchar *new_ptr, uint32 length, diff --git a/sql/item.h b/sql/item.h index ae96d67ebfd..0816f8d1e39 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5785,8 +5785,6 @@ public: }; #ifdef MYSQL_SERVER -#include "gstream.h" -#include "spatial.h" #include "item_sum.h" #include "item_func.h" #include "item_row.h" diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index f3d4c4bc38f..c38d0b986f1 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -28,6 +28,8 @@ #include "sql_type_geom.h" #include "item.h" +#include "gstream.h" +#include "spatial.h" #include "gcalc_slicescan.h" #include "gcalc_tools.h" diff --git a/sql/spatial.cc b/sql/spatial.cc index bba9ae45f58..ebec280a5eb 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -185,6 +185,33 @@ Geometry *Geometry::construct(Geometry_buffer *buffer, } +uint Geometry::get_key_image_itMBR(LEX_CSTRING &src, uchar *buff, uint length) +{ + const char *dummy; + MBR mbr; + Geometry_buffer buffer; + Geometry *gobj; + const uint image_length= SIZEOF_STORED_DOUBLE*4; + + if (src.length < SRID_SIZE) + { + bzero(buff, image_length); + return image_length; + } + gobj= Geometry::construct(&buffer, (char*) src.str, (uint32) src.length); + if (!gobj || gobj->get_mbr(&mbr, &dummy)) + bzero(buff, image_length); + else + { + float8store(buff, mbr.xmin); + float8store(buff+8, mbr.xmax); + float8store(buff+16, mbr.ymin); + float8store(buff+24, mbr.ymax); + } + return image_length; +} + + Geometry *Geometry::create_from_wkt(Geometry_buffer *buffer, Gis_read_stream *trs, String *wkt, bool init_stream) diff --git a/sql/spatial.h b/sql/spatial.h index fa4e40b5aa5..7817fd041cd 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -322,6 +322,7 @@ public: bool er_on_3D, String *res); static Geometry *create_from_opresult(Geometry_buffer *g_buf, String *res, Gcalc_result_receiver &rr); + static uint get_key_image_itMBR(LEX_CSTRING &src, uchar *buff, uint length); int as_wkt(String *wkt, const char **end); int as_json(String *wkt, uint max_dec_digits, const char **end); int bbox_as_json(String *wkt); diff --git a/sql/sql_type_geom.cc b/sql/sql_type_geom.cc index 120306a58a2..94ec69ae62c 100644 --- a/sql/sql_type_geom.cc +++ b/sql/sql_type_geom.cc @@ -886,4 +886,16 @@ bool Field_geom::load_data_set_null(THD *thd) } +uint Field_geom::get_key_image(uchar *buff,uint length, imagetype type_arg) +{ + if (type_arg == itMBR) + { + LEX_CSTRING tmp; + tmp.str= (const char *) get_ptr(); + tmp.length= get_length(ptr); + return Geometry::get_key_image_itMBR(tmp, buff, length); + } + return Field_blob::get_key_image_itRAW(buff, length); +} + #endif // HAVE_SPATIAL diff --git a/sql/sql_type_geom.h b/sql/sql_type_geom.h index d0b504d6844..487bdaa53be 100644 --- a/sql/sql_type_geom.h +++ b/sql/sql_type_geom.h @@ -412,6 +412,7 @@ public: represented differently, but we need to support it either way. */ uint32 key_length() const { return packlength; } + uint get_key_image(uchar *buff,uint length, imagetype type_arg); /** Non-nullable GEOMETRY types cannot have defaults, |