diff --git a/mysql-test/main/features.result b/mysql-test/main/features.result index cae4a37ca64..0fec83f363e 100644 --- a/mysql-test/main/features.result +++ b/mysql-test/main/features.result @@ -20,6 +20,7 @@ Feature_subquery 0 Feature_system_versioning 0 Feature_timezone 0 Feature_trigger 0 +Feature_vector_index 0 Feature_window_functions 0 Feature_xml 0 # @@ -209,3 +210,18 @@ show status like "feature_into_%"; Variable_name Value Feature_into_outfile 4 Feature_into_variable 2 +# +# Feature vector index +# +create table t1 (id int auto_increment primary key, +u vector(5) not null, vector index (u)); +select * from t1; +id u +select * from t1; +id u +select * from t1; +id u +show status like "Feature_vector_index"; +Variable_name Value +Feature_vector_index 2 +drop table t1; diff --git a/mysql-test/main/features.test b/mysql-test/main/features.test index 6ef617159e6..3d2a03df545 100644 --- a/mysql-test/main/features.test +++ b/mysql-test/main/features.test @@ -166,3 +166,15 @@ drop table t1; --remove_file $MYSQLTEST_VARDIR/tmp/features_outfile.1 --remove_file $MYSQLTEST_VARDIR/tmp/features_outfile.2 show status like "feature_into_%"; + +--echo # +--echo # Feature vector index +--echo # + +create table t1 (id int auto_increment primary key, + u vector(5) not null, vector index (u)); +select * from t1; +select * from t1; +select * from t1; +show status like "Feature_vector_index"; +drop table t1; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 31371bf91df..50bd32030c1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7629,6 +7629,7 @@ SHOW_VAR status_vars[]= { {"Feature_application_time_periods", (char*) offsetof(STATUS_VAR, feature_application_time_periods), SHOW_LONG_STATUS}, {"Feature_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS}, {"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS}, + {"Feature_vector_index", (char*) offsetof(STATUS_VAR, feature_vector_index), SHOW_LONG_STATUS}, {"Feature_window_functions", (char*) offsetof(STATUS_VAR, feature_window_functions), SHOW_LONG_STATUS}, {"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS}, {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS}, diff --git a/sql/sql_class.h b/sql/sql_class.h index fa2ca6cbe52..6abab6f2391 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1028,6 +1028,7 @@ typedef struct system_status_var ulong feature_timezone; /* +1 when XPATH is used */ ulong feature_trigger; /* +1 opening a table with triggers */ ulong feature_xml; /* +1 when XPATH is used */ + ulong feature_vector_index; /* +1 when open table with vector index */ ulong feature_window_functions; /* +1 when window functions are used */ ulong feature_into_outfile; /* +1 when INTO OUTFILE is used */ ulong feature_into_variable; /* +1 when INTO VARIABLE is used */ diff --git a/sql/table.cc b/sql/table.cc index 452f1a7cd07..cdd3131d9bd 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -788,7 +788,8 @@ err_not_open: DBUG_RETURN(share->error); } -static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end, +static bool create_key_infos(THD *thd, const uchar *strpos, + const uchar *frm_image_end, uint keys, KEY *keyinfo, uint new_frm_ver, uint *ext_key_parts, TABLE_SHARE *share, uint len, KEY *first_keyinfo, LEX_STRING *keynames) @@ -845,6 +846,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end, keyinfo->algorithm= HA_KEY_ALG_UNDEF; strpos+=4; } + if (keyinfo->algorithm == HA_KEY_ALG_VECTOR) + thd->status_var.feature_vector_index++; if (i == 0) { @@ -2100,7 +2103,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, share->set_use_ext_keys_flag(plugin_hton(se_plugin)->flags & HTON_SUPPORTS_EXTENDED_KEYS); - if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo, + if (create_key_infos(thd, disk_buff + 6, frm_image_end, keys, keyinfo, new_frm_ver, &ext_key_parts, share, len, &first_keyinfo, &keynames)) goto err; @@ -2200,7 +2203,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, } else { - if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo, + if (create_key_infos(thd, disk_buff + 6, frm_image_end, keys, keyinfo, new_frm_ver, &ext_key_parts, share, len, &first_keyinfo, &keynames)) goto err;