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).

As a side effect ALTER TABLE now detects FULLTEXT index renames correctly
This commit is contained in:
Sergei Golubchik 2024-01-14 11:43:43 +01:00
parent f5e9c4e9ef
commit 062f8eb37d
76 changed files with 338 additions and 468 deletions

View file

@ -102,7 +102,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) */
@ -269,51 +270,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 */

View file

@ -175,7 +175,7 @@ Cardinality 0
Sub_part NULL
Packed NULL
Null
Index_type BTREE
Index_type HASH
Comment
Index_comment
Ignored NO

View file

@ -2,6 +2,9 @@ create table t1(a blob unique) engine= InnoDB;
insert into t1 values('RUC');
insert into t1 values ('RUC');
ERROR 23000: Duplicate entry 'RUC' for key 'a'
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
t1 0 a 1 a A 1 NULL NULL YES HASH NO
drop table t1;
create table t1 (a blob unique , c int unique) engine=innodb;
show create table t1;

View file

@ -8,6 +8,7 @@ create table t1(a blob unique) engine= InnoDB;
insert into t1 values('RUC');
--error ER_DUP_ENTRY
insert into t1 values ('RUC');
show keys from t1;
drop table t1;
create table t1 (a blob unique , c int unique) engine=innodb;

View file

@ -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, "");

View file

@ -541,7 +541,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;

View file

@ -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,

View file

@ -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;
@ -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

View file

@ -519,6 +519,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;

View file

@ -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...');

View file

@ -1,12 +0,0 @@
--- sync_ddl.result
+++ sync_ddl.reject
@@ -100,7 +100,7 @@
ADD COLUMN id2 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
DROP INDEX idx1,
ADD FULLTEXT INDEX idx2(value);
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 2
+info: Records: 2 Duplicates: 0 Warnings: 0
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;

View file

@ -1,12 +0,0 @@
--- sync_ddl.result
+++ sync_ddl.reject
@@ -100,7 +100,7 @@
ADD COLUMN id2 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
DROP INDEX idx1,
ADD FULLTEXT INDEX idx2(value);
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 2
+info: Records: 2 Duplicates: 0 Warnings: 0
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;

View file

@ -610,7 +610,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, "");

View file

@ -585,7 +585,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;

View file

@ -843,6 +843,8 @@ public:
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;

View file

@ -3572,6 +3572,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.

View file

@ -4093,8 +4093,7 @@ public:
*/
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

View file

@ -6339,7 +6339,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)))

View file

@ -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;

View file

@ -2852,7 +2852,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
@ -2872,8 +2872,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);
@ -12286,7 +12285,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),
@ -14761,8 +14760,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()))

View file

@ -666,8 +666,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))

View file

@ -7247,7 +7247,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;

View file

@ -2150,7 +2150,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.
@ -2205,7 +2205,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
@ -2441,9 +2441,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 "));
@ -2469,9 +2469,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);
@ -2620,11 +2620,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)
{
@ -7371,9 +7366,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
@ -7392,7 +7384,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()))

View file

@ -2657,7 +2657,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);

View file

@ -2135,8 +2135,8 @@ static int sort_keys(KEY *a, KEY *b)
(b_flags & HA_KEY_HAS_PART_KEY_SEG));
}
return_if_nonzero((a_flags & HA_FULLTEXT) -
(b_flags & HA_FULLTEXT));
return_if_nonzero((a->algorithm == HA_KEY_ALG_FULLTEXT) -
(b->algorithm == HA_KEY_ALG_FULLTEXT));
/*
Prefer original key order. usable_key_parts contains here
@ -3161,25 +3161,30 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
switch (key->type) {
case Key::MULTIPLE:
key_info->flags= 0;
break;
key_info->flags= 0;
break;
case Key::FULLTEXT:
key_info->flags= HA_FULLTEXT;
if ((key_info->parser_name= &key->key_create_info.parser_name)->str)
key_info->flags= HA_FULLTEXT_legacy;
if (key->key_create_info.algorithm == HA_KEY_ALG_UNDEF)
key->key_create_info.algorithm= HA_KEY_ALG_FULLTEXT;
if ((key_info->parser_name= &key->key_create_info.parser_name)->str)
key_info->flags|= HA_USES_PARSER;
else
key_info->parser_name= 0;
break;
break;
case Key::SPATIAL:
key_info->flags= HA_SPATIAL;
break;
key_info->flags= HA_SPATIAL_legacy;
if (key->key_create_info.algorithm == HA_KEY_ALG_UNDEF)
key->key_create_info.algorithm= HA_KEY_ALG_RTREE;
break;
case Key::FOREIGN_KEY:
key_number--; // Skip this key
key_number--; // Skip this key
continue;
case Key::IGNORE_KEY:
DBUG_ASSERT(0);
break;
default:
case Key::PRIMARY:
case Key::UNIQUE:
key_info->flags = HA_NOSAME;
break;
}
@ -3214,7 +3219,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
*/
/* TODO: Add proper checks if handler supports key_type and algorithm */
if (key_info->flags & HA_SPATIAL)
if (key_info->algorithm == HA_KEY_ALG_RTREE)
{
if (!(file->ha_table_flags() & HA_CAN_RTREEKEYS))
{
@ -3222,21 +3227,10 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(TRUE);
}
if (key_info->user_defined_key_parts != 1)
{
my_error(ER_WRONG_ARGUMENTS, MYF(0), "SPATIAL INDEX");
DBUG_RETURN(TRUE);
}
}
else if (key_info->algorithm == HA_KEY_ALG_RTREE)
{
if ((key_info->user_defined_key_parts & 1) == 1)
{
my_error(ER_WRONG_ARGUMENTS, MYF(0), "RTREE INDEX");
DBUG_RETURN(TRUE);
}
/* TODO: To be deleted */
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RTREE INDEX");
DBUG_RETURN(TRUE);
}
/* Take block size from key part or table part */
@ -8815,7 +8809,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (!cfield->field->type_handler()->type_can_have_key_part() ||
!cfield->type_handler()->type_can_have_key_part() ||
/* spatial keys can't have sub-key length */
(key_info->flags & HA_SPATIAL) ||
key_info->algorithm == HA_KEY_ALG_RTREE ||
(cfield->field->field_length == key_part_length &&
!f_is_blob(key_part->key_type)) ||
(cfield->length &&
@ -8880,7 +8874,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_create_info.comment= key_info->comment;
key_create_info.is_ignored= key_info->is_ignored;
if (key_info->flags & HA_SPATIAL)
if (key_info->algorithm == HA_KEY_ALG_RTREE)
key_type= Key::SPATIAL;
else if (key_info->flags & HA_NOSAME)
{
@ -8899,7 +8893,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
goto err;
}
}
else if (key_info->flags & HA_FULLTEXT)
else if (key_info->algorithm == HA_KEY_ALG_FULLTEXT)
key_type= Key::FULLTEXT;
else
key_type= Key::MULTIPLE;

View file

@ -3125,15 +3125,18 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
}
/* Fix fulltext keys for old .frm files */
if (share->key_info[key].flags & HA_FULLTEXT)
share->key_info[key].algorithm= HA_KEY_ALG_FULLTEXT;
key_part= keyinfo->key_part;
uint key_parts= share->use_ext_keys ? keyinfo->ext_key_parts :
keyinfo->user_defined_key_parts;
if (keyinfo->algorithm == HA_KEY_ALG_LONG_HASH)
key_parts++;
if (keyinfo->algorithm == HA_KEY_ALG_UNDEF) // old .frm
{
if (keyinfo->flags & HA_FULLTEXT_legacy)
keyinfo->algorithm= HA_KEY_ALG_FULLTEXT;
else if (keyinfo->flags & HA_SPATIAL_legacy)
keyinfo->algorithm= HA_KEY_ALG_RTREE;
}
for (i=0; i < key_parts; key_part++, i++)
{
Field *field;

View file

@ -687,9 +687,8 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
/* For SPATIAL, FULLTEXT and HASH indexes (anything other than B-tree),
ignore the ASC/DESC attribute of columns. */
const uchar ha_reverse_sort=
key->algorithm > HA_KEY_ALG_BTREE || key->flags & (HA_FULLTEXT|HA_SPATIAL)
? 0 : HA_REVERSE_SORT;
const uchar ha_reverse_sort= key->algorithm > HA_KEY_ALG_BTREE
? 0 : HA_REVERSE_SORT;
for (key_part=key->key_part,key_part_end=key_part+key->user_defined_key_parts ;
key_part != key_part_end ;

View file

@ -101,17 +101,6 @@ int ha_blackhole::truncate()
DBUG_RETURN(0);
}
const char *ha_blackhole::index_type(uint key_number)
{
DBUG_ENTER("ha_blackhole::index_type");
DBUG_RETURN((table_share->key_info[key_number].flags & HA_FULLTEXT) ?
"FULLTEXT" :
(table_share->key_info[key_number].flags & HA_SPATIAL) ?
"SPATIAL" :
(table_share->key_info[key_number].algorithm ==
HA_KEY_ALG_RTREE) ? "RTREE" : "BTREE");
}
int ha_blackhole::write_row(const uchar * buf)
{
DBUG_ENTER("ha_blackhole::write_row");

View file

@ -45,7 +45,6 @@ public:
The name of the index type that will be used for display
don't implement this method unless you really have indexes
*/
const char *index_type(uint key_number) override;
ulonglong table_flags() const override
{
return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |

View file

@ -102,7 +102,6 @@ public:
delete file_buff;
free_root(&blobroot, MYF(0));
}
const char *index_type(uint inx) override { return "NONE"; }
ulonglong table_flags() const override
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT |

View file

@ -66,12 +66,6 @@ public:
ha_example(handlerton *hton, TABLE_SHARE *table_arg);
~ha_example() = default;
/** @brief
The name of the index type that will be used for display.
Don't implement this method unless you really have indexes.
*/
const char *index_type(uint inx) override { return "HASH"; }
/** @brief
This is a list of flags that indicate what functionality the storage engine
implements. The current table flags are documented in handler.h

View file

@ -33,11 +33,6 @@ public:
ha_heap(handlerton *hton, TABLE_SHARE *table);
~ha_heap() = default;
handler *clone(const char *name, MEM_ROOT *mem_root) override;
const char *index_type(uint inx) override
{
return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
"BTREE" : "HASH");
}
/* Rows also use a fixed-size format */
enum row_type get_row_type() const override { return ROW_TYPE_FIXED; }
ulonglong table_flags() const override

View file

@ -5026,32 +5026,6 @@ ha_innobase::table_type() const
return(innobase_hton_name);
}
/****************************************************************//**
Returns the index type.
@return index type */
const char*
ha_innobase::index_type(
/*====================*/
uint keynr) /*!< : index number */
{
dict_index_t* index = innobase_get_index(keynr);
if (!index) {
return "Corrupted";
}
if (index->type & DICT_FTS) {
return("FULLTEXT");
}
if (dict_index_is_spatial(index)) {
return("SPATIAL");
}
return("BTREE");
}
/****************************************************************//**
Returns the operations supported for indexes.
@return flags of supported operations */
@ -5069,7 +5043,7 @@ ha_innobase::index_flags(
/* For spatial index, we don't support descending scan
and ICP so far. */
if (table_share->key_info[key].flags & HA_SPATIAL) {
if (table_share->key_info[key].algorithm == HA_KEY_ALG_RTREE) {
return HA_READ_NEXT | HA_READ_ORDER| HA_READ_RANGE
| HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR;
}
@ -10853,12 +10827,12 @@ create_index(
ut_a(!key->name.streq(GEN_CLUST_INDEX));
const ha_table_option_struct& o = *form->s->option_struct;
if (key->flags & (HA_SPATIAL | HA_FULLTEXT)) {
if (key->algorithm == HA_KEY_ALG_FULLTEXT ||
key->algorithm == HA_KEY_ALG_RTREE) {
/* Only one of these can be specified at a time. */
ut_ad(~key->flags & (HA_SPATIAL | HA_FULLTEXT));
ut_ad(!(key->flags & HA_NOSAME));
index = dict_mem_index_create(table, key->name.str,
(key->flags & HA_SPATIAL)
key->algorithm == HA_KEY_ALG_RTREE
? DICT_SPATIAL : DICT_FTS,
key->user_defined_key_parts);
@ -10974,7 +10948,7 @@ create_index(
& HA_REVERSE_SORT);
}
ut_ad(key->flags & HA_FULLTEXT || !(index->type & DICT_FTS));
ut_ad(key->algorithm == HA_KEY_ALG_FULLTEXT || !(index->type & DICT_FTS));
/* Even though we've defined max_supported_key_part_length, we
still do our own checking using field_lengths to be absolutely
@ -11266,7 +11240,7 @@ create_table_info_t::check_table_options()
break;
}
for (ulint i = 0; i < m_form->s->keys; i++) {
if (m_form->key_info[i].flags & HA_SPATIAL) {
if (m_form->key_info[i].algorithm == HA_KEY_ALG_RTREE) {
push_warning(m_thd,
Sql_condition::WARN_LEVEL_WARN,
HA_ERR_UNSUPPORTED,
@ -11519,7 +11493,7 @@ bool create_table_info_t::innobase_table_flags()
for (uint i = 0; i < m_form->s->keys; i++) {
const KEY* key = &m_form->key_info[i];
if (key->flags & HA_FULLTEXT) {
if (key->algorithm == HA_KEY_ALG_FULLTEXT) {
m_flags2 |= DICT_TF2_FTS;
/* We don't support FTS indexes in temporary
@ -11968,7 +11942,8 @@ create_table_info_t::gcols_in_fulltext_or_spatial()
{
for (ulint i = 0; i < m_form->s->keys; i++) {
const KEY* key = m_form->key_info + i;
if (!(key->flags & (HA_SPATIAL | HA_FULLTEXT))) {
if (key->algorithm != HA_KEY_ALG_RTREE &&
key->algorithm != HA_KEY_ALG_FULLTEXT) {
continue;
}
for (ulint j = 0; j < key->user_defined_key_parts; j++) {
@ -14896,8 +14871,8 @@ ha_innobase::info_low(
for (j = 0; j < key->ext_key_parts; j++) {
if ((key->flags & HA_FULLTEXT)
|| (key->flags & HA_SPATIAL)) {
if ((key->algorithm == HA_KEY_ALG_FULLTEXT)
|| (key->algorithm == HA_KEY_ALG_RTREE)) {
/* The record per key does not apply to
FTS or Spatial indexes. */

View file

@ -65,8 +65,6 @@ public:
const char* table_type() const override;
const char* index_type(uint key_number) override;
Table_flags table_flags() const override;
ulong index_flags(uint idx, uint part, bool all_parts) const override;

View file

@ -1476,7 +1476,7 @@ static uint innobase_fulltext_exist(const TABLE* table)
uint count = 0;
for (uint i = 0; i < table->s->keys; i++) {
if (table->key_info[i].flags & HA_FULLTEXT) {
if (table->key_info[i].algorithm == HA_KEY_ALG_FULLTEXT) {
count++;
}
}
@ -1514,7 +1514,7 @@ innobase_spatial_exist(
const TABLE* table)
{
for (uint i = 0; i < table->s->keys; i++) {
if (table->key_info[i].flags & HA_SPATIAL) {
if (table->key_info[i].algorithm == HA_KEY_ALG_RTREE) {
return(true);
}
}
@ -2447,7 +2447,7 @@ innodb_instant_alter_column_allowed_reason:
/* Do not support adding/droping a virtual column, while
there is a table rebuild caused by adding a new FTS_DOC_ID */
if ((new_key->flags & HA_FULLTEXT) && add_drop_v_cols
if ((new_key->algorithm == HA_KEY_ALG_FULLTEXT) && add_drop_v_cols
&& !DICT_TF2_FLAG_IS_SET(m_prebuilt->table,
DICT_TF2_FTS_HAS_DOC_ID)) {
ha_alter_info->unsupported_reason =
@ -2757,10 +2757,9 @@ cannot_create_many_fulltext_index:
const KEY* key =
&ha_alter_info->key_info_buffer[
ha_alter_info->index_add_buffer[i]];
if (key->flags & HA_FULLTEXT) {
if (key->algorithm == HA_KEY_ALG_FULLTEXT) {
DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK
& ~(HA_FULLTEXT
| HA_PACK_KEY
& ~(HA_PACK_KEY
| HA_GENERATED_KEY
| HA_BINARY_PACK_KEY)));
if (add_fulltext) {
@ -2797,7 +2796,7 @@ cannot_create_many_fulltext_index:
&fts_doc_col_no, &num_v, true);
}
if (online && (key->flags & HA_SPATIAL)) {
if (online && key->algorithm == HA_KEY_ALG_RTREE) {
if (ha_alter_info->online) {
ha_alter_info->unsupported_reason = my_get_err_msg(
@ -3036,7 +3035,7 @@ innobase_find_equiv_index(
const KEY* key = &keys[*it];
if (key->user_defined_key_parts < n_cols
|| key->flags & HA_SPATIAL) {
|| key->algorithm == HA_KEY_ALG_RTREE) {
no_match:
continue;
}
@ -3878,15 +3877,13 @@ innobase_create_index_def(
index->rebuild = new_clustered;
if (key_clustered) {
DBUG_ASSERT(!(key->flags & (HA_FULLTEXT | HA_SPATIAL)));
DBUG_ASSERT(key->algorithm <= HA_KEY_ALG_BTREE);
DBUG_ASSERT(key->flags & HA_NOSAME);
index->ind_type = DICT_CLUSTERED | DICT_UNIQUE;
} else if (key->flags & HA_FULLTEXT) {
DBUG_ASSERT(!(key->flags & (HA_SPATIAL | HA_NOSAME)));
} else if (key->algorithm == HA_KEY_ALG_FULLTEXT) {
DBUG_ASSERT(!(key->flags & HA_NOSAME));
DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK
& ~(HA_FULLTEXT
| HA_PACK_KEY
| HA_BINARY_PACK_KEY)));
& ~(HA_PACK_KEY | HA_BINARY_PACK_KEY)));
index->ind_type = DICT_FTS;
/* Note: key->parser is only parser name,
@ -3913,7 +3910,7 @@ innobase_create_index_def(
index->parser = &fts_default_parser;);
ut_ad(index->parser);
}
} else if (key->flags & HA_SPATIAL) {
} else if (key->algorithm == HA_KEY_ALG_RTREE) {
DBUG_ASSERT(!(key->flags & HA_NOSAME));
index->ind_type = DICT_SPATIAL;
ut_ad(n_fields == 1);
@ -3936,7 +3933,7 @@ innobase_create_index_def(
index->ind_type = (key->flags & HA_NOSAME) ? DICT_UNIQUE : 0;
}
if (!(key->flags & HA_SPATIAL)) {
if (key->algorithm != HA_KEY_ALG_RTREE) {
for (i = 0; i < n_fields; i++) {
innobase_create_index_field_def(
new_clustered, altered_table,
@ -5154,7 +5151,7 @@ innobase_check_gis_columns(
const KEY& key = ha_alter_info->key_info_buffer[
ha_alter_info->index_add_buffer[key_num]];
if (!(key.flags & HA_SPATIAL)) {
if (key.algorithm != HA_KEY_ALG_RTREE) {
continue;
}
@ -8131,14 +8128,13 @@ check_if_ok_to_rename:
for (ulint i = 0; i < ha_alter_info->key_count; i++) {
const KEY* key = &ha_alter_info->key_info_buffer[i];
if (key->flags & HA_FULLTEXT) {
if (key->algorithm == HA_KEY_ALG_FULLTEXT) {
/* The column length does not matter for
fulltext search indexes. But, UNIQUE
fulltext indexes are not supported. */
DBUG_ASSERT(!(key->flags & HA_NOSAME));
DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK
& ~(HA_FULLTEXT
| HA_PACK_KEY
& ~(HA_PACK_KEY
| HA_BINARY_PACK_KEY)));
add_fts_idx = true;
continue;

View file

@ -1337,7 +1337,8 @@ static int maria_chk(HA_CHECK *param, char *filename)
*/
my_bool update_index=1;
for (key=0 ; key < share->base.keys; key++)
if (share->keyinfo[key].flag & (HA_BINARY_PACK_KEY|HA_FULLTEXT))
if (share->keyinfo[key].flag & HA_BINARY_PACK_KEY ||
share->keyinfo[key].key_alg == HA_KEY_ALG_FULLTEXT)
update_index=0;
error=maria_sort_records(param,info,filename,param->opt_sort_key,
@ -1693,7 +1694,7 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name)
{
keyseg=keyinfo->seg;
if (keyinfo->flag & HA_NOSAME) text="unique ";
else if (keyinfo->flag & HA_FULLTEXT) text="fulltext ";
else if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT) text="fulltext ";
else text="multip.";
pos=buff;
@ -1879,7 +1880,7 @@ static int maria_sort_records(HA_CHECK *param,
param->error_printed=0;
DBUG_RETURN(0); /* Nothing to do */
}
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
_ma_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d",
name,sort_key+1);

View file

@ -99,7 +99,7 @@ int main(int argc,char *argv[])
aio->info=info;
if ((inx >= info->s->base.keys) ||
!(info->s->keyinfo[inx].flag & HA_FULLTEXT))
info->s->keyinfo[inx].key_alg != HA_KEY_ALG_FULLTEXT)
{
printf("Key %d in table %s is not a FULLTEXT key\n", inx,
info->s->open_file_name.str);

View file

@ -490,8 +490,7 @@ static int table2maria(TABLE *table_arg, data_file_type row_type,
if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME),
recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF),
keydef_out, share->keys * sizeof(MARIA_KEYDEF),
&keyseg,
(share->key_parts + share->keys) * sizeof(HA_KEYSEG),
&keyseg, (share->key_parts + share->keys) * sizeof(HA_KEYSEG),
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */
keydef= *keydef_out;
@ -499,11 +498,10 @@ static int table2maria(TABLE *table_arg, data_file_type row_type,
pos= table_arg->key_info;
for (i= 0; i < share->keys; i++, pos++)
{
keydef[i].flag= (uint16) (pos->flags & (HA_NOSAME | HA_FULLTEXT |
HA_SPATIAL));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?
(pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :
pos->algorithm;
keydef[i].flag= (uint16) (pos->flags & (HA_NOSAME | HA_FULLTEXT_legacy |
HA_SPATIAL_legacy));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ? HA_KEY_ALG_BTREE
: pos->algorithm;
keydef[i].block_length= pos->block_size;
keydef[i].seg= keyseg;
keydef[i].keysegs= pos->user_defined_key_parts;
@ -728,28 +726,11 @@ int maria_check_definition(MARIA_KEYDEF *t1_keyinfo,
{
HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg;
HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg;
if (t1_keyinfo[i].flag & HA_FULLTEXT && t2_keyinfo[i].flag & HA_FULLTEXT)
if ((t1_keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT &&
t2_keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT) ||
(t1_keyinfo[i].key_alg == HA_KEY_ALG_RTREE &&
t2_keyinfo[i].key_alg == HA_KEY_ALG_RTREE))
continue;
else if (t1_keyinfo[i].flag & HA_FULLTEXT ||
t2_keyinfo[i].flag & HA_FULLTEXT)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_fulltext= %d, t2_fulltext=%d",
MY_TEST(t1_keyinfo[i].flag & HA_FULLTEXT),
MY_TEST(t2_keyinfo[i].flag & HA_FULLTEXT)));
DBUG_RETURN(1);
}
if (t1_keyinfo[i].flag & HA_SPATIAL && t2_keyinfo[i].flag & HA_SPATIAL)
continue;
else if (t1_keyinfo[i].flag & HA_SPATIAL ||
t2_keyinfo[i].flag & HA_SPATIAL)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_spatial= %d, t2_spatial=%d",
MY_TEST(t1_keyinfo[i].flag & HA_SPATIAL),
MY_TEST(t2_keyinfo[i].flag & HA_SPATIAL)));
DBUG_RETURN(1);
}
if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs ||
t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg)
{
@ -1028,17 +1009,6 @@ static const char *ha_maria_exts[]=
};
const char *ha_maria::index_type(uint key_number)
{
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
"FULLTEXT" :
(table->key_info[key_number].flags & HA_SPATIAL) ?
"SPATIAL" :
(table->key_info[key_number].algorithm == HA_KEY_ALG_RTREE) ?
"RTREE" : "BTREE");
}
ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const
{
ulong flags;
@ -1046,8 +1016,7 @@ ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const
table_share->key_info[inx].algorithm == HA_KEY_ALG_UNIQUE_HASH)
flags= 0;
else
if ((table_share->key_info[inx].flags & HA_SPATIAL ||
table_share->key_info[inx].algorithm == HA_KEY_ALG_RTREE))
if (table_share->key_info[inx].algorithm == HA_KEY_ALG_RTREE)
{
/* All GIS scans are non-ROR scans. We also disable IndexConditionPushdown */
flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
@ -2267,9 +2236,10 @@ void ha_maria::start_bulk_insert(ha_rows rows, uint flags)
(!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES));
for (i=0 ; i < share->base.keys ; i++,key++)
{
if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY | HA_RTREE_INDEX)) &&
! maria_too_big_key_for_sort(key,rows) && share->base.auto_key != i+1 &&
if (!(key->flag & HA_AUTO_KEY) && share->base.auto_key != i+1 &&
! maria_too_big_key_for_sort(key,rows) &&
(all_keys || !(key->flag & HA_NOSAME)) &&
table->key_info[i].algorithm != HA_KEY_ALG_RTREE &&
table->key_info[i].algorithm != HA_KEY_ALG_LONG_HASH)
{
maria_clear_key_active(share->state.key_map, i);

View file

@ -62,7 +62,6 @@ public:
ha_maria(handlerton *hton, TABLE_SHARE * table_arg);
~ha_maria() = default;
handler *clone(const char *name, MEM_ROOT *mem_root) override final;
const char *index_type(uint key_number) override final;
ulonglong table_flags() const override
{ return int_table_flags; }
ulong index_flags(uint inx, uint part, bool all_parts) const override final;

View file

@ -570,11 +570,11 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
if ((!(param->testflag & T_SILENT)))
printf ("- check data record references index: %d\n",key+1);
if (keyinfo->flag & (HA_FULLTEXT | HA_SPATIAL))
if (keyinfo->key_alg > HA_KEY_ALG_BTREE)
full_text_keys++;
if (share->state.key_root[key] == HA_OFFSET_ERROR)
{
if (share->state.state.records != 0 && !(keyinfo->flag & HA_FULLTEXT))
if (share->state.state.records != 0 && keyinfo->key_alg != HA_KEY_ALG_FULLTEXT)
_ma_check_print_error(param, "Key tree %u is empty", key + 1);
goto do_stat;
}
@ -595,7 +595,7 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
param->max_level=0;
if (chk_index(param, info,keyinfo, &page, &keys, param->key_crc+key,1))
DBUG_RETURN(-1);
if (!(keyinfo->flag & (HA_FULLTEXT | HA_SPATIAL | HA_RTREE_INDEX)))
if (keyinfo->key_alg <= HA_KEY_ALG_BTREE)
{
if (keys != share->state.state.records)
{
@ -879,7 +879,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
DBUG_DUMP("buff", anc_page->buff, anc_page->size);
/* TODO: implement appropriate check for RTree keys */
if (keyinfo->flag & (HA_SPATIAL | HA_RTREE_INDEX))
if (keyinfo->key_alg == HA_KEY_ALG_RTREE)
DBUG_RETURN(0);
alloc_on_stack(*param->stack_end_ptr, temp_buff, temp_buff_alloced,
@ -1038,7 +1038,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
(*key_checksum)+= maria_byte_checksum(tmp_key.data, tmp_key.data_length);
record= _ma_row_pos_from_key(&tmp_key);
if (keyinfo->flag & HA_FULLTEXT) /* special handling for ft2 */
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT) /* special handling for ft2 */
{
uint off;
int subkeys;
@ -1208,7 +1208,7 @@ static int check_keys_in_record(HA_CHECK *param, MARIA_HA *info, int extend,
if (maria_is_key_active(share->state.key_map, keynr))
{
MARIA_KEY key;
if (!(keyinfo->flag & HA_FULLTEXT))
if (keyinfo->key_alg != HA_KEY_ALG_FULLTEXT)
{
(*keyinfo->make_key)(info, &key, keynr, info->lastkey_buff, record,
start_recpos, 0);
@ -1218,8 +1218,7 @@ static int check_keys_in_record(HA_CHECK *param, MARIA_HA *info, int extend,
/* We don't need to lock the key tree here as we don't allow
concurrent threads when running maria_chk
*/
int search_result=
(keyinfo->flag & (HA_SPATIAL | HA_RTREE_INDEX)) ?
int search_result= keyinfo->key_alg == HA_KEY_ALG_RTREE ?
maria_rtree_find_first(info, &key, MBR_EQUAL | MBR_DATA) :
_ma_search(info, &key, SEARCH_SAME, share->state.key_root[keynr]);
if (search_result)
@ -2212,8 +2211,7 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info, my_bool extend)
for (key=0 ; key < share->base.keys; key++)
{
if (param->tmp_key_crc[key] != param->key_crc[key] &&
!(share->keyinfo[key].flag &
(HA_FULLTEXT | HA_SPATIAL | HA_RTREE_INDEX)))
share->keyinfo[key].key_alg <= HA_KEY_ALG_BTREE)
{
_ma_check_print_error(param,"Checksum for key: %2d doesn't match "
"checksum for records",
@ -3042,7 +3040,7 @@ static int writekeys(MARIA_SORT_PARAM *sort_param)
{
if (maria_is_key_active(share->state.key_map, i))
{
if (share->keyinfo[i].flag & HA_FULLTEXT )
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_ma_ft_add(info, i, key_buff, record, filepos))
goto err;
@ -3067,7 +3065,7 @@ static int writekeys(MARIA_SORT_PARAM *sort_param)
{
if (maria_is_key_active(share->state.key_map, i))
{
if (share->keyinfo[i].flag & HA_FULLTEXT)
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_ma_ft_del(info,i,key_buff,record,filepos))
break;
@ -3358,7 +3356,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
goto err;
}
if ((nod_flag= page.node) || keyinfo->flag & HA_FULLTEXT)
if ((nod_flag= page.node) || keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
keypos= page.buff + share->keypage_header + nod_flag;
endpos= page.buff + page.size;
@ -3384,7 +3382,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
!(*keyinfo->get_key)(&key, page.flag, nod_flag, &keypos))
break;
DBUG_ASSERT(keypos <= endpos);
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint off;
int subkeys;
@ -3977,7 +3975,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
share->state.state.records=share->state.state.del=share->state.split=0;
share->state.state.empty=0;
if (sort_param.keyinfo->flag & HA_FULLTEXT)
if (sort_param.keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param.keyinfo->seg->charset->mbmaxlen;
@ -4522,7 +4520,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
istep=1;
if ((!(param->testflag & T_SILENT)))
printf ("- Fixing index %d\n",key+1);
if (sort_param[i].keyinfo->flag & HA_FULLTEXT)
if (sort_param[i].keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
sort_param[i].key_read=sort_maria_ft_key_read;
sort_param[i].key_write=sort_maria_ft_key_write;
@ -4569,7 +4567,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
total_key_length+=sort_param[i].key_length;
#endif
if (sort_param[i].keyinfo->flag & HA_FULLTEXT)
if (sort_param[i].keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint ft_max_word_len_for_sort=
(FT_MAX_WORD_LEN_FOR_SORT *
@ -6617,16 +6615,16 @@ static ha_checksum maria_byte_checksum(const uchar *buf, uint length)
my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows)
{
uint key_maxlength=key->maxlength;
if (key->flag & HA_FULLTEXT)
if (key->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
key->seg->charset->mbmaxlen;
key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
return (ulonglong) rows * key_maxlength > maria_max_temp_length;
}
return (key->flag & HA_SPATIAL) ||
(key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
((ulonglong) rows * key_maxlength >
(ulonglong) maria_max_temp_length));
return key->key_alg == HA_KEY_ALG_RTREE ||
(key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY) &&
((ulonglong) rows * key_maxlength > maria_max_temp_length));
}
/*

View file

@ -464,14 +464,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
min_key_length= key_length= pointer;
if (keydef->key_alg == HA_KEY_ALG_RTREE)
keydef->flag|= HA_RTREE_INDEX; /* For easier tests */
if (keydef->flag & HA_SPATIAL)
{
/* BAR TODO to support 3D and more dimensions in the future */
uint sp_segs=SPDIMS*2;
keydef->flag=HA_SPATIAL;
keydef->flag=HA_SPATIAL_legacy;
if (flags & HA_DONT_TOUCH_DATA)
{
/*
@ -500,9 +496,9 @@ int maria_create(const char *name, enum data_file_type datafile_type,
length++; /* At least one length uchar */
min_key_length++;
}
else if (keydef->flag & HA_FULLTEXT)
else if (keydef->key_alg == HA_KEY_ALG_FULLTEXT)
{
keydef->flag=HA_FULLTEXT | HA_PACK_KEY | HA_VAR_LENGTH_KEY;
keydef->flag=HA_FULLTEXT_legacy | HA_PACK_KEY | HA_VAR_LENGTH_KEY;
options|=HA_OPTION_PACK_KEYS; /* Using packed keys */
for (j=0, keyseg=keydef->seg ; (int) j < keydef->keysegs ;
@ -940,7 +936,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
DBUG_PRINT("info", ("write key and keyseg definitions"));
for (i=0 ; i < share.base.keys - uniques; i++)
{
uint sp_segs=(keydefs[i].flag & HA_SPATIAL) ? 2*SPDIMS : 0;
uint sp_segs=keydefs[i].key_alg == HA_KEY_ALG_RTREE ? 2*SPDIMS : 0;
if (_ma_keydef_write(file, &keydefs[i]))
goto err;

View file

@ -77,7 +77,7 @@ int maria_delete(MARIA_HA *info,const uchar *record)
if (maria_is_key_active(share->state.key_map, i))
{
keyinfo->version++;
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_ma_ft_del(info, i, old_key, record, info->cur_row.lastpos))
goto err;
@ -232,9 +232,9 @@ my_bool _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEY *key,
result= 1;
goto err;
}
if ((error= d_search(info, key, (keyinfo->flag & HA_FULLTEXT ?
SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT:
SEARCH_SAME),
if ((error= d_search(info, key, keyinfo->key_alg == HA_KEY_ALG_FULLTEXT ?
SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT :
SEARCH_SAME,
&page)))
{
if (error < 0)
@ -315,7 +315,7 @@ static int d_search(MARIA_HA *info, MARIA_KEY *key, uint32 comp_flag,
page_flag= anc_page->flag;
nod_flag= anc_page->node;
if (!flag && (keyinfo->flag & HA_FULLTEXT))
if (!flag && keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint off;
int subkeys;

View file

@ -385,7 +385,7 @@ void maria_ftparser_call_deinitializer(MARIA_HA *info)
{
MYSQL_FTPARSER_PARAM *ftparser_param=
&info->ftparser_param[keyinfo->ftkey_nr*MAX_PARAM_NR + j];
if (keyinfo->flag & HA_FULLTEXT && ftparser_param->mysql_add_word)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT && ftparser_param->mysql_add_word)
{
if (keyinfo->parser->deinit)
keyinfo->parser->deinit(ftparser_param);

View file

@ -201,7 +201,7 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr,
int_key->flag= 0; /* Always return full key */
int_key->keyinfo= info->s->keyinfo + keynr;
is_ft= int_key->keyinfo->flag & HA_FULLTEXT;
is_ft= int_key->keyinfo->key_alg == HA_KEY_ALG_FULLTEXT;
for (keyseg= int_key->keyinfo->seg ; keyseg->type ;keyseg++)
{
enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type;
@ -373,7 +373,7 @@ MARIA_KEY *_ma_pack_key(register MARIA_HA *info, MARIA_KEY *int_key,
/* only key prefixes are supported */
DBUG_ASSERT(((keypart_map+1) & keypart_map) == 0);
is_ft= int_key->keyinfo->flag & HA_FULLTEXT;
is_ft= int_key->keyinfo->key_alg == HA_KEY_ALG_FULLTEXT;
for (keyseg=int_key->keyinfo->seg ; keyseg->type && keypart_map;
old+= keyseg->length, keyseg++)
{

View file

@ -760,14 +760,14 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
else if (pos->type == HA_KEYTYPE_BINARY)
pos->charset= &my_charset_bin;
}
if (keyinfo->flag & HA_SPATIAL)
if (keyinfo->key_alg == HA_KEY_ALG_RTREE)
{
uint sp_segs=SPDIMS*2;
keyinfo->seg=pos-sp_segs;
keyinfo->keysegs--;
versioning= 0;
}
else if (keyinfo->flag & HA_FULLTEXT)
else if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
versioning= 0;
DBUG_ASSERT(fulltext_keys);
@ -791,6 +791,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags,
memcpy(&share->ft2_keyinfo, keyinfo, sizeof(MARIA_KEYDEF));
share->ft2_keyinfo.keysegs=1;
share->ft2_keyinfo.flag=0;
share->ft2_keyinfo.key_alg=HA_KEY_ALG_BTREE;
share->ft2_keyinfo.keylength=
share->ft2_keyinfo.minlength=
share->ft2_keyinfo.maxlength=HA_FT_WLEN+share->base.rec_reflength;
@ -1404,7 +1405,7 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo)
keyinfo->ck_insert = _ma_ck_write;
keyinfo->ck_delete = _ma_ck_delete;
}
if (keyinfo->flag & HA_SPATIAL)
if (keyinfo->key_alg == HA_KEY_ALG_RTREE)
keyinfo->make_key= _ma_sp_make_key;
else
keyinfo->make_key= _ma_make_key;
@ -1459,12 +1460,16 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo)
/* set keyinfo->write_comp_flag */
if (keyinfo->flag & HA_SORT_ALLOWS_SAME)
keyinfo->write_comp_flag=SEARCH_BIGGER; /* Put after same key */
else if (keyinfo->flag & ( HA_NOSAME | HA_FULLTEXT))
else if (keyinfo->flag & HA_NOSAME)
{
keyinfo->write_comp_flag= SEARCH_FIND | SEARCH_UPDATE; /* No duplicates */
if (keyinfo->flag & HA_NULL_ARE_EQUAL)
keyinfo->write_comp_flag|= SEARCH_NULL_ARE_EQUAL;
}
else if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
keyinfo->write_comp_flag= SEARCH_FIND | SEARCH_UPDATE;
}
else
keyinfo->write_comp_flag= SEARCH_SAME; /* Keys in rec-pos order */
keyinfo->write_comp_flag|= SEARCH_INSERT;

View file

@ -313,7 +313,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
keyinfo->keylength+= (uint16) diff_length;
keyinfo->minlength+= (uint16) diff_length;
keyinfo->maxlength+= (uint16) diff_length;
keyinfo->seg[keyinfo->flag & HA_FULLTEXT ?
keyinfo->seg[keyinfo->key_alg == HA_KEY_ALG_FULLTEXT ?
FT_SEGS : keyinfo->keysegs].length= (uint16) rec_reflength;
}
if (share->ft2_keyinfo.seg)

View file

@ -1931,7 +1931,7 @@ _ma_calc_var_pack_key_length(const MARIA_KEY *int_key, uint nod_flag,
key_length= int_key->data_length + int_key->ref_length + nod_flag;
sort_order=0;
if ((keyinfo->flag & HA_FULLTEXT) &&
if ((keyinfo->key_alg == HA_KEY_ALG_FULLTEXT) &&
((keyseg->type == HA_KEYTYPE_TEXT) ||
(keyseg->type == HA_KEYTYPE_VARTEXT1) ||
(keyseg->type == HA_KEYTYPE_VARTEXT2)) &&

View file

@ -454,7 +454,7 @@ static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param)
}
if ((sort_keys= (uchar **)
my_malloc(PSI_INSTRUMENT_ME, (size_t)(keys*(sort_length+sizeof(char*))+
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
(sort_param->keyinfo->key_alg == HA_KEY_ALG_FULLTEXT ?
HA_FT_MAXBYTELEN : 0)), MYF(0))))
{
if (my_init_dynamic_array(PSI_INSTRUMENT_ME, &sort_param->buffpek, sizeof(BUFFPEK),

View file

@ -22,7 +22,6 @@
#include "ma_sp_defs.h"
#define MAX_REC_LENGTH 1024
#define KEYALG HA_KEY_ALG_RTREE
static void create_linestring(uchar *record,uint rownr);
static void print_record(uchar * record,my_off_t offs,const char * tail);
@ -89,8 +88,8 @@ int run_test(const char *filename)
keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1;
keyinfo[0].flag=HA_SPATIAL;
keyinfo[0].key_alg=KEYALG;
keyinfo[0].flag= 0;
keyinfo[0].key_alg=HA_KEY_ALG_RTREE;
keyinfo[0].seg[0].type= HA_KEYTYPE_BINARY;
keyinfo[0].seg[0].flag=0;

View file

@ -91,7 +91,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec,
{
if (maria_is_key_active(share->state.key_map, i))
{
if (keyinfo->flag & HA_FULLTEXT )
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_ma_ft_cmp(info,i,oldrec, newrec))
{
@ -212,7 +212,7 @@ err:
{
if (((ulonglong) 1 << i) & changed)
{
if (share->keyinfo[i].flag & HA_FULLTEXT)
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if ((flag++ && _ma_ft_del(info,i,new_key_buff,newrec,pos)) ||
_ma_ft_add(info,i,old_key_buff,oldrec,pos))

View file

@ -175,7 +175,7 @@ int maria_write(MARIA_HA *info, const uchar *record)
mysql_rwlock_wrlock(&keyinfo->root_lock);
keyinfo->version++;
}
if (keyinfo->flag & HA_FULLTEXT )
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_ma_ft_add(info,i, buff,record,filepos))
{
@ -357,7 +357,7 @@ err:
@todo RECOVERY BUG
The key deletes below should generate CLR_ENDs
*/
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_ma_ft_del(info,i,buff,record,filepos))
{
@ -662,7 +662,7 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key,
else
dup_key_pos= HA_OFFSET_ERROR;
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint off;
int subkeys;
@ -869,7 +869,7 @@ int _ma_insert(register MARIA_HA *info, MARIA_KEY *key,
if (a_length <= share->max_index_block_size)
{
if (share->max_index_block_size - a_length < 32 &&
(keyinfo->flag & HA_FULLTEXT) && key_pos == endpos &&
keyinfo->key_alg == HA_KEY_ALG_FULLTEXT && key_pos == endpos &&
share->base.key_reflength <= share->rec_reflength &&
share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))
{

View file

@ -1700,14 +1700,6 @@ my_bool _ma_write_abort_default(MARIA_HA *info);
int maria_delete_table_files(const char *name, my_bool temporary,
myf flags)__attribute__((visibility("default"))) ;
/*
This cannot be in my_base.h as it clashes with HA_SPATIAL.
But it was introduced for Aria engine, and is only used there.
So it can safely stay here, only visible to Aria
*/
#define HA_RTREE_INDEX 16384 /* For RTREE search */
#define MARIA_FLUSH_DATA 1
#define MARIA_FLUSH_INDEX 2
int _ma_flush_table_files(MARIA_HA *info, uint flush_data_or_index,

View file

@ -3893,7 +3893,7 @@ int ha_mroonga::storage_create_index_table(TABLE *table,
// TODO: Add NULL check for index_type
int key_alg = key_info->algorithm;
if (key_info->flags & HA_FULLTEXT) {
if (key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
index_table_flags |= GRN_OBJ_TABLE_PAT_KEY;
error = mrn_change_encoding(ctx, key_info->key_part->field->charset());
if (error) {
@ -3924,7 +3924,7 @@ int ha_mroonga::storage_create_index_table(TABLE *table,
DBUG_RETURN(error);
}
if (key_info->flags & HA_FULLTEXT) {
if (key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
grn_obj *tokenizer = find_tokenizer(key_info, tmp_share, i);
if (tokenizer) {
grn_info_type info_type = GRN_INFO_DEFAULT_TOKENIZER;
@ -3946,7 +3946,7 @@ int ha_mroonga::storage_create_index_table(TABLE *table,
{
grn_obj *normalizer = NULL;
Field *field = &(key_info->key_part->field[0]);
if (key_info->flags & HA_FULLTEXT) {
if (key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
if (have_custom_normalizer(key_info) ||
should_normalize(field)) {
normalizer = find_normalizer(key_info);
@ -4041,7 +4041,7 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
if (tokenizer) {
index_column_flags |= GRN_OBJ_WITH_POSITION;
}
if (is_multiple_column_index && (key_info->flags & HA_FULLTEXT)) {
if (is_multiple_column_index && key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
index_column_flags |= GRN_OBJ_WITH_SECTION;
}
}
@ -4069,7 +4069,7 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
mrn_change_encoding(ctx, system_charset_info);
if (is_multiple_column_index) {
if (key_info->flags & HA_FULLTEXT) {
if (key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
grn_obj source_ids;
GRN_UINT32_INIT(&source_ids, GRN_OBJ_VECTOR);
@ -4551,7 +4551,7 @@ int ha_mroonga::storage_reindex()
bool is_multiple_column_index =
(KEY_N_KEY_PARTS(&(key_info[i])) != 1 &&
!(key_info[i].flags & HA_FULLTEXT));
key_info[i].algorithm != HA_KEY_ALG_FULLTEXT);
if (n_columns == 1 || is_multiple_column_index) {
grn_table_truncate(ctx, grn_index_tables[i]);
@ -5805,7 +5805,7 @@ bool ha_mroonga::wrapper_is_target_index(KEY *key_info)
{
MRN_DBUG_ENTER_METHOD();
bool target_index =
(key_info->algorithm == HA_KEY_ALG_FULLTEXT) || mrn_is_geo_key(key_info);
key_info->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key_info);
DBUG_PRINT("info", ("mroonga: %s", target_index ? "true" : "false"));
DBUG_RETURN(target_index);
}
@ -6264,7 +6264,7 @@ int ha_mroonga::storage_write_row_multiple_column_indexes(const uchar *buf,
KEY *key_info = &(table->key_info[i]);
if (KEY_N_KEY_PARTS(key_info) == 1 || (key_info->flags & HA_FULLTEXT)) {
if (KEY_N_KEY_PARTS(key_info) == 1 || key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
continue;
}
@ -6859,7 +6859,7 @@ int ha_mroonga::storage_update_row_index(const uchar *old_data,
KEY *key_info = &(table->key_info[i]);
if (KEY_N_KEY_PARTS(key_info) == 1 || (key_info->flags & HA_FULLTEXT)) {
if (KEY_N_KEY_PARTS(key_info) == 1 || key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
continue;
}
@ -7218,7 +7218,7 @@ int ha_mroonga::storage_delete_row_index(const uchar *buf)
KEY *key_info = &(table->key_info[i]);
if (KEY_N_KEY_PARTS(key_info) == 1 || (key_info->flags & HA_FULLTEXT)) {
if (KEY_N_KEY_PARTS(key_info) == 1 || key_info->algorithm == HA_KEY_ALG_FULLTEXT) {
continue;
}
@ -12972,7 +12972,7 @@ int ha_mroonga::storage_truncate_index()
if (
!(key_info->flags & HA_NOSAME) &&
(KEY_N_KEY_PARTS(key_info) == 1 || (key_info->flags & HA_FULLTEXT))
(KEY_N_KEY_PARTS(key_info) == 1 || key_info->algorithm == HA_KEY_ALG_FULLTEXT)
) {
continue;
}
@ -13688,7 +13688,7 @@ int ha_mroonga::wrapper_disable_indexes_mroonga(key_map map, bool persist)
}
KEY *key_info = table_share->key_info;
for (i = 0; i < table_share->keys; i++) {
if (!(key_info[i].flags & HA_FULLTEXT) &&
if (key_info[i].algorithm != HA_KEY_ALG_FULLTEXT &&
!mrn_is_geo_key(&key_info[i])) {
continue;
}
@ -13792,7 +13792,7 @@ int ha_mroonga::wrapper_enable_indexes_mroonga(key_map map, bool persist)
mrn_set_bitmap_by_key(table->read_set, p_key_info);
mrn::PathMapper mapper(share->table_name);
for (i = 0, j = 0; i < n_keys; i++) {
if (!(key_info[i].flags & HA_FULLTEXT) &&
if (key_info[i].algorithm != HA_KEY_ALG_FULLTEXT &&
!mrn_is_geo_key(&key_info[i])) {
j++;
continue;
@ -13806,7 +13806,7 @@ int ha_mroonga::wrapper_enable_indexes_mroonga(key_map map, bool persist)
index_columns[i] = NULL;
if (!grn_index_columns[i]) {
if (
(key_info[i].flags & HA_FULLTEXT) &&
(key_info[i].algorithm == HA_KEY_ALG_FULLTEXT) &&
(error = wrapper_create_index_fulltext(mapper.table_name(),
i, &key_info[i],
index_tables, index_columns,
@ -13900,7 +13900,7 @@ int ha_mroonga::storage_enable_indexes(key_map map, bool persist)
}
if (
KEY_N_KEY_PARTS(&(key_info[i])) != 1 &&
!(key_info[i].flags & HA_FULLTEXT)
key_info[i].algorithm != HA_KEY_ALG_FULLTEXT
) {
mrn_set_bitmap_by_key(table->read_set, &key_info[i]);
have_multiple_column_index = true;
@ -14032,7 +14032,7 @@ int ha_mroonga::wrapper_fill_indexes(THD *thd, KEY *key_info,
uint k;
for (k = 0; k < n_keys; k++) {
tmp_key_info = &key_info[k];
if (!(tmp_key_info->flags & HA_FULLTEXT) &&
if (tmp_key_info->algorithm != HA_KEY_ALG_FULLTEXT &&
!mrn_is_geo_key(tmp_key_info)) {
continue;
}
@ -14104,7 +14104,7 @@ int ha_mroonga::wrapper_recreate_indexes(THD *thd)
grn_table = NULL;
mrn_set_bitmap_by_key(table->read_set, p_key_info);
for (i = 0; i < n_keys; i++) {
if (!(key_info[i].flags & HA_FULLTEXT) && !mrn_is_geo_key(&key_info[i])) {
if (key_info[i].algorithm != HA_KEY_ALG_FULLTEXT && !mrn_is_geo_key(&key_info[i])) {
continue;
}
mrn::IndexTableName index_table_name(mapper.table_name(),
@ -14423,7 +14423,7 @@ int ha_mroonga::storage_add_index_multiple_columns(KEY *key_info,
KEY *current_key_info = key_info + i;
if (
KEY_N_KEY_PARTS(current_key_info) == 1 ||
(current_key_info->flags & HA_FULLTEXT)
current_key_info->algorithm == HA_KEY_ALG_FULLTEXT
) {
continue;
}
@ -14562,7 +14562,7 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
n_keys = ha_alter_info->index_drop_count;
for (i = 0; i < n_keys; ++i) {
const KEY *key = ha_alter_info->index_drop_buffer[i];
if (key->flags & HA_FULLTEXT || mrn_is_geo_key(key)) {
if (key->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key)) {
result_mroonga = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
} else {
memcpy(&alter_index_drop_buffer[alter_index_drop_count],
@ -14577,7 +14577,7 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
for (i = 0; i < n_keys; ++i) {
const KEY *key =
&altered_table->key_info[ha_alter_info->index_add_buffer[i]];
if (key->flags & HA_FULLTEXT || mrn_is_geo_key(key)) {
if (key->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key)) {
result_mroonga = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
} else {
alter_index_add_buffer[alter_index_add_count] =
@ -14592,7 +14592,7 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter(
n_keys = ha_alter_info->key_count;
for (i = 0; i < n_keys; ++i) {
const KEY *key = &altered_table->key_info[i];
if (!(key->flags & HA_FULLTEXT || mrn_is_geo_key(key))) {
if (!(key->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key))) {
memcpy(&alter_key_info_buffer[alter_key_count],
&ha_alter_info->key_info_buffer[i], sizeof(KEY));
memcpy(&wrap_altered_table_key_info[alter_key_count],
@ -14760,7 +14760,7 @@ bool ha_mroonga::wrapper_inplace_alter_table(
n_keys = ha_alter_info->index_drop_count;
for (i = 0; i < n_keys; ++i) {
const KEY *key = ha_alter_info->index_drop_buffer[i];
if (!(key->flags & HA_FULLTEXT || mrn_is_geo_key(key))) {
if (!(key->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key))) {
continue;
}
while (strcmp(key_info[j].name.str, key->name.str)) {
@ -14811,7 +14811,7 @@ bool ha_mroonga::wrapper_inplace_alter_table(
for (i = 0; i < n_keys; ++i) {
uint key_pos = ha_alter_info->index_add_buffer[i];
KEY *key = &altered_table->key_info[key_pos];
if (!(key->flags & HA_FULLTEXT || mrn_is_geo_key(key))) {
if (!(key->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key))) {
continue;
}
if (share->disable_keys) {
@ -14823,7 +14823,7 @@ bool ha_mroonga::wrapper_inplace_alter_table(
}
DBUG_PRINT("info", ("mroonga: add key pos=%u", key_pos));
if (
(key->flags & HA_FULLTEXT) &&
(key->algorithm == HA_KEY_ALG_FULLTEXT) &&
(error = wrapper_create_index_fulltext(mapper.table_name(),
key_pos,
key, index_tables, NULL,
@ -14887,7 +14887,7 @@ bool ha_mroonga::wrapper_inplace_alter_table(
for (i = 0; i < n_keys; ++i) {
uint key_pos = ha_alter_info->index_add_buffer[i];
KEY *key = &altered_table->key_info[key_pos];
if (!(key->flags & HA_FULLTEXT || mrn_is_geo_key(key))) {
if (!(key->algorithm == HA_KEY_ALG_FULLTEXT || mrn_is_geo_key(key))) {
continue;
}
if (share->disable_keys) {
@ -14992,7 +14992,7 @@ bool ha_mroonga::storage_inplace_alter_table_add_index(
}
if (
KEY_N_KEY_PARTS(key) != 1 &&
!(key->flags & HA_FULLTEXT)
key->algorithm != HA_KEY_ALG_FULLTEXT
) {
mrn_set_bitmap_by_key(table->read_set, key);
have_multiple_column_index = true;
@ -15587,7 +15587,7 @@ int ha_mroonga::wrapper_add_index(TABLE *table_arg, KEY *key_info,
mrn_set_bitmap_by_key(table->read_set, p_key_info);
mrn::PathMapper mapper(share->table_name);
for (i = 0, j = 0; i < num_of_keys; i++) {
if (!(key_info[i].flags & HA_FULLTEXT) && !mrn_is_geo_key(&key_info[i])) {
if (key_info[i].algorithm != HA_KEY_ALG_FULLTEXT && !mrn_is_geo_key(&key_info[i])) {
wrap_alter_key_info[j] = key_info[i];
j++;
continue;
@ -15601,7 +15601,7 @@ int ha_mroonga::wrapper_add_index(TABLE *table_arg, KEY *key_info,
}
index_tables[i + n_keys] = NULL;
if (
(key_info[i].flags & HA_FULLTEXT) &&
(key_info[i].algorithm == HA_KEY_ALG_FULLTEXT) &&
(error = wrapper_create_index_fulltext(mapper.table_name(),
i + n_keys,
&key_info[i], index_tables, NULL,
@ -15621,7 +15621,7 @@ int ha_mroonga::wrapper_add_index(TABLE *table_arg, KEY *key_info,
if (!error && i > j && !share->disable_keys) {
for (k = 0; k < num_of_keys; k++) {
tmp_key_info = &key_info[k];
if (!(tmp_key_info->flags & HA_FULLTEXT) &&
if (tmp_key_info->algorithm != HA_KEY_ALG_FULLTEXT &&
!mrn_is_geo_key(tmp_key_info)) {
continue;
}
@ -15651,7 +15651,7 @@ int ha_mroonga::wrapper_add_index(TABLE *table_arg, KEY *key_info,
if (error)
{
for (k = 0; k < i; k++) {
if (!(key_info[k].flags & HA_FULLTEXT) && !mrn_is_geo_key(&key_info[k]))
if (key_info[k].algorithm != HA_KEY_ALG_FULLTEXT && !mrn_is_geo_key(&key_info[k]))
{
continue;
}
@ -15752,7 +15752,7 @@ int ha_mroonga::storage_add_index(TABLE *table_arg, KEY *key_info,
}
if (
KEY_N_KEY_PARTS(&(key_info[i])) != 1 &&
!(key_info[i].flags & HA_FULLTEXT)
key_info[i].algorithm != HA_KEY_ALG_FULLTEXT
) {
mrn_set_bitmap_by_key(table->read_set, &key_info[i]);
have_multiple_column_index = true;
@ -15874,7 +15874,7 @@ int ha_mroonga::wrapper_prepare_drop_index(TABLE *table_arg, uint *key_num,
MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(uint, wrap_key_num, num_of_keys);
for (i = 0, j = 0; i < num_of_keys; i++) {
uint key_index = key_num[i];
if (!(key_info[key_index].flags & HA_FULLTEXT) &&
if (key_info[key_index].algorithm != HA_KEY_ALG_FULLTEXT &&
!mrn_is_geo_key(&key_info[key_index])) {
wrap_key_num[j] = share->wrap_key_nr[key_index];
j++;

View file

@ -516,9 +516,7 @@ error:
bool mrn_is_geo_key(const KEY *key_info)
{
return key_info->algorithm == HA_KEY_ALG_UNDEF &&
KEY_N_KEY_PARTS(key_info) == 1 &&
key_info->key_part[0].field->type() == MYSQL_TYPE_GEOMETRY;
return key_info->algorithm == HA_KEY_ALG_RTREE;
}
int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
@ -631,7 +629,7 @@ int mrn_parse_index_param(MRN_SHARE *share, TABLE *table)
bool is_wrapper_mode = share->engine != NULL;
if (is_wrapper_mode) {
if (!(key_info->flags & HA_FULLTEXT) && !mrn_is_geo_key(key_info)) {
if (key_info->algorithm != HA_KEY_ALG_FULLTEXT && !mrn_is_geo_key(key_info)) {
continue;
}
}

View file

@ -407,7 +407,7 @@ void ftparser_call_deinitializer(MI_INFO *info)
{
MYSQL_FTPARSER_PARAM *ftparser_param=
&info->ftparser_param[keyinfo->ftkey_nr * MAX_PARAM_NR + j];
if (keyinfo->flag & HA_FULLTEXT && ftparser_param->mysql_add_word)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT && ftparser_param->mysql_add_word)
{
if (keyinfo->parser->deinit)
keyinfo->parser->deinit(ftparser_param);

View file

@ -282,10 +282,10 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
pos= table_arg->key_info;
for (i= 0; i < share->keys; i++, pos++)
{
keydef[i].flag= ((uint16) pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?
(pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :
pos->algorithm;
keydef[i].flag= ((uint16) pos->flags & (HA_NOSAME | HA_FULLTEXT_legacy
| HA_SPATIAL_legacy));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ? HA_KEY_ALG_BTREE
: pos->algorithm;
keydef[i].block_length= pos->block_size;
keydef[i].seg= keyseg;
keydef[i].keysegs= pos->user_defined_key_parts;
@ -511,28 +511,11 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
{
HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg;
HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg;
if (t1_keyinfo[i].flag & HA_FULLTEXT && t2_keyinfo[i].flag & HA_FULLTEXT)
if ((t1_keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT &&
t2_keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT) ||
(t1_keyinfo[i].key_alg == HA_KEY_ALG_RTREE &&
t2_keyinfo[i].key_alg == HA_KEY_ALG_RTREE))
continue;
else if (t1_keyinfo[i].flag & HA_FULLTEXT ||
t2_keyinfo[i].flag & HA_FULLTEXT)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_fulltext= %d, t2_fulltext=%d",
MY_TEST(t1_keyinfo[i].flag & HA_FULLTEXT),
MY_TEST(t2_keyinfo[i].flag & HA_FULLTEXT)));
DBUG_RETURN(1);
}
if (t1_keyinfo[i].flag & HA_SPATIAL && t2_keyinfo[i].flag & HA_SPATIAL)
continue;
else if (t1_keyinfo[i].flag & HA_SPATIAL ||
t2_keyinfo[i].flag & HA_SPATIAL)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_spatial= %d, t2_spatial=%d",
MY_TEST(t1_keyinfo[i].flag & HA_SPATIAL),
MY_TEST(t2_keyinfo[i].flag & HA_SPATIAL)));
DBUG_RETURN(1);
}
if ((!mysql_40_compat &&
t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) ||
t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs)
@ -766,26 +749,13 @@ static const char *ha_myisam_exts[] = {
NullS
};
const char *ha_myisam::index_type(uint key_number)
{
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
"FULLTEXT" :
(table->key_info[key_number].flags & HA_SPATIAL) ?
"SPATIAL" :
(table->key_info[key_number].algorithm == HA_KEY_ALG_RTREE) ?
"RTREE" :
"BTREE");
}
ulong ha_myisam::index_flags(uint inx, uint part, bool all_parts) const
{
ulong flags;
if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT)
flags= 0;
else
if ((table_share->key_info[inx].flags & HA_SPATIAL ||
table_share->key_info[inx].algorithm == HA_KEY_ALG_RTREE))
if (table_share->key_info[inx].algorithm == HA_KEY_ALG_RTREE)
{
/* All GIS scans are non-ROR scans. We also disable IndexConditionPushdown */
flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
@ -1813,10 +1783,11 @@ void ha_myisam::start_bulk_insert(ha_rows rows, uint flags)
(!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES));
for (i=0 ; i < share->base.keys ; i++,key++)
{
if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY)) &&
! mi_too_big_key_for_sort(key,rows) && file->s->base.auto_key != i+1 &&
if (!(key->flag & HA_AUTO_KEY) && file->s->base.auto_key != i+1 &&
! mi_too_big_key_for_sort(key,rows) &&
(all_keys || !(key->flag & HA_NOSAME)) &&
table->key_info[i].algorithm != HA_KEY_ALG_LONG_HASH)
table->key_info[i].algorithm != HA_KEY_ALG_LONG_HASH &&
table->key_info[i].algorithm != HA_KEY_ALG_RTREE)
{
mi_clear_key_active(share->state.key_map, i);
index_disabled= 1;

View file

@ -49,7 +49,6 @@ class ha_myisam final : public handler
ha_myisam(handlerton *hton, TABLE_SHARE *table_arg);
~ha_myisam() = default;
handler *clone(const char *name, MEM_ROOT *mem_root) override;
const char *index_type(uint key_number) override;
ulonglong table_flags() const override { return int_table_flags; }
int index_init(uint idx, bool sorted) override;
int index_end() override;

View file

@ -446,10 +446,10 @@ int chk_key(HA_CHECK *param, register MI_INFO *info)
if ((!(param->testflag & T_SILENT)))
printf ("- check data record references index: %d\n",key+1);
if (keyinfo->flag & (HA_FULLTEXT | HA_SPATIAL))
if (keyinfo->key_alg > HA_KEY_ALG_BTREE)
full_text_keys++;
if (share->state.key_root[key] == HA_OFFSET_ERROR &&
(info->state->records == 0 || keyinfo->flag & HA_FULLTEXT))
(info->state->records == 0 || keyinfo->key_alg == HA_KEY_ALG_FULLTEXT))
goto do_stat;
if (!_mi_fetch_keypage(info,keyinfo,share->state.key_root[key],
DFLT_INIT_HITS,info->buff,0))
@ -469,7 +469,7 @@ int chk_key(HA_CHECK *param, register MI_INFO *info)
if (chk_index(param,info,keyinfo,share->state.key_root[key],info->buff,
&keys, param->key_crc+key,1))
DBUG_RETURN(-1);
if(!(keyinfo->flag & (HA_FULLTEXT | HA_SPATIAL)))
if (keyinfo->key_alg <= HA_KEY_ALG_BTREE)
{
if (keys != info->state->records)
{
@ -736,7 +736,7 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
DBUG_DUMP("buff",(uchar*) buff,mi_getint(buff));
/* TODO: implement appropriate check for RTree keys */
if (keyinfo->flag & HA_SPATIAL)
if (keyinfo->key_alg == HA_KEY_ALG_RTREE)
DBUG_RETURN(0);
if (!(temp_buff=(uchar*) my_alloca((uint) keyinfo->block_length)))
@ -830,7 +830,7 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
(*key_checksum)+= mi_byte_checksum((uchar*) key,
key_length- info->s->rec_reflength);
record= _mi_dpos(info,0,key+key_length);
if (keyinfo->flag & HA_FULLTEXT) /* special handling for ft2 */
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT) /* special handling for ft2 */
{
uint off;
int subkeys;
@ -1209,7 +1209,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend)
{
if (mi_is_key_active(info->s->state.key_map, key))
{
if(!(keyinfo->flag & HA_FULLTEXT))
if(keyinfo->key_alg != HA_KEY_ALG_FULLTEXT)
{
uint key_length=_mi_make_key(info,key,info->lastkey,record,
start_recpos);
@ -1218,8 +1218,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend)
/* We don't need to lock the key tree here as we don't allow
concurrent threads when running myisamchk
*/
int search_result=
(keyinfo->flag & HA_SPATIAL) ?
int search_result= keyinfo->key_alg == HA_KEY_ALG_RTREE ?
rtree_find_first(info, key, info->lastkey, key_length,
MBR_EQUAL | MBR_DATA) :
_mi_search(info,keyinfo,info->lastkey,key_length,
@ -1278,7 +1277,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend)
for (key=0 ; key < info->s->base.keys; key++)
{
if (key_checksum[key] != param->key_crc[key] &&
!(info->s->keyinfo[key].flag & (HA_FULLTEXT | HA_SPATIAL)))
(info->s->keyinfo[key].key_alg <= HA_KEY_ALG_BTREE))
{
mi_check_print_error(param,"Checksum for key: %2d doesn't match checksum for records",
key+1);
@ -1767,12 +1766,12 @@ static int writekeys(MI_SORT_PARAM *sort_param)
{
if (mi_is_key_active(info->s->state.key_map, i))
{
if (info->s->keyinfo[i].flag & HA_FULLTEXT )
if (info->s->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_mi_ft_add(info, i, key, buff, filepos))
goto err;
}
else if (info->s->keyinfo[i].flag & HA_SPATIAL)
else if (info->s->keyinfo[i].key_alg == HA_KEY_ALG_RTREE)
{
uint key_length=_mi_make_key(info,i,key,buff,filepos);
if (rtree_insert(info, i, key, key_length))
@ -1796,7 +1795,7 @@ static int writekeys(MI_SORT_PARAM *sort_param)
{
if (mi_is_key_active(info->s->state.key_map, i))
{
if (info->s->keyinfo[i].flag & HA_FULLTEXT)
if (info->s->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_mi_ft_del(info,i, key,buff,filepos))
break;
@ -2026,7 +2025,7 @@ static int sort_one_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
llstr(pagepos,llbuff));
goto err;
}
if ((nod_flag=mi_test_if_nod(buff)) || keyinfo->flag & HA_FULLTEXT)
if ((nod_flag=mi_test_if_nod(buff)) || keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
used_length=mi_getint(buff);
keypos=buff+2+nod_flag;
@ -2051,7 +2050,7 @@ static int sort_one_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
(key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,key)) == 0)
break;
DBUG_ASSERT(keypos <= endpos);
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint off;
int subkeys;
@ -2361,7 +2360,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
info->state->records=info->state->del=share->state.split=0;
info->state->empty=0;
if (sort_param.keyinfo->flag & HA_FULLTEXT)
if (sort_param.keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param.keyinfo->seg->charset->mbmaxlen;
@ -2830,7 +2829,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
istep=1;
if ((!(param->testflag & T_SILENT)))
printf ("- Fixing index %d\n",key+1);
if (sort_param[i].keyinfo->flag & HA_FULLTEXT)
if (sort_param[i].keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
sort_param[i].key_read=sort_ft_key_read;
sort_param[i].key_write=sort_ft_key_write;
@ -2875,7 +2874,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
total_key_length+=sort_param[i].key_length;
#endif
if (sort_param[i].keyinfo->flag & HA_FULLTEXT)
if (sort_param[i].keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param[i].keyinfo->seg->charset->mbmaxlen;
@ -4684,14 +4683,15 @@ static ha_checksum mi_byte_checksum(const uchar *buf, uint length)
my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
{
uint key_maxlength=key->maxlength;
if (key->flag & HA_FULLTEXT)
if (key->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
key->seg->charset->mbmaxlen;
key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
return (ulonglong) rows * key_maxlength > myisam_max_temp_length;
}
return (key->flag & HA_SPATIAL) ||
(key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
return key->key_alg == HA_KEY_ALG_RTREE ||
(key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY) &&
((ulonglong) rows * key_maxlength > myisam_max_temp_length));
}

View file

@ -259,11 +259,11 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share.state.key_root[i]= HA_OFFSET_ERROR;
min_key_length_skip=length=real_length_diff=0;
key_length=pointer;
if (keydef->flag & HA_SPATIAL)
if (keydef->key_alg == HA_KEY_ALG_RTREE)
{
/* BAR TODO to support 3D and more dimensions in the future */
uint sp_segs=SPDIMS*2;
keydef->flag=HA_SPATIAL;
keydef->flag=HA_SPATIAL_legacy;
if (flags & HA_DONT_TOUCH_DATA)
{
@ -294,9 +294,9 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
length++; /* At least one length byte */
min_key_length_skip+=SPLEN*2*SPDIMS;
}
else if (keydef->flag & HA_FULLTEXT)
else if (keydef->key_alg == HA_KEY_ALG_FULLTEXT)
{
keydef->flag=HA_FULLTEXT | HA_PACK_KEY | HA_VAR_LENGTH_KEY;
keydef->flag=HA_FULLTEXT_legacy | HA_PACK_KEY | HA_VAR_LENGTH_KEY;
options|=HA_OPTION_PACK_KEYS; /* Using packed keys */
for (j=0, keyseg=keydef->seg ; (int) j < keydef->keysegs ;
@ -716,7 +716,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
DBUG_PRINT("info", ("write key and keyseg definitions"));
for (i=0 ; i < share.base.keys - uniques; i++)
{
uint sp_segs=(keydefs[i].flag & HA_SPATIAL) ? 2*SPDIMS : 0;
uint sp_segs=keydefs[i].key_alg == HA_KEY_ALG_RTREE ? 2*SPDIMS : 0;
if (mi_keydef_write(file, &keydefs[i]))
goto err;

View file

@ -76,7 +76,7 @@ int mi_delete(MI_INFO *info,const uchar *record)
if (mi_is_key_active(info->s->state.key_map, i))
{
info->s->keyinfo[i].version++;
if (info->s->keyinfo[i].flag & HA_FULLTEXT )
if (info->s->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT )
{
if (_mi_ft_del(info,i, old_key,record,info->lastpos))
goto err;
@ -169,11 +169,10 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo,
error= -1;
goto err;
}
if ((error=d_search(info,keyinfo,
(keyinfo->flag & HA_FULLTEXT ?
SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT :
SEARCH_SAME),
key,key_length,old_root,root_buff)) >0)
if ((error= d_search(info,keyinfo, keyinfo->key_alg == HA_KEY_ALG_FULLTEXT ?
SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT :
SEARCH_SAME,
key, key_length, old_root, root_buff)) > 0)
{
if (error == 2)
{
@ -235,7 +234,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
}
nod_flag=mi_test_if_nod(anc_buff);
if (!flag && keyinfo->flag & HA_FULLTEXT)
if (!flag && keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint off;
int subkeys;

View file

@ -58,10 +58,10 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
uchar *pos;
uchar *start;
reg1 HA_KEYSEG *keyseg;
my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
my_bool is_ft= info->s->keyinfo[keynr].key_alg == HA_KEY_ALG_FULLTEXT;
DBUG_ENTER("_mi_make_key");
if (info->s->keyinfo[keynr].flag & HA_SPATIAL)
if (info->s->keyinfo[keynr].key_alg == HA_KEY_ALG_RTREE)
{
/*
TODO: nulls processing
@ -219,7 +219,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
{
uchar *start_key=key;
HA_KEYSEG *keyseg;
my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
my_bool is_ft= info->s->keyinfo[keynr].key_alg == HA_KEY_ALG_FULLTEXT;
DBUG_ENTER("_mi_pack_key");
/* "one part" rtree key is 2*SPDIMS part key in MyISAM */

View file

@ -386,14 +386,14 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
else if (pos->type == HA_KEYTYPE_BINARY)
pos->charset= &my_charset_bin;
}
if (keyinfo->flag & HA_SPATIAL)
if (keyinfo->key_alg == HA_KEY_ALG_RTREE)
{
uint sp_segs= SPDIMS*2;
keyinfo->seg= pos - sp_segs;
DBUG_ASSERT(keyinfo->keysegs == sp_segs + 1);
keyinfo->keysegs= sp_segs;
}
else if (keyinfo->flag & HA_FULLTEXT)
else if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
if (!fulltext_keys)
{ /* 4.0 compatibility code, to be removed in 5.0 */
@ -421,6 +421,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
memcpy(& share->ft2_keyinfo, keyinfo, sizeof(MI_KEYDEF));
share->ft2_keyinfo.keysegs=1;
share->ft2_keyinfo.flag=0;
share->ft2_keyinfo.key_alg=HA_KEY_ALG_BTREE;
share->ft2_keyinfo.keylength=
share->ft2_keyinfo.minlength=
share->ft2_keyinfo.maxlength=HA_FT_WLEN+share->base.rec_reflength;

View file

@ -282,7 +282,7 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
keyinfo->keylength+= (uint16) diff_length;
keyinfo->minlength+= (uint16) diff_length;
keyinfo->maxlength+= (uint16) diff_length;
keyinfo->seg[keyinfo->flag & HA_FULLTEXT ?
keyinfo->seg[keyinfo->key_alg == HA_KEY_ALG_FULLTEXT ?
FT_SEGS : keyinfo->keysegs].length= (uint16) rec_reflength;
}
if (share->ft2_keyinfo.seg)

View file

@ -1473,7 +1473,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
key_length=_mi_keylength(keyinfo,key)+nod_flag;
sort_order=0;
if ((keyinfo->flag & HA_FULLTEXT) &&
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT &&
((keyseg->type == HA_KEYTYPE_TEXT) ||
(keyseg->type == HA_KEYTYPE_VARTEXT1) ||
(keyseg->type == HA_KEYTYPE_VARTEXT2)) &&

View file

@ -87,7 +87,7 @@ int mi_update(register MI_INFO *info, const uchar *oldrec,
{
if (mi_is_key_active(share->state.key_map, i))
{
if (share->keyinfo[i].flag & HA_FULLTEXT )
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT )
{
if (_mi_ft_cmp(info,i,oldrec, newrec))
{
@ -203,7 +203,7 @@ err:
{
if (((ulonglong) 1 << i) & changed)
{
if (share->keyinfo[i].flag & HA_FULLTEXT)
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if ((flag++ && _mi_ft_del(info,i, new_key,newrec,pos)) ||
_mi_ft_add(info,i, old_key,oldrec,pos))

View file

@ -110,7 +110,7 @@ int mi_write(MI_INFO *info, const uchar *record)
mysql_rwlock_wrlock(&share->key_root_lock[i]);
share->keyinfo[i].version++;
}
if (share->keyinfo[i].flag & HA_FULLTEXT )
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_mi_ft_add(info,i, buff, record, filepos))
{
@ -196,7 +196,7 @@ err:
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
mysql_rwlock_wrlock(&share->key_root_lock[i]);
if (share->keyinfo[i].flag & HA_FULLTEXT)
if (share->keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXT)
{
if (_mi_ft_del(info,i, buff,record,filepos))
{
@ -267,12 +267,16 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key,
if (keyinfo->flag & HA_SORT_ALLOWS_SAME)
comp_flag=SEARCH_BIGGER; /* Put after same key */
else if (keyinfo->flag & (HA_NOSAME|HA_FULLTEXT))
else if (keyinfo->flag & HA_NOSAME)
{
comp_flag=SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT; /* No duplicates */
if (keyinfo->flag & HA_NULL_ARE_EQUAL)
comp_flag|= SEARCH_NULL_ARE_EQUAL;
}
else if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
comp_flag=SEARCH_FIND | SEARCH_UPDATE | SEARCH_INSERT;
}
else
comp_flag=SEARCH_SAME; /* Keys in rec-pos order */
@ -369,7 +373,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
else
dupp_key_pos= HA_OFFSET_ERROR;
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
uint off;
int subkeys;
@ -521,7 +525,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (a_length <= keyinfo->block_length)
{
if (keyinfo->block_length - a_length < 32 &&
keyinfo->flag & HA_FULLTEXT && key_pos == endpos &&
keyinfo->key_alg == HA_KEY_ALG_FULLTEXT && key_pos == endpos &&
info->s->base.key_reflength <= info->s->rec_reflength &&
info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))
{

View file

@ -98,7 +98,7 @@ int main(int argc,char *argv[])
aio->info=info;
if ((inx >= info->s->base.keys) ||
!(info->s->keyinfo[inx].flag & HA_FULLTEXT))
info->s->keyinfo[inx].key_alg != HA_KEY_ALG_FULLTEXT)
{
printf("Key %d in table %s is not a FULLTEXT key\n", inx, info->filename);
goto err;

View file

@ -1050,7 +1050,8 @@ static int myisamchk(HA_CHECK *param, char * filename)
*/
my_bool update_index=1;
for (key=0 ; key < share->base.keys; key++)
if (share->keyinfo[key].flag & (HA_BINARY_PACK_KEY|HA_FULLTEXT))
if (share->keyinfo[key].flag & HA_BINARY_PACK_KEY ||
share->keyinfo[key].key_alg == HA_KEY_ALG_FULLTEXT)
update_index=0;
error=mi_sort_records(param,info,filename,param->opt_sort_key,
@ -1323,7 +1324,7 @@ static void descript(HA_CHECK *param, register MI_INFO *info, char * name)
{
keyseg=keyinfo->seg;
if (keyinfo->flag & HA_NOSAME) text="unique ";
else if (keyinfo->flag & HA_FULLTEXT) text="fulltext ";
else if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT) text="fulltext ";
else text="multip.";
pos=buff;
@ -1500,7 +1501,7 @@ static int mi_sort_records(HA_CHECK *param,
param->error_printed=0;
DBUG_RETURN(0); /* Nothing to do */
}
if (keyinfo->flag & HA_FULLTEXT)
if (keyinfo->key_alg == HA_KEY_ALG_FULLTEXT)
{
mi_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d",
name,sort_key+1);

View file

@ -432,7 +432,7 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
}
if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME,
(size_t)(keys * (sort_length + sizeof(char*)) +
((sort_param->keyinfo->flag & HA_FULLTEXT) ?
(sort_param->keyinfo->key_alg == HA_KEY_ALG_FULLTEXT ?
HA_FT_MAXBYTELEN : 0)), MYF(0))))
{
if (my_init_dynamic_array(PSI_INSTRUMENT_ME, &sort_param->buffpek,

View file

@ -88,7 +88,7 @@ int run_test(const char *filename)
keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1;
keyinfo[0].flag=HA_SPATIAL;
keyinfo[0].flag=0;
keyinfo[0].key_alg=KEYALG;
keyinfo[0].seg[0].type= HA_KEYTYPE_BINARY;

View file

@ -168,18 +168,6 @@ extern "C" void myrg_print_wrong_table(const char *table_name)
}
const char *ha_myisammrg::index_type(uint key_number)
{
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
"FULLTEXT" :
(table->key_info[key_number].flags & HA_SPATIAL) ?
"SPATIAL" :
(table->key_info[key_number].algorithm == HA_KEY_ALG_RTREE) ?
"RTREE" :
"BTREE");
}
/**
Callback function for open of a MERGE parent table.

View file

@ -77,7 +77,6 @@ public:
ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg);
~ha_myisammrg();
const char *index_type(uint key_number) override;
ulonglong table_flags() const override
{
return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_NO_TRANSACTIONS |

View file

@ -53,8 +53,6 @@ public:
~ha_perfschema();
const char *index_type(uint) override { return ""; }
/** Capabilities of the performance schema tables. */
ulonglong table_flags(void) const override
{

View file

@ -116,3 +116,9 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
insert into t3 values (1, 1), (1, 1);
set @@session.unique_checks = @old_val;
drop table t1, t2, t3;
#
# MDEV-35077 Assertion failure in myrocks::ha_rocksdb::position_to_correct_key upon using unique hash key
#
CREATE TABLE t (s INT, UNIQUE(s) USING HASH) ENGINE=RocksDB;
UPDATE t SET s = 1 WHERE s > 2;
DROP TABLE t;

View file

@ -177,3 +177,11 @@ insert into t3 values (1, 1), (1, 1);
set @@session.unique_checks = @old_val;
# cleanup
drop table t1, t2, t3;
--echo #
--echo # MDEV-35077 Assertion failure in myrocks::ha_rocksdb::position_to_correct_key upon using unique hash key
--echo #
CREATE TABLE t (s INT, UNIQUE(s) USING HASH) ENGINE=RocksDB;
UPDATE t SET s = 1 WHERE s > 2;
DROP TABLE t;

View file

@ -5853,8 +5853,8 @@ const char *ha_spider::index_type(
DBUG_PRINT("info",("spider flags=%ld", key_info->flags));
DBUG_PRINT("info",("spider algorithm=%d", key_info->algorithm));
DBUG_RETURN(
(key_info->flags & HA_FULLTEXT) ? "FULLTEXT" :
(key_info->flags & HA_SPATIAL) ? "SPATIAL" :
(key_info->algorithm == HA_KEY_ALG_FULLTEXT) ? "FULLTEXT" :
(key_info->algorithm == HA_KEY_ALG_RTREE) ? "SPATIAL" :
(key_info->algorithm == HA_KEY_ALG_HASH) ? "HASH" :
(key_info->algorithm == HA_KEY_ALG_RTREE) ? "RTREE" :
"BTREE"