Skip to content

Commit da149c7

Browse files
committed
Add statistics usable for feedback plugin
Following status variables where added: Feature_vector_index ; Incremented when reading a vector index from a .frm file.
1 parent db64d19 commit da149c7

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

mysql-test/main/features.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Feature_subquery 0
2020
Feature_system_versioning 0
2121
Feature_timezone 0
2222
Feature_trigger 0
23+
Feature_vector_index 0
2324
Feature_window_functions 0
2425
Feature_xml 0
2526
#
@@ -209,3 +210,18 @@ show status like "feature_into_%";
209210
Variable_name Value
210211
Feature_into_outfile 4
211212
Feature_into_variable 2
213+
#
214+
# Feature vector index
215+
#
216+
create table t1 (id int auto_increment primary key,
217+
u vector(5) not null, vector index (u));
218+
select * from t1;
219+
id u
220+
select * from t1;
221+
id u
222+
select * from t1;
223+
id u
224+
show status like "Feature_vector_index";
225+
Variable_name Value
226+
Feature_vector_index 2
227+
drop table t1;

mysql-test/main/features.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,15 @@ drop table t1;
166166
--remove_file $MYSQLTEST_VARDIR/tmp/features_outfile.1
167167
--remove_file $MYSQLTEST_VARDIR/tmp/features_outfile.2
168168
show status like "feature_into_%";
169+
170+
--echo #
171+
--echo # Feature vector index
172+
--echo #
173+
174+
create table t1 (id int auto_increment primary key,
175+
u vector(5) not null, vector index (u));
176+
select * from t1;
177+
select * from t1;
178+
select * from t1;
179+
show status like "Feature_vector_index";
180+
drop table t1;

sql/mysqld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7629,6 +7629,7 @@ SHOW_VAR status_vars[]= {
76297629
{"Feature_application_time_periods", (char*) offsetof(STATUS_VAR, feature_application_time_periods), SHOW_LONG_STATUS},
76307630
{"Feature_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS},
76317631
{"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS},
7632+
{"Feature_vector_index", (char*) offsetof(STATUS_VAR, feature_vector_index), SHOW_LONG_STATUS},
76327633
{"Feature_window_functions", (char*) offsetof(STATUS_VAR, feature_window_functions), SHOW_LONG_STATUS},
76337634
{"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS},
76347635
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},

sql/sql_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ typedef struct system_status_var
10281028
ulong feature_timezone; /* +1 when XPATH is used */
10291029
ulong feature_trigger; /* +1 opening a table with triggers */
10301030
ulong feature_xml; /* +1 when XPATH is used */
1031+
ulong feature_vector_index; /* +1 when open table with vector index */
10311032
ulong feature_window_functions; /* +1 when window functions are used */
10321033
ulong feature_into_outfile; /* +1 when INTO OUTFILE is used */
10331034
ulong feature_into_variable; /* +1 when INTO VARIABLE is used */

sql/table.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
788788
DBUG_RETURN(share->error);
789789
}
790790

791-
static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
791+
static bool create_key_infos(THD *thd, const uchar *strpos,
792+
const uchar *frm_image_end,
792793
uint keys, KEY *keyinfo, uint new_frm_ver,
793794
uint *ext_key_parts, TABLE_SHARE *share, uint len,
794795
KEY *first_keyinfo, LEX_STRING *keynames)
@@ -845,6 +846,8 @@ static bool create_key_infos(const uchar *strpos, const uchar *frm_image_end,
845846
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
846847
strpos+=4;
847848
}
849+
if (keyinfo->algorithm == HA_KEY_ALG_VECTOR)
850+
thd->status_var.feature_vector_index++;
848851

849852
if (i == 0)
850853
{
@@ -2100,7 +2103,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
21002103
share->set_use_ext_keys_flag(plugin_hton(se_plugin)->flags &
21012104
HTON_SUPPORTS_EXTENDED_KEYS);
21022105

2103-
if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo,
2106+
if (create_key_infos(thd, disk_buff + 6, frm_image_end, keys, keyinfo,
21042107
new_frm_ver, &ext_key_parts,
21052108
share, len, &first_keyinfo, &keynames))
21062109
goto err;
@@ -2200,7 +2203,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
22002203
}
22012204
else
22022205
{
2203-
if (create_key_infos(disk_buff + 6, frm_image_end, keys, keyinfo,
2206+
if (create_key_infos(thd, disk_buff + 6, frm_image_end, keys, keyinfo,
22042207
new_frm_ver, &ext_key_parts,
22052208
share, len, &first_keyinfo, &keynames))
22062209
goto err;

0 commit comments

Comments
 (0)