mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-20006 Move geometry specific code in Field_blob::get_key_image() to Field_geom
This commit is contained in:
35
sql/field.cc
35
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 */
|
/* 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);
|
size_t blob_length= get_length(ptr);
|
||||||
uchar *blob;
|
uchar *blob= get_ptr();
|
||||||
|
|
||||||
#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();
|
|
||||||
size_t local_char_length= length / field_charset->mbmaxlen;
|
size_t local_char_length= length / field_charset->mbmaxlen;
|
||||||
local_char_length= my_charpos(field_charset, blob, blob + blob_length,
|
local_char_length= my_charpos(field_charset, blob, blob + blob_length,
|
||||||
local_char_length);
|
local_char_length);
|
||||||
|
@ -3929,6 +3929,7 @@ protected:
|
|||||||
|
|
||||||
static void do_copy_blob(Copy_field *copy);
|
static void do_copy_blob(Copy_field *copy);
|
||||||
static void do_conv_blob(Copy_field *copy);
|
static void do_conv_blob(Copy_field *copy);
|
||||||
|
uint get_key_image_itRAW(uchar *buff, uint length);
|
||||||
public:
|
public:
|
||||||
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
|
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
|
||||||
@ -4104,7 +4105,11 @@ public:
|
|||||||
set_ptr_offset(0, length, data);
|
set_ptr_offset(0, length, data);
|
||||||
}
|
}
|
||||||
int copy_value(Field_blob *from);
|
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);
|
void set_key_image(const uchar *buff,uint length);
|
||||||
Field *new_key_field(MEM_ROOT *root, TABLE *new_table,
|
Field *new_key_field(MEM_ROOT *root, TABLE *new_table,
|
||||||
uchar *new_ptr, uint32 length,
|
uchar *new_ptr, uint32 length,
|
||||||
|
@ -5785,8 +5785,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MYSQL_SERVER
|
#ifdef MYSQL_SERVER
|
||||||
#include "gstream.h"
|
|
||||||
#include "spatial.h"
|
|
||||||
#include "item_sum.h"
|
#include "item_sum.h"
|
||||||
#include "item_func.h"
|
#include "item_func.h"
|
||||||
#include "item_row.h"
|
#include "item_row.h"
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include "sql_type_geom.h"
|
#include "sql_type_geom.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
#include "gstream.h"
|
||||||
|
#include "spatial.h"
|
||||||
#include "gcalc_slicescan.h"
|
#include "gcalc_slicescan.h"
|
||||||
#include "gcalc_tools.h"
|
#include "gcalc_tools.h"
|
||||||
|
|
||||||
|
@ -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,
|
Geometry *Geometry::create_from_wkt(Geometry_buffer *buffer,
|
||||||
Gis_read_stream *trs, String *wkt,
|
Gis_read_stream *trs, String *wkt,
|
||||||
bool init_stream)
|
bool init_stream)
|
||||||
|
@ -322,6 +322,7 @@ public:
|
|||||||
bool er_on_3D, String *res);
|
bool er_on_3D, String *res);
|
||||||
static Geometry *create_from_opresult(Geometry_buffer *g_buf,
|
static Geometry *create_from_opresult(Geometry_buffer *g_buf,
|
||||||
String *res, Gcalc_result_receiver &rr);
|
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_wkt(String *wkt, const char **end);
|
||||||
int as_json(String *wkt, uint max_dec_digits, const char **end);
|
int as_json(String *wkt, uint max_dec_digits, const char **end);
|
||||||
int bbox_as_json(String *wkt);
|
int bbox_as_json(String *wkt);
|
||||||
|
@ -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
|
#endif // HAVE_SPATIAL
|
||||||
|
@ -412,6 +412,7 @@ public:
|
|||||||
represented differently, but we need to support it either way.
|
represented differently, but we need to support it either way.
|
||||||
*/
|
*/
|
||||||
uint32 key_length() const { return packlength; }
|
uint32 key_length() const { return packlength; }
|
||||||
|
uint get_key_image(uchar *buff,uint length, imagetype type_arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Non-nullable GEOMETRY types cannot have defaults,
|
Non-nullable GEOMETRY types cannot have defaults,
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
#define SPIDER_DBTON_SIZE 15
|
#define SPIDER_DBTON_SIZE 15
|
||||||
|
|
||||||
|
#ifndef SIZEOF_STORED_DOUBLE
|
||||||
|
#define SIZEOF_STORED_DOUBLE 8
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SPIDER_DB_WRAPPER_MYSQL "mysql"
|
#define SPIDER_DB_WRAPPER_MYSQL "mysql"
|
||||||
#define SPIDER_DB_WRAPPER_MARIADB "mariadb"
|
#define SPIDER_DB_WRAPPER_MARIADB "mariadb"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user