Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-33408 Introduce session variables to manage HNSW index parameters #3226

Open
wants to merge 28 commits into
base: bb-11.4-vec-vicentiu-hugo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7b87e01
MDEV-32885 VEC_DISTANCE() function
vuvova Nov 25, 2023
ed8b6da
make INFORMATION_SCHEMA.STATISTICS.COMMENT not nullable
vuvova Jan 19, 2024
4bea056
fix main.plugin_vars test to cleanup after itself
vuvova Feb 5, 2024
62e6031
cleanup: spaces, casts, comments
vuvova Jan 8, 2024
e409868
cleanup: pass TABLE_SHARE to store_key_options()
vuvova Jan 26, 2024
bc8a7a3
reject invalid spatial key declarations in the parser
vuvova Jan 8, 2024
16846b5
cleanup: remove unconditional #ifdef's
vuvova Jan 10, 2024
2cd2320
cleanup: lex_string_set3()
vuvova Jan 27, 2024
8ddb99a
cleanup: Queue and Bounded_queue
vuvova Feb 6, 2024
ef14f42
cleanup: key algorithm vs key flags
vuvova Jan 14, 2024
022bc34
cleanup: make_long_hash_field_name() and add_hash_field()
vuvova Jan 18, 2024
38e84a8
cleanup: generalize ER_SPATIAL_CANT_HAVE_NULL
vuvova Jan 17, 2024
f1d0352
cleanup: generalize ER_INNODB_NO_FT_TEMP_TABLE
vuvova Jan 25, 2024
0cbd050
cleanup: extract ha_create_table_from_share()
vuvova Jan 25, 2024
cdcf739
open frm for DROP TABLE
vuvova Jan 26, 2024
3fa8be1
cleanup: unused function argument
vuvova Jan 26, 2024
cc82b35
Revert "MDEV-15458 Segfault in heap_scan() upon UPDATE after ADD SYST…
vuvova Feb 9, 2024
a857b68
initial support for vector indexes
vuvova Jan 17, 2024
9ca6554
Initial fixup
cvicentiu Feb 17, 2024
1568677
Wip
cvicentiu Feb 21, 2024
e944876
Graph insert possibly working ok
cvicentiu Feb 22, 2024
b34a896
Search is now working, but layer unaware
cvicentiu Feb 22, 2024
8aa7c1e
wip
cvicentiu Feb 22, 2024
3d0e4ea
Vec insert and search working on a multi-layer
cvicentiu Feb 23, 2024
437e214
MDEV-33408 Alter HNSW graph storage and fix memory leak
HugoWenTD Apr 12, 2024
ee2cc47
Support files for ann-workspace
cvicentiu Apr 15, 2024
7829259
Bug fixes - on top of Hugo's patch
cvicentiu Apr 18, 2024
5899540
Introduce session variables to manage HNSW index parameters
HugoWenTD Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup: key algorithm vs key flags
the information about index algorithm was stored in two
places inconsistently split between both.

BTREE index could have key->algorithm == HA_KEY_ALG_BTREE, if the user
explicitly specified USING BTREE or HA_KEY_ALG_UNDEF, if not.

RTREE index had key->algorithm == HA_KEY_ALG_RTREE
and always had key->flags & HA_SPATIAL

FULLTEXT index had  key->algorithm == HA_KEY_ALG_FULLTEXT
and always had key->flags & HA_FULLTEXT

HASH index had key->algorithm == HA_KEY_ALG_HASH or HA_KEY_ALG_UNDEF

long unique index always had key->algorithm == HA_KEY_ALG_LONG_HASH

In this commit:

All indexes except BTREE and HASH always have key->algorithm
set, HA_SPATIAL and HA_FULLTEXT flags are not used anymore (except
for storage to keep frms backward compatible).
  • Loading branch information
vuvova authored and cvicentiu committed Apr 4, 2024
commit ef14f42b1da6920420ee966bf6ffebbc7d7f3a7a
69 changes: 34 additions & 35 deletions include/my_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ enum ha_rkey_function {
/* Key algorithm types (stored in .frm) */

enum ha_key_alg {
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
HA_KEY_ALG_UNDEF= 0, /* Not specified. Practically the
key will be B-tree or hash */
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */
Expand Down Expand Up @@ -267,51 +268,49 @@ enum ha_base_keytype {
Note that these can only be up to 16 bits!
*/

#define HA_NOSAME 1U /* Set if not dupplicated records */
#define HA_PACK_KEY 2U /* Pack string key to previous key */
#define HA_AUTO_KEY 16U /* MEMORY/MyISAM/Aria internal */
#define HA_BINARY_PACK_KEY 32U /* Packing of all keys to prev key */
#define HA_FULLTEXT 128U /* For full-text search */
#define HA_SPATIAL 1024U /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048U /* NULL in key are cmp as equal */
#define HA_GENERATED_KEY 8192U /* Automatically generated key */
/*
Part of unique hash key. Used only for temporary (work) tables so is not
written to .frm files.
*/
#define HA_UNIQUE_HASH 262144U

/* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_AUTO_KEY | \
HA_FULLTEXT | \
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY | \
HA_UNIQUE_HASH)
#define HA_NOSAME 1U /* Set if not dupplicated records */
#define HA_PACK_KEY 2U /* Pack string key to previous key */
#define HA_SPACE_PACK_USED 4U /* Test for if SPACE_PACK used */
#define HA_VAR_LENGTH_KEY 8U /* automatic bit */
#define HA_AUTO_KEY 16U /* MEMORY/MyISAM/Aria internal */
#define HA_BINARY_PACK_KEY 32U /* Packing of all keys to prev key */
#define HA_NULL_PART_KEY 64U /* automatic bit */
#define HA_FULLTEXT_legacy 128U /* For full-text search */
#define HA_SORT_ALLOWS_SAME 512U /* Intern bit when sorting records */
#define HA_SPATIAL_legacy 1024U /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048U /* NULL in key are cmp as equal */
#define HA_USES_COMMENT 4096U /* automatic bit */
#define HA_GENERATED_KEY 8192U /* Automatically generated key */
#define HA_USES_PARSER 16384U /* Fulltext index uses [pre]parser */
#define HA_USES_BLOCK_SIZE 32768U /* automatic bit */

/*
Key contains partial segments.

This flag is internal to the MySQL server by design. It is not supposed
neither to be saved in FRM-files, nor to be passed to storage engines.
It is intended to pass information into internal static sort_keys(KEY *,
KEY *) function.
It is intended to pass information into internal sort_keys(KEY *, KEY *)
function.

This flag can be calculated -- it's based on key lengths comparison.
*/
#define HA_KEY_HAS_PART_KEY_SEG 65536
/* Internal Flag Can be calculated */
#define HA_INVISIBLE_KEY 2<<18
/* Automatic bits in key-flag */

#define HA_SPACE_PACK_USED 4 /* Test for if SPACE_PACK used */
#define HA_VAR_LENGTH_KEY 8
#define HA_NULL_PART_KEY 64
#define HA_USES_COMMENT 4096
#define HA_USES_PARSER 16384 /* Fulltext index uses [pre]parser */
#define HA_USES_BLOCK_SIZE ((uint) 32768)
#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
#define HA_KEY_HAS_PART_KEY_SEG 65536U

/* This flag can be used only in KEY::ext_key_flags */
#define HA_EXT_NOSAME 131072
#define HA_EXT_NOSAME 131072U

/*
Part of unique hash key. Used only for temporary (work) tables so is not
written to .frm files.
*/
#define HA_UNIQUE_HASH 262144U

/* Internal Flag Can be calculated */
#define HA_INVISIBLE_KEY (2<<18)

/* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_AUTO_KEY | HA_NULL_ARE_EQUAL | \
HA_GENERATED_KEY | HA_UNIQUE_HASH)

/* These flags can be added to key-seg-flag */

Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/myisam.result
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ t1c1 t2c1
UNLOCK TABLES;
DROP TABLE t1,t2;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
Got one of the listed errors
ERROR HY000: Incorrect arguments to RTREE INDEX
create table t1 (a int, b varchar(200), c text not null) checksum=1;
create table t2 (a int, b varchar(200), c text not null) checksum=0;
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/myisam.test
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ DROP TABLE t1,t2;
#
# Test RTREE index
#
--error 1235, 1289
--error ER_WRONG_ARGUMENTS
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
# INSERT INTO t1 VALUES (1,1),(1,1);
# DELETE FROM rt WHERE a<1;
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/gcol/r/innodb_virtual_index.result
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: INPLACE ADD or DROP of
CREATE FULLTEXT INDEX idx ON t1(col9);
ALTER TABLE t1 ADD COLUMN col7a INT GENERATED ALWAYS AS (col5x % col6x)
VIRTUAL, ADD FULLTEXT KEY ftidx ( col9 ), algorithm=inplace;
Warnings:
Note 1831 Duplicate index `ftidx`. This is deprecated and will be disallowed in a future release
DROP TABLE t1;
CREATE TABLE t1 (
col1 int(11) NOT NULL,
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/innodb/r/foreign_key.result
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ ALTER TABLE t1 ADD FOREIGN KEY (f) REFERENCES non_existing_table (x);
SET SESSION FOREIGN_KEY_CHECKS = ON;
ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f);
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
Warnings:
Note 1831 Duplicate index `ft2`. This is deprecated and will be disallowed in a future release
DROP TABLE t1;
CREATE TABLE t1 (f VARCHAR(256), FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY)
ENGINE=InnoDB;
Expand All @@ -279,6 +281,8 @@ ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f);
Warnings:
Warning 1088 failed to load FOREIGN KEY constraints
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
Warnings:
Note 1831 Duplicate index `ft2`. This is deprecated and will be disallowed in a future release
DROP TABLE t1;
#
# MDEV-18630 Conditional jump or move depends on uninitialised value
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/innodb/r/innodb-alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
CREATE TABLE t1n LIKE t1o;
ALTER TABLE t1n ADD FULLTEXT INDEX(ct);
Warnings:
Note 1831 Duplicate index `ct_2`. This is deprecated and will be disallowed in a future release
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=INPLACE;
ERROR 42000: Incorrect column name 'FTS_DOC_ID'
ALTER TABLE t1n CHANGE c1 Fts_DOC_ID INT, ALGORITHM=COPY;
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/innodb_fts/r/crash_recovery.result
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ FULLTEXT(title,body)) ENGINE=InnoDB;
INSERT INTO mdev19073 (title, body) VALUES
('MySQL Tutorial', 'DBMS stands for Database...');
CREATE FULLTEXT INDEX idx ON mdev19073(title, body);
Warnings:
Note 1831 Duplicate index `idx`. This is deprecated and will be disallowed in a future release
CREATE TABLE mdev19073_2 LIKE mdev19073;
INSERT INTO mdev19073_2 (title, body) VALUES
('MySQL Tutorial', 'DBMS stands for Database...');
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/maria/maria.result
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ t1c1 t2c1
unlock tables;
DROP TABLE t1,t2;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`));
Got one of the listed errors
ERROR HY000: Incorrect arguments to RTREE INDEX
create table t1 (a int, b varchar(200), c text not null) checksum=1;
create table t2 (a int, b varchar(200), c text not null) checksum=0;
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/maria/maria.test
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ DROP TABLE t1,t2;
#
# Test RTREE index
#
--error 1235, 1289
--error ER_WRONG_ARGUMENTS
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`));
# INSERT INTO t1 VALUES (1,1),(1,1);
# DELETE FROM rt WHERE a<1;
Expand Down
2 changes: 2 additions & 0 deletions sql/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ class Field: public Value_source
TMYSQL_COMPRESSED= 24, // Compatibility with TMySQL
};
enum imagetype { itRAW, itMBR};
static enum imagetype image_type(enum ha_key_alg alg)
{ return alg == HA_KEY_ALG_RTREE ? itMBR : itRAW; }

utype unireg_check;
field_visibility_t invisible;
Expand Down
16 changes: 16 additions & 0 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3492,6 +3492,22 @@ PSI_table_share *handler::ha_table_share_psi() const
return table_share->m_psi;
}

const char *handler::index_type(uint key_number)
{
static const char* alg2str[]= { "???", "BTREE", "SPATIAL", "HASH",
"FULLTEXT", "HASH", "HASH" };
enum ha_key_alg alg= table_share->key_info[key_number].algorithm;
if (!alg)
{
if (index_flags(key_number, 0, 1) & HA_READ_RANGE)
alg= HA_KEY_ALG_BTREE;
else
alg= HA_KEY_ALG_HASH;
}
return alg2str[alg];
}


/** @brief
Open database-handler.

Expand Down
3 changes: 1 addition & 2 deletions sql/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4038,8 +4038,7 @@ class handler :public Sql_alloc
*/
virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; }

virtual const char *index_type(uint key_number) { DBUG_ASSERT(0); return "";}

virtual const char *index_type(uint key_number);

/**
Signal that the table->read_set and table->write_set table maps changed
Expand Down
2 changes: 1 addition & 1 deletion sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6316,7 +6316,7 @@ bool Item_func_match::fix_index()

for (keynr=0 ; keynr < table->s->keys ; keynr++)
{
if ((table->key_info[keynr].flags & HA_FULLTEXT) &&
if (table->key_info[keynr].algorithm == HA_KEY_ALG_FULLTEXT &&
(match_flags & FT_BOOL ?
table->keys_in_use_for_query.is_set(keynr) :
table->s->usable_indexes(table->in_use).is_set(keynr)))
Expand Down
2 changes: 1 addition & 1 deletion sql/key.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void key_copy(uchar *to_key, const uchar *from_record, const KEY *key_info,
key_length-= HA_KEY_BLOB_LENGTH;
length= MY_MIN(key_length, key_part->length);
uint bytes= key_part->field->get_key_image(to_key, length, from_ptr,
key_info->flags & HA_SPATIAL ? Field::itMBR : Field::itRAW);
Field::image_type(key_info->algorithm));
if (with_zerofill && bytes < length)
bzero((char*) to_key + bytes, length - bytes);
to_key+= HA_KEY_BLOB_LENGTH;
Expand Down
10 changes: 4 additions & 6 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,7 @@ SQL_SELECT::test_quick_select(THD *thd,
add("cause", "not applicable");
continue;
}
if (key_info->flags & HA_FULLTEXT)
if (key_info->algorithm == HA_KEY_ALG_FULLTEXT)
{
trace_idx_details.add("usable", false).add("cause", "fulltext");
continue; // ToDo: ft-keys in non-ft ranges, if possible SerG
Expand All @@ -2871,8 +2871,7 @@ SQL_SELECT::test_quick_select(THD *thd,
cur_key_len += key_part_info->store_length;
key_parts->field= key_part_info->field;
key_parts->null_bit= key_part_info->null_bit;
key_parts->image_type =
(key_info->flags & HA_SPATIAL) ? Field::itMBR : Field::itRAW;
key_parts->image_type = Field::image_type(key_info->algorithm);
/* Only HA_PART_KEY_SEG is used */
key_parts->flag= (uint8) key_part_info->key_part_flag;
trace_keypart.add(key_parts->field->field_name);
Expand Down Expand Up @@ -12224,7 +12223,7 @@ get_quick_select(PARAM *param,uint idx,SEL_ARG *key_tree, uint mrr_flags,
bool create_err= FALSE;
DBUG_ENTER("get_quick_select");

if (param->table->key_info[param->real_keynr[idx]].flags & HA_SPATIAL)
if (param->table->key_info[param->real_keynr[idx]].algorithm & HA_KEY_ALG_RTREE)
quick=new QUICK_RANGE_SELECT_GEOM(param->thd, param->table,
param->real_keynr[idx],
MY_TEST(parent_alloc),
Expand Down Expand Up @@ -14699,8 +14698,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
bool has_min_max_fld= false, has_other_fld= false;
if (join->conds && min_max_arg_item &&
!check_group_min_max_predicates(join->conds, min_max_arg_item,
(index_info->flags & HA_SPATIAL) ?
Field::itMBR : Field::itRAW,
Field::image_type(index_info->algorithm),
&has_min_max_fld, &has_other_fld))
{
if (unlikely(trace_group.trace_started()))
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler,
uint key_len;
const KEY *c_key= table->s->key_info + handler->keyno;

if ((c_key->flags & HA_SPATIAL) ||
c_key->algorithm == HA_KEY_ALG_FULLTEXT ||
if (c_key->algorithm == HA_KEY_ALG_RTREE ||
c_key->algorithm == HA_KEY_ALG_FULLTEXT ||
(ha_rkey_mode != HA_READ_KEY_EXACT &&
(table->key_info[handler->keyno].index_flags &
(HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE)) == 0))
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7195,7 +7195,8 @@ static bool add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
{
if (!(form->keys_in_use_for_query.is_set(key)))
continue;
if (form->key_info[key].flags & (HA_FULLTEXT | HA_SPATIAL))
if (form->key_info[key].algorithm == HA_KEY_ALG_FULLTEXT ||
form->key_info[key].algorithm == HA_KEY_ALG_RTREE)
continue;

KEY *keyinfo= form->key_info+key;
Expand Down
24 changes: 8 additions & 16 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
Build a CREATE TABLE statement for a table.

SYNOPSIS
show_create_table()
show_create_table_ex()
thd The thread
table_list A list containing one table to write statement
for.
Expand Down Expand Up @@ -2120,7 +2120,7 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
!create_info_arg;
handlerton *hton;
int error= 0;
DBUG_ENTER("show_create_table");
DBUG_ENTER("show_create_table_ex");
DBUG_PRINT("enter",("table: %s", table->s->table_name.str));

#ifdef WITH_PARTITION_STORAGE_ENGINE
Expand Down Expand Up @@ -2356,9 +2356,9 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
}
else if (key_info->flags & HA_NOSAME)
packet->append(STRING_WITH_LEN("UNIQUE KEY "));
else if (key_info->flags & HA_FULLTEXT)
else if (key_info->algorithm == HA_KEY_ALG_FULLTEXT)
packet->append(STRING_WITH_LEN("FULLTEXT KEY "));
else if (key_info->flags & HA_SPATIAL)
else if (key_info->algorithm == HA_KEY_ALG_RTREE)
packet->append(STRING_WITH_LEN("SPATIAL KEY "));
else
packet->append(STRING_WITH_LEN("KEY "));
Expand All @@ -2384,9 +2384,9 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
if (key_part->field)
append_identifier(thd, packet, &key_part->field->field_name);
if (key_part->field &&
(key_part->length !=
table->field[key_part->fieldnr-1]->key_length() &&
!(key_info->flags & (HA_FULLTEXT | HA_SPATIAL))))
key_part->length != table->field[key_part->fieldnr-1]->key_length() &&
key_info->algorithm != HA_KEY_ALG_RTREE &&
key_info->algorithm != HA_KEY_ALG_FULLTEXT)
{
packet->append_parenthesized((long) key_part->length /
key_part->field->charset()->mbmaxlen);
Expand Down Expand Up @@ -2535,11 +2535,6 @@ static void store_key_options(THD *thd, String *packet, TABLE_SHARE *share,
key_info->algorithm == HA_KEY_ALG_LONG_HASH)
packet->append(STRING_WITH_LEN(" USING HASH"));

/* send USING only in non-default case: non-spatial rtree */
if ((key_info->algorithm == HA_KEY_ALG_RTREE) &&
!(key_info->flags & HA_SPATIAL))
packet->append(STRING_WITH_LEN(" USING RTREE"));

if ((key_info->flags & HA_USES_BLOCK_SIZE) &&
share->key_block_size != key_info->block_size)
{
Expand Down Expand Up @@ -7219,9 +7214,6 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, TABLE *table,
? "D" : "A", 1, cs);
table->field[8]->set_notnull();
}
if (key_info->algorithm == HA_KEY_ALG_LONG_HASH)
table->field[13]->store(STRING_WITH_LEN("HASH"), cs);
else
{
/*
We have to use table key information to get the key statistics
Expand All @@ -7240,7 +7232,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, TABLE *table,
table->field[13]->store(tmp, strlen(tmp), cs);
}
}
if (!(key_info->flags & HA_FULLTEXT) &&
if (key_info->algorithm != HA_KEY_ALG_FULLTEXT &&
(key_part->field &&
key_part->length !=
show_table->s->field[key_part->fieldnr-1]->key_length()))
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
DBUG_ENTER("collect_statistics_for_index");

/* No statistics for FULLTEXT indexes. */
if (key_info->flags & (HA_FULLTEXT|HA_SPATIAL))
if (key_info->algorithm > HA_KEY_ALG_BTREE)
DBUG_RETURN(rc);

Index_prefix_calc index_prefix_calc(thd, table, key_info);
Expand Down