diff --git a/mysql-test/main/mysqldump-system,win.rdiff b/mysql-test/main/mysqldump-system,win.rdiff index 50c08438dcf..dc96c5b862a 100644 --- a/mysql-test/main/mysqldump-system,win.rdiff +++ b/mysql-test/main/mysqldump-system,win.rdiff @@ -1,6 +1,6 @@ --- mysqldump-system.result +++ mysqldump-system,win.result -@@ -449,9 +449,9 @@ +@@ -1861,9 +1861,9 @@ Table Checksum mysql.roles_mapping 2510045525 mysql.time_zone_transition 3719776009 @@ -9,10 +9,10 @@ mysql.servers 2079085450 -mysql.func 3241572444 +mysql.func 310494789 - mysql.innodb_table_stats 1285726777 - mysql.table_stats 2836905944 + mysql.innodb_table_stats 1972297402 + mysql.table_stats 1911089388 # Opps.... -@@ -484,9 +484,9 @@ +@@ -1896,9 +1896,9 @@ Table Checksum mysql.roles_mapping 2510045525 mysql.time_zone_transition 3719776009 @@ -21,6 +21,6 @@ mysql.servers 2079085450 -mysql.func 3241572444 +mysql.func 310494789 - mysql.innodb_table_stats 1285726777 - mysql.table_stats 2836905944 + mysql.innodb_table_stats 1972297402 + mysql.table_stats 1911089388 DROP FUNCTION IF EXISTS metaphon; diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index 59c0a09e08c..58e4b2daa70 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -19,20 +19,20 @@ GRANT role_2 TO foobar; SET DEFAULT ROLE role_2 FOR foobar; ALTER TABLE mysql.roles_mapping ORDER BY Host, User, Role; set @save_innodb_stats_persistent= @@innodb_stats_persistent; -create table mysql.tz like mysql.time_zone_transition; -alter table mysql.tz engine=innodb; -insert into mysql.tz select * from mysql.time_zone_transition; +create table test.tz like mysql.time_zone_transition; +alter table test.tz engine=innodb; +insert into test.tz select * from mysql.time_zone_transition; set global innodb_stats_persistent=1; set time_zone="+03:00"; SET TIMESTAMP= UNIX_TIMESTAMP('2022-01-07 07:07:00'); -ANALYZE TABLE mysql.tz PERSISTENT FOR ALL; +ANALYZE TABLE test.tz PERSISTENT FOR ALL; Table Op Msg_type Msg_text -mysql.tz analyze status Engine-independent statistics collected -mysql.tz analyze status OK +test.tz analyze status Engine-independent statistics collected +test.tz analyze status OK delete from mysql.index_stats where prefix_arity!=1; delete from mysql.column_stats where column_name!='Time_zone_id'; -update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; -update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; +update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="test" and table_name="tz"; +update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="test" and table_name="tz"; update mysql.column_stats set histogram=json_replace(histogram, '$.collected_by', replace(json_value(histogram, '$.collected_by'), @@version, 'version')); set global innodb_stats_persistent= @save_innodb_stats_persistent; alter table mysql.time_zone_name ORDER BY Name; @@ -97,38 +97,38 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; REPLACE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); +('test','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; REPLACE INTO `index_stats` VALUES -('mysql','tz','PRIMARY',1,78.8000); +('test','tz','PRIMARY',1,78.8000); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; REPLACE INTO `table_stats` VALUES -('mysql','tz',394); +('test','tz',394); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; REPLACE INTO `innodb_index_stats` VALUES -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); +('test','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), +('test','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), +('test','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), +('test','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; REPLACE INTO `innodb_table_stats` VALUES -('mysql','tz','2019-12-31 21:00:00',394,1,0); +('test','tz','2019-12-31 21:00:00',394,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -717,38 +717,38 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; REPLACE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); +('test','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; REPLACE INTO `index_stats` VALUES -('mysql','tz','PRIMARY',1,78.8000); +('test','tz','PRIMARY',1,78.8000); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; REPLACE INTO `table_stats` VALUES -('mysql','tz',394); +('test','tz',394); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; REPLACE INTO `innodb_index_stats` VALUES -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); +('test','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), +('test','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), +('test','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), +('test','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; REPLACE INTO `innodb_table_stats` VALUES -('mysql','tz','2019-12-31 21:00:00',394,1,0); +('test','tz','2019-12-31 21:00:00',394,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -1314,38 +1314,38 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; INSERT IGNORE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); +('test','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; INSERT IGNORE INTO `index_stats` VALUES -('mysql','tz','PRIMARY',1,78.8000); +('test','tz','PRIMARY',1,78.8000); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; INSERT IGNORE INTO `table_stats` VALUES -('mysql','tz',394); +('test','tz',394); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; INSERT IGNORE INTO `innodb_index_stats` VALUES -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); +('test','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), +('test','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), +('test','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), +('test','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; INSERT IGNORE INTO `innodb_table_stats` VALUES -('mysql','tz','2019-12-31 21:00:00',394,1,0); +('test','tz','2019-12-31 21:00:00',394,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -1867,8 +1867,8 @@ mysql.time_zone_transition 3719776009 mysql.plugin 1587119305 mysql.servers 2079085450 mysql.func 3241572444 -mysql.innodb_table_stats 1285726777 -mysql.table_stats 2836905944 +mysql.innodb_table_stats 1972297402 +mysql.table_stats 1911089388 # Opps.... CREATE USER mariadb_test_restore IDENTIFIED BY 'getitback'; GRANT ALL ON *.* TO mariadb_test_restore WITH GRANT OPTION; @@ -1902,16 +1902,16 @@ mysql.time_zone_transition 3719776009 mysql.plugin 1587119305 mysql.servers 2079085450 mysql.func 3241572444 -mysql.innodb_table_stats 1285726777 -mysql.table_stats 2836905944 +mysql.innodb_table_stats 1972297402 +mysql.table_stats 1911089388 DROP FUNCTION IF EXISTS metaphon; DROP SERVER s1; -DELETE FROM mysql.column_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); -DELETE FROM mysql.index_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); -DELETE FROM mysql.table_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); -DELETE FROM mysql.innodb_index_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos'); -DELETE FROM mysql.innodb_table_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos'); -drop table mysql.tz; +DELETE FROM mysql.column_stats WHERE db_name='mysql'; +DELETE FROM mysql.index_stats WHERE db_name='mysql'; +DELETE FROM mysql.table_stats WHERE db_name='mysql'; +DELETE FROM mysql.innodb_index_stats WHERE database_name='test'; +DELETE FROM mysql.innodb_table_stats WHERE database_name='mysql'; +drop table test.tz; DROP ROLE role_2; DROP ROLE role_1; drop user foobar; diff --git a/mysql-test/main/mysqldump-system.test b/mysql-test/main/mysqldump-system.test index 85ad44211a8..1ddf44cf7d7 100644 --- a/mysql-test/main/mysqldump-system.test +++ b/mysql-test/main/mysqldump-system.test @@ -39,18 +39,18 @@ ALTER TABLE mysql.roles_mapping ORDER BY Host, User, Role; # innodb and EITS tables statistics # set @save_innodb_stats_persistent= @@innodb_stats_persistent; -create table mysql.tz like mysql.time_zone_transition; -alter table mysql.tz engine=innodb; -insert into mysql.tz select * from mysql.time_zone_transition; +create table test.tz like mysql.time_zone_transition; +alter table test.tz engine=innodb; +insert into test.tz select * from mysql.time_zone_transition; set global innodb_stats_persistent=1; set time_zone="+03:00"; SET TIMESTAMP= UNIX_TIMESTAMP('2022-01-07 07:07:00'); -ANALYZE TABLE mysql.tz PERSISTENT FOR ALL; +ANALYZE TABLE test.tz PERSISTENT FOR ALL; # for predictable output in tests delete from mysql.index_stats where prefix_arity!=1; delete from mysql.column_stats where column_name!='Time_zone_id'; -update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; -update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="mysql" and table_name="tz"; +update mysql.innodb_index_stats set last_update="2020-01-01" where database_name="test" and table_name="tz"; +update mysql.innodb_table_stats set last_update="2020-01-01" where database_name="test" and table_name="tz"; update mysql.column_stats set histogram=json_replace(histogram, '$.collected_by', replace(json_value(histogram, '$.collected_by'), @@version, 'version')); set global innodb_stats_persistent= @save_innodb_stats_persistent; alter table mysql.time_zone_name ORDER BY Name; @@ -144,12 +144,12 @@ DROP FUNCTION IF EXISTS metaphon; DROP SERVER s1; # EITS && innodb stats -DELETE FROM mysql.column_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); -DELETE FROM mysql.index_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); -DELETE FROM mysql.table_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); -DELETE FROM mysql.innodb_index_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos'); -DELETE FROM mysql.innodb_table_stats WHERE database_name='mysql' and table_name in ('tz','gtid_slave_pos'); -drop table mysql.tz; +DELETE FROM mysql.column_stats WHERE db_name='mysql'; +DELETE FROM mysql.index_stats WHERE db_name='mysql'; +DELETE FROM mysql.table_stats WHERE db_name='mysql'; +DELETE FROM mysql.innodb_index_stats WHERE database_name='test'; +DELETE FROM mysql.innodb_table_stats WHERE database_name='mysql'; +drop table test.tz; DROP ROLE role_2; DROP ROLE role_1; diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index 22ab446f866..0f2abc34255 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -2145,11 +2145,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 call proc_1(); show open tables from mysql; @@ -2159,11 +2156,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 call proc_1(); show open tables from mysql; @@ -2173,11 +2167,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 call proc_1(); show open tables from mysql; @@ -2187,11 +2178,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 flush tables; create function func_1() returns int begin flush tables; return 1; end| @@ -2206,11 +2194,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 prepare abc from "flush tables"; execute abc; @@ -2221,11 +2206,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 execute abc; show open tables from mysql; @@ -2235,11 +2217,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 execute abc; show open tables from mysql; @@ -2249,11 +2228,8 @@ select Host, User from mysql.user limit 0; Host User show open tables from mysql; Database Table In_use Name_locked -mysql column_stats 0 0 mysql general_log 0 0 mysql global_priv 0 0 -mysql index_stats 0 0 -mysql table_stats 0 0 mysql user 0 0 flush tables; deallocate prepare abc; diff --git a/mysql-test/main/userstat.result b/mysql-test/main/userstat.result index a0e8cf1fcf0..3563863aafe 100644 --- a/mysql-test/main/userstat.result +++ b/mysql-test/main/userstat.result @@ -240,12 +240,18 @@ set @@global.general_log=@save_general_log; # create function f() returns int return (select 1 from performance_schema.threads); set global userstat= 1; +create table t1 (a int primary key); +insert into t1 values (1),(2); +select * from t1 where a=1; +a +1 select f() from information_schema.table_statistics; ERROR 21000: Subquery returns more than 1 row select f() from information_schema.index_statistics; ERROR 21000: Subquery returns more than 1 row set global userstat= 0; drop function f; +drop table t1; # # End of 10.2 tests # diff --git a/mysql-test/main/userstat.test b/mysql-test/main/userstat.test index 36a128b25f1..fbf0de8dd88 100644 --- a/mysql-test/main/userstat.test +++ b/mysql-test/main/userstat.test @@ -122,12 +122,16 @@ set @@global.general_log=@save_general_log; --echo # create function f() returns int return (select 1 from performance_schema.threads); set global userstat= 1; +create table t1 (a int primary key); +insert into t1 values (1),(2); +select * from t1 where a=1; --error ER_SUBQUERY_NO_1_ROW select f() from information_schema.table_statistics; --error ER_SUBQUERY_NO_1_ROW select f() from information_schema.index_statistics; set global userstat= 0; drop function f; +drop table t1; --enable_ps2_protocol --echo # @@ -145,7 +149,9 @@ set global userstat= 1; create or replace table t1 (a int, key(a)) engine=MyISAM; insert into t1 values (1),(2),(3),(4); flush index_statistics; +--disable_ps2_protocol select a from t1 where a in ( select a from t1 ); +--enable_ps2_protocol show index_statistics; drop table t1; set global userstat=@save_userstat; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 921687dce63..5a21e8ecd33 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2312,7 +2312,8 @@ retry_share: */ enum enum_mdl_type mdl_type= MDL_BACKUP_DML; - if (table->s->table_category != TABLE_CATEGORY_USER) + if (table->s->table_category != TABLE_CATEGORY_USER && + table->s->table_category != TABLE_CATEGORY_MYSQL) mdl_type= MDL_BACKUP_SYS_DML; else if (table->s->online_backup) mdl_type= MDL_BACKUP_TRANS_DML; diff --git a/sql/table.cc b/sql/table.cc index 181fc32fdbb..0551e502c05 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -324,6 +324,8 @@ TABLE_CATEGORY get_table_category(const Lex_ident_db &db, name.streq(SLOW_LOG_NAME) || name.streq(TRANSACTION_REG_NAME)) return TABLE_CATEGORY_LOG; + + return TABLE_CATEGORY_MYSQL; } return TABLE_CATEGORY_USER; diff --git a/sql/table.h b/sql/table.h index 314fcccbdcd..c34ac17de4f 100644 --- a/sql/table.h +++ b/sql/table.h @@ -490,6 +490,11 @@ enum enum_table_category */ TABLE_CATEGORY_LOG=5, + /** + Other tables in the mysql schema, like global_priv and db + */ + TABLE_CATEGORY_MYSQL= 6, + /* Types below are read only tables, not affected by FLUSH TABLES or MDL locks. @@ -514,7 +519,7 @@ enum enum_table_category to I_S tables in the table cache, which should use this table type. */ - TABLE_CATEGORY_INFORMATION=6, + TABLE_CATEGORY_INFORMATION=7, /** Performance schema tables. @@ -536,7 +541,7 @@ enum enum_table_category The server implementation perform writes. Performance tables are cached in the table cache. */ - TABLE_CATEGORY_PERFORMANCE=7 + TABLE_CATEGORY_PERFORMANCE=8 }; typedef enum enum_table_category TABLE_CATEGORY;