Skip to content

Commit

Permalink
MDEV-33913 TABLE_STATISTICS increments ROWS_CHANGED twice upon UPDATE…
Browse files Browse the repository at this point in the history
… and does not count DELETE
  • Loading branch information
elenst authored and vuvova committed May 27, 2024
1 parent 94033fc commit 86055e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mysql-test/main/information_schema_stats.result
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ id first_name last_name address phone email
select * from just_a_test force index(primary) where id=8;
id first_name last_name address phone email
update just_a_test set first_name="unlucky" where id=5;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
test just_a_test 31 6 6 5 1 0 4 1
delete from just_a_test where id=5;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES ROWS_INSERTED ROWS_UPDATED ROWS_DELETED KEY_READ_HITS KEY_READ_MISSES
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/information_schema_stats.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ select * from information_schema.index_statistics where table_schema='test' and
select * from just_a_test force index(primary) where id between 1 and 2;
select * from just_a_test force index(primary) where id=8;
update just_a_test set first_name="unlucky" where id=5;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
delete from just_a_test where id=5;
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
Expand Down
2 changes: 1 addition & 1 deletion plugin/userstat/table_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
continue;

rows_changed= (rows_stats->inserted + rows_stats->updated +
rows_stats->updated);
rows_stats->deleted);
table->field[0]->store(table_stats->table, schema_length,
system_charset_info);
table->field[1]->store(table_stats->table + schema_length+1,
Expand Down

0 comments on commit 86055e4

Please sign in to comment.