2017-12-06 10:35:09 +02:00
|
|
|
--source include/have_innodb.inc
|
|
|
|
|
|
|
|
#
|
|
|
|
# BUG#22469660 INNODB DOESN'T UPDATE INDEX STATS WHEN ADDING OR DROPPING VIRTUAL COLUMN
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t (
|
|
|
|
a INT,
|
|
|
|
b INT,
|
|
|
|
c INT GENERATED ALWAYS AS(a+b),
|
|
|
|
d INT GENERATED ALWAYS AS(a+b+b),
|
|
|
|
KEY idxa (a),
|
|
|
|
KEY vidxcd (c, d)
|
2017-12-06 10:37:08 +02:00
|
|
|
) ENGINE=INNODB STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
|
2017-12-06 10:35:09 +02:00
|
|
|
|
|
|
|
INSERT INTO t (a,b) VALUES (1, 2);
|
|
|
|
|
|
|
|
SELECT index_name, stat_name, stat_description
|
|
|
|
FROM mysql.innodb_index_stats
|
|
|
|
WHERE database_name = 'test' AND table_name = 't';
|
|
|
|
|
|
|
|
ALTER TABLE t ADD COLUMN e INT GENERATED ALWAYS AS(a+a+b), ADD INDEX idxb (b), ALGORITHM=INPLACE;
|
2019-05-08 23:12:01 +03:00
|
|
|
select count(*) from t;
|
2017-12-06 10:35:09 +02:00
|
|
|
|
|
|
|
SELECT index_name, stat_name, stat_description
|
|
|
|
FROM mysql.innodb_index_stats
|
|
|
|
WHERE database_name = 'test' AND table_name = 't';
|
|
|
|
|
|
|
|
ALTER TABLE t DROP COLUMN c, DROP INDEX idxa, ALGORITHM=INPLACE;
|
2019-05-08 23:12:01 +03:00
|
|
|
select count(*) from t;
|
2017-12-06 10:35:09 +02:00
|
|
|
|
|
|
|
SELECT index_name, stat_name, stat_description
|
|
|
|
FROM mysql.innodb_index_stats
|
|
|
|
WHERE database_name = 'test' AND table_name = 't';
|
|
|
|
|
|
|
|
ALTER TABLE t ADD INDEX vidxe (e), ALGORITHM=INPLACE;
|
2019-05-08 23:12:01 +03:00
|
|
|
select count(*) from t;
|
2017-12-06 10:35:09 +02:00
|
|
|
|
|
|
|
SELECT index_name, stat_name, stat_description
|
|
|
|
FROM mysql.innodb_index_stats
|
|
|
|
WHERE database_name = 'test' AND table_name = 't';
|
|
|
|
|
|
|
|
ALTER TABLE t ADD COLUMN f INT GENERATED ALWAYS AS(a + a), ADD INDEX vidxf (f), ALGORITHM=INPLACE;
|
2019-05-08 23:12:01 +03:00
|
|
|
select count(*) from t;
|
2017-12-06 10:35:09 +02:00
|
|
|
|
|
|
|
SELECT index_name, stat_name, stat_description
|
|
|
|
FROM mysql.innodb_index_stats
|
|
|
|
WHERE database_name = 'test' AND table_name = 't';
|
|
|
|
|
|
|
|
ALTER TABLE t DROP INDEX vidxcd;
|
|
|
|
|
|
|
|
SELECT index_name, stat_name, stat_description
|
|
|
|
FROM mysql.innodb_index_stats
|
|
|
|
WHERE database_name = 'test' AND table_name = 't';
|
|
|
|
|
|
|
|
DROP TABLE t;
|