Skip to content
Permalink
Browse files
InnoDB: Remove dead code for DATA_POINT and DATA_VAR_POINT
The POINT data type is being treated just like any other
geometry data type in InnoDB. The fixed-length data type
DATA_POINT had been introduced in WL#6942 based on a
misunderstanding and without appropriate review.
Because of fundamental design problems (such as a
DEFAULT POINT(0 0) value secretly introduced by InnoDB),
the code was disabled in Oracle Bug#20415831 fix.

This patch removes the dead code and definitions that were
left behind by the Oracle Bug#20415831 patch.
  • Loading branch information
dr-m committed Jul 3, 2017
1 parent cf2789b commit 56ff6f1
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 187 deletions.
@@ -4673,29 +4673,12 @@ btr_index_rec_validate(
rec_get_nth_field_offs(offsets, i, &len);

/* Note that if fixed_size != 0, it equals the
length of a fixed-size column in the clustered index,
except the DATA_POINT, whose length would be MBR_LEN
when it's indexed in a R-TREE. We should adjust it here.
length of a fixed-size column in the clustered index.
We should adjust it here.
A prefix index of the column is of fixed, but different
length. When fixed_size == 0, prefix_len is the maximum
length of the prefix index column. */

if (dict_field_get_col(field)->mtype == DATA_POINT) {
ut_ad(fixed_size == DATA_POINT_LEN);
if (dict_index_is_spatial(index)) {
/* For DATA_POINT data, when it has R-tree
index, the fixed_len is the MBR of the point.
But if it's a primary key and on R-TREE
as the PK pointer, the length shall be
DATA_POINT_LEN as well. */
ut_ad((field->fixed_len == DATA_MBR_LEN
&& i == 0)
|| (field->fixed_len == DATA_POINT_LEN
&& i != 0));
fixed_size = field->fixed_len;
}
}

if ((field->prefix_len == 0
&& len != UNIV_SQL_NULL && fixed_size
&& len != fixed_size)
@@ -193,14 +193,6 @@ dtype_print(const dtype_t* type)
fputs("DATA_BLOB", stderr);
break;

case DATA_POINT:
fputs("DATA_POINT", stderr);
break;

case DATA_VAR_POINT:
fputs("DATA_VAR_POINT", stderr);
break;

case DATA_GEOMETRY:
fputs("DATA_GEOMETRY", stderr);
break;
@@ -2891,22 +2891,9 @@ dict_index_add_col(
field = dict_index_get_nth_field(index, index->n_def - 1);

field->col = col;
/* DATA_POINT is a special type, whose fixed_len should be:
1) DATA_MBR_LEN, when it's indexed in R-TREE. In this case,
it must be the first col to be added.
2) DATA_POINT_LEN(be equal to fixed size of column), when it's
indexed in B-TREE,
3) DATA_POINT_LEN, if a POINT col is the PRIMARY KEY, and we are
adding the PK col to other B-TREE/R-TREE. */
/* TODO: We suppose the dimension is 2 now. */
if (dict_index_is_spatial(index) && DATA_POINT_MTYPE(col->mtype)
&& index->n_def == 1) {
field->fixed_len = DATA_MBR_LEN;
} else {
field->fixed_len = static_cast<unsigned int>(
dict_col_get_fixed_size(
col, dict_table_is_comp(table)));
}
field->fixed_len = static_cast<unsigned int>(
dict_col_get_fixed_size(
col, dict_table_is_comp(table)));

if (prefix_len && field->fixed_len > prefix_len) {
field->fixed_len = (unsigned int) prefix_len;
@@ -5971,14 +5971,6 @@ innobase_match_index_columns(
spatial index on it and we intend to use DATA_GEOMETRY
for legacy GIS data types which are of var-length. */
switch (col_type) {
case DATA_POINT:
case DATA_VAR_POINT:
if (DATA_POINT_MTYPE(mtype)
|| mtype == DATA_GEOMETRY
|| mtype == DATA_BLOB) {
break;
}
/* Fall through */
case DATA_GEOMETRY:
if (mtype == DATA_BLOB) {
break;
@@ -7969,12 +7961,6 @@ build_template_field(
prebuilt->templ_contains_blob = TRUE;
}

if (templ->type == DATA_POINT) {
/* We set this only when it's DATA_POINT, but not
DATA_VAR_POINT */
prebuilt->templ_contains_fixed_point = TRUE;
}

return(templ);
}

@@ -8059,7 +8045,6 @@ ha_innobase::build_template(

/* Prepare to build m_prebuilt->mysql_template[]. */
m_prebuilt->templ_contains_blob = FALSE;
m_prebuilt->templ_contains_fixed_point = FALSE;
m_prebuilt->mysql_prefix_len = 0;
m_prebuilt->n_template = 0;
m_prebuilt->idx_cond_n_cols = 0;
@@ -8950,8 +8935,6 @@ calc_row_difference(
switch (col_type) {

case DATA_BLOB:
case DATA_POINT:
case DATA_VAR_POINT:
case DATA_GEOMETRY:
o_ptr = row_mysql_read_blob_ref(&o_len, o_ptr, o_len);
n_ptr = row_mysql_read_blob_ref(&n_len, n_ptr, n_len);
@@ -11714,10 +11697,6 @@ create_table_info_t::create_table_def()
}
}

if (col_type == DATA_POINT) {
col_len = DATA_POINT_LEN;
}

is_virtual = (innobase_is_v_fld(field)) ? DATA_VIRTUAL : 0;
is_stored = innobase_is_s_fld(field);

@@ -1760,7 +1760,6 @@ innobase_col_to_mysql(
memcpy(dest, data, len);
break;

case DATA_VAR_POINT:
case DATA_GEOMETRY:
case DATA_BLOB:
/* Skip MySQL BLOBs when reporting an erroneous row
@@ -1785,7 +1784,6 @@ innobase_col_to_mysql(
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_DECIMAL:
case DATA_POINT:
/* Above are the valid column types for MySQL data. */
ut_ad(flen == len);
/* fall through */
@@ -3011,29 +3009,6 @@ innobase_check_foreigns(
return(false);
}

/** Get the default POINT value in MySQL format
@param[in] heap memory heap where allocated
@param[in] length length of MySQL format
@return mysql format data */
static
const byte*
innobase_build_default_mysql_point(
mem_heap_t* heap,
ulint length)
{
byte* buf = static_cast<byte*>(mem_heap_alloc(
heap, DATA_POINT_LEN + length));

byte* wkb = buf + length;

ulint len = get_wkb_of_default_point(SPDIMS, wkb, DATA_POINT_LEN);
ut_ad(len == DATA_POINT_LEN);

row_mysql_store_blob_ref(buf, length, wkb, len);

return(buf);
}

/** Convert a default value for ADD COLUMN.

@param heap Memory heap where allocated
@@ -3060,16 +3035,6 @@ innobase_build_col_map_add(

const byte* mysql_data = field->ptr;

if (dfield_get_type(dfield)->mtype == DATA_POINT) {
/** If the DATA_POINT field is NOT NULL, we need to
give it a default value, since DATA_POINT is a fixed length
type, we couldn't store a value of length 0, like other
geom types. Server doesn't provide the default value, and
we would use POINT(0 0) here instead. */

mysql_data = innobase_build_default_mysql_point(heap, size);
}

row_mysql_store_col_in_innobase_format(
dfield, buf, true, mysql_data, size, comp);
}
@@ -4703,12 +4668,6 @@ prepare_inplace_alter_table_dict(

}

if (col_type == DATA_POINT) {
/* DATA_POINT should be of fixed length,
instead of the pack_length(blob length). */
col_len = DATA_POINT_LEN;
}

if (dict_col_name_is_reserved(field->field_name)) {
dict_mem_table_free(ctx->new_table);
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
@@ -77,28 +77,18 @@ binary strings */
charset-collation for tables created with it
can also be latin1_swedish_ci */

/* DATA_POINT&DATA_VAR_POINT are for standard geometry datatype 'point' and
DATA_GEOMETRY include all other standard geometry datatypes as described in
OGC standard(line_string, polygon, multi_point, multi_polygon,
/* DATA_GEOMETRY includes all standard geometry datatypes as described in
OGC standard(point, line_string, polygon, multi_point, multi_polygon,
multi_line_string, geometry_collection, geometry).
Currently, geometry data is stored in the standard Well-Known Binary(WKB)
format (http://www.opengeospatial.org/standards/sfa).
We use BLOB as underlying datatype for DATA_GEOMETRY and DATA_VAR_POINT
while CHAR for DATA_POINT */
We use BLOB as the underlying datatype. */
#define DATA_GEOMETRY 14 /* geometry datatype of variable length */
/* The following two are disabled temporarily, we won't create them in
get_innobase_type_from_mysql_type().
TODO: We will enable DATA_POINT/them when we come to the fixed-length POINT
again. */
#define DATA_POINT 15 /* geometry datatype of fixed length POINT */
#define DATA_VAR_POINT 16 /* geometry datatype of variable length
POINT, used when we want to store POINT
as BLOB internally */
#define DATA_MTYPE_MAX 63 /* dtype_store_for_order_and_null_size()
requires the values are <= 63 */

#define DATA_MTYPE_CURRENT_MIN DATA_VARCHAR /* minimum value of mtype */
#define DATA_MTYPE_CURRENT_MAX DATA_VAR_POINT /* maximum value of mtype */
#define DATA_MTYPE_CURRENT_MAX DATA_GEOMETRY /* maximum value of mtype */
/*-------------------------------------------*/
/* The 'PRECISE TYPE' of a column */
/*
@@ -211,15 +201,6 @@ store the charset-collation number; one byte is left unused, though */
/* Maximum multi-byte character length in bytes, plus 1 */
#define DATA_MBMAX 5

/* For DATA_POINT of dimension 2, the length of value in btree is always 25,
which is the summary of:
SRID_SIZE(4) + WKB_HEADER_SIZE(1+4) + POINT_DATA_SIZE(8*2).
So the length of physical record or POINT KEYs on btree are 25.
GIS_TODO: When we support multi-dimensions DATA_POINT, we should get the
length from corresponding column or index definition, instead of this MACRO
*/
#define DATA_POINT_LEN 25

/* Pack mbminlen, mbmaxlen to mbminmaxlen. */
#define DATA_MBMINMAXLEN(mbminlen, mbmaxlen) \
unsigned((mbmaxlen) * DATA_MBMAX + (mbminlen))
@@ -229,18 +210,12 @@ length from corresponding column or index definition, instead of this MACRO
/* Get mbmaxlen from mbminmaxlen. */
#define DATA_MBMAXLEN(mbminmaxlen) unsigned((mbminmaxlen) / DATA_MBMAX)

/* For checking if a geom_type is POINT */
#define DATA_POINT_MTYPE(mtype) ((mtype) == DATA_POINT \
|| (mtype) == DATA_VAR_POINT)

/* For checking if mtype is GEOMETRY datatype */
#define DATA_GEOMETRY_MTYPE(mtype) (DATA_POINT_MTYPE(mtype) \
|| (mtype) == DATA_GEOMETRY)
#define DATA_GEOMETRY_MTYPE(mtype) ((mtype) == DATA_GEOMETRY)

/* For checking if mtype is BLOB or GEOMETRY, since we use BLOB as
the underling datatype of GEOMETRY(not DATA_POINT) data. */
the underlying datatype of GEOMETRY data. */
#define DATA_LARGE_MTYPE(mtype) ((mtype) == DATA_BLOB \
|| (mtype) == DATA_VAR_POINT \
|| (mtype) == DATA_GEOMETRY)

/* For checking if data type is big length data type. */
@@ -504,7 +504,6 @@ dtype_get_fixed_size_low(
case DATA_INT:
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_POINT:
return(len);
case DATA_MYSQL:
if (prtype & DATA_BINARY_TYPE) {
@@ -533,7 +532,6 @@ dtype_get_fixed_size_low(
case DATA_BINARY:
case DATA_DECIMAL:
case DATA_VARMYSQL:
case DATA_VAR_POINT:
case DATA_GEOMETRY:
case DATA_BLOB:
return(0);
@@ -580,7 +578,6 @@ dtype_get_min_size_low(
case DATA_INT:
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_POINT:
return(len);
case DATA_MYSQL:
if (prtype & DATA_BINARY_TYPE) {
@@ -603,7 +600,6 @@ dtype_get_min_size_low(
case DATA_BINARY:
case DATA_DECIMAL:
case DATA_VARMYSQL:
case DATA_VAR_POINT:
case DATA_GEOMETRY:
case DATA_BLOB:
return(0);
@@ -637,9 +633,7 @@ dtype_get_max_size_low(
case DATA_BINARY:
case DATA_DECIMAL:
case DATA_VARMYSQL:
case DATA_POINT:
return(len);
case DATA_VAR_POINT:
case DATA_GEOMETRY:
case DATA_BLOB:
break;
@@ -681,12 +681,6 @@ struct row_prebuilt_t {
not to be confused with InnoDB
externally stored columns
(VARCHAR can be off-page too) */
unsigned templ_contains_fixed_point:1;/*!< TRUE if the
template contains a column with
DATA_POINT. Since InnoDB regards
DATA_POINT as non-BLOB type, the
templ_contains_blob can't tell us
if there is DATA_POINT */
mysql_row_templ_t* mysql_template;/*!< template used to transform
rows fast between MySQL and Innobase
formats; memory for this template
@@ -378,8 +378,6 @@ cmp_whole_field(
case DATA_MYSQL:
return(innobase_mysql_cmp(prtype,
a, a_length, b, b_length));
case DATA_POINT:
case DATA_VAR_POINT:
case DATA_GEOMETRY:
return(cmp_geometry_field(mtype, prtype, a, a_length, b,
b_length));
@@ -437,11 +435,6 @@ cmp_data(
case DATA_SYS:
pad = ULINT_UNDEFINED;
break;
case DATA_POINT:
case DATA_VAR_POINT:
/* Since DATA_POINT has a fixed length of DATA_POINT_LEN,
currently, pad is not needed. Meanwhile, DATA_VAR_POINT acts
the same as DATA_GEOMETRY */
case DATA_GEOMETRY:
ut_ad(prtype & DATA_BINARY_TYPE);
pad = ULINT_UNDEFINED;
@@ -308,7 +308,6 @@ rec_init_offsets_comp_ordinary(

if (!field->fixed_len
|| (temp && !dict_col_get_fixed_size(col, temp))) {
ut_ad(col->mtype != DATA_POINT);
/* Variable-length field: read the length */
len = *lens--;
/* If the maximum length of the field is up
@@ -445,9 +444,6 @@ rec_init_offsets(
if (UNIV_UNLIKELY(!field->fixed_len)) {
const dict_col_t* col
= dict_field_get_col(field);
/* DATA_POINT should always be a fixed
length column. */
ut_ad(col->mtype != DATA_POINT);
/* Variable-length field: read the length */
len = *lens--;
/* If the maximum length of the field
@@ -858,8 +854,6 @@ rec_get_converted_size_comp_prefix_low(
}

ut_ad(len <= col->len || DATA_LARGE_MTYPE(col->mtype)
|| (DATA_POINT_MTYPE(col->mtype)
&& len == DATA_MBR_LEN)
|| (col->len == 0 && col->mtype == DATA_VARCHAR));

fixed_len = field->fixed_len;
@@ -1337,8 +1331,6 @@ rec_convert_dtuple_to_rec_comp(
*lens-- = (byte) (len >> 8) | 0xc0;
*lens-- = (byte) len;
} else {
/* DATA_POINT would have a fixed_len */
ut_ad(dtype_get_mtype(type) != DATA_POINT);
ut_ad(len <= dtype_get_len(type)
|| DATA_LARGE_MTYPE(dtype_get_mtype(type))
|| !strcmp(index->name,
@@ -840,9 +840,7 @@ row_merge_buf_add(
}

ut_ad(len <= col->len
|| DATA_LARGE_MTYPE(col->mtype)
|| (col->mtype == DATA_POINT
&& len == DATA_MBR_LEN));
|| DATA_LARGE_MTYPE(col->mtype));

fixed_len = ifield->fixed_len;
if (fixed_len && !dict_table_is_comp(index->table)

0 comments on commit 56ff6f1

Please sign in to comment.