1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
# Tests for PERFORMANCE_SCHEMA
# Miscelaneous
--source include/not_embedded.inc
--source include/have_perfschema.inc
--source include/have_innodb.inc
--source include/no_protocol.inc
#
# Bug#12790483 OBJECTS_SUMMARY_GLOBAL_BY_TYPE AND RENAME TABLE
#
# Rename table leaves old tables names behind in
# performance_schema.objects_summary_global_by_type
#
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
CREATE TABLE test.t_before(a INT);
INSERT INTO test.t_before VALUES (1);
# The new table should appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE.
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
RENAME TABLE test.t_before TO test.t_after;
# The renamed table should appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE, but only
# after it is accessed.
SELECT COUNT(*) FROM test.t_after;
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
DROP TABLE test.t_after;
# The renamed table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE.
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
#
# Verify table views are ignored by the table io instrumentation.
#
CREATE TABLE test.t1(a INT);
INSERT INTO test.t1 VALUES (1);
CREATE VIEW test.v1 AS SELECT * FROM test.t1;
SELECT COUNT(*) FROM test.v1;
# Verify that a PFS table share was not created for the view.
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
DROP VIEW test.v1;
DROP TABLE test.t1;
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
#
# Bug#45496 Performance schema: assertion fails in
# ha_perfschema::rnd_init:223
#
--disable_result_log
SELECT EVENT_ID FROM performance_schema.events_waits_current
WHERE THREAD_ID IN
(SELECT THREAD_ID FROM performance_schema.threads)
AND EVENT_NAME IN
(SELECT NAME FROM performance_schema.setup_instruments
WHERE NAME LIKE "wait/synch/%")
LIMIT 1;
--enable_result_log
#
# Bug#45088 Should not be able to create tables of engine PERFORMANCE_SCHEMA
#
--error ER_CANT_CREATE_TABLE
create table test.t1(a int) engine=performance_schema;
# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
#
# Bug#44897 Performance Schema: can create a ghost table in another database
#
--error ER_CANT_CREATE_TABLE
create table test.t1 like performance_schema.events_waits_current;
# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
#
# Bug#44898 PerformanceSchema: can create a table in db performance_schema, cannot insert
#
--error ER_TABLEACCESS_DENIED_ERROR
create table performance_schema.t1(a int);
# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE
SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
WHERE object_schema='test';
#
# Bug#51447 performance schema evil twin files
#
--disable_warnings
drop table if exists test.ghost;
--enable_warnings
create table test.ghost (a int, b int);
alter table test.ghost add index index_a(a);
alter table test.ghost add index index_b(b);
insert into test.ghost values (1, 3);
insert into test.ghost values (2, 4);
select * from test.ghost;
drop table test.ghost;
# Shoud return nothing
select * from performance_schema.file_instances
where file_name like "%ghost%";
#
# Bug#52586 Misleading error message on attempt to access
# a P_S table using a wrong name
--error ER_NO_SUCH_TABLE
select * from performance_schema.no_such_table;
#
# Bug#12370950 - 60905: TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE AGGREGATES NON-INSERT DML WRONGLY
#
--disable_warnings
DROP TABLE IF EXISTS t_60905;
--enable_warnings
CREATE TABLE t_60905 (i INT, j INT, KEY(i)) ENGINE = InnoDB;
INSERT INTO t_60905 VALUES
(1,2), (3,4), (5,6), (7,8), (9,10);
# should delete with a "single" PRIMARY lookup (2 PRIMARY fetch, 1 PRIMARY delete)
DELETE FROM t_60905 WHERE i = 1;
# should delete with a full scan (5 NULL fetch, 1 NULL delete)
DELETE FROM t_60905 WHERE j = 8;
# show the instrument data.
SELECT object_schema,
object_name,
index_name,
count_fetch,
count_insert,
count_update,
count_delete
FROM performance_schema.table_io_waits_summary_by_index_usage
WHERE object_schema = 'test'
AND object_name = 't_60905';
DROP TABLE t_60905;
#
# Bug#71278 NUMBER OF ROWS IN PERFORMANCE SCHEMA TABLES
#
show global variables like "performance_schema_max_thread_instances";
replace_result 512 256;
explain select * from performance_schema.threads;
#
# Bug #73082 SHOW EVENTS in performance_schema gives Access Denied
#
use performance_schema;
show events;
show events from performance_schema;
show events where Db= 'performance_schema';
use test;
#
# Bug#11929832 - EVENTS_STATEMENTS_HISTORY HAS ERRORS=0 WHEN THERE ARE ERRORS
#
# Verify that SQL errors are properly counted.
use test;
truncate performance_schema.events_statements_history;
truncate performance_schema.events_statements_history_long;
--error ER_NO_SUCH_TABLE
select * from t1;
--echo
select mysql_errno, returned_sqlstate, message_text, errors, warnings
from performance_schema.events_statements_history where errors > 0;
--echo #
select mysql_errno, returned_sqlstate, message_text, errors, warnings from
performance_schema.events_statements_history_long where errors > 0;
#
# Bug#20519832 - TRUNCATED SQL_TEXT values are not suffixed with '...'
#
# Verify that truncated SQL statements are suffixed with '...'
use performance_schema;
truncate performance_schema.events_statements_history;
# Should truncate at 1024 bytes (1024 characters)
select 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' AS A;
# Should truncate at 1024 bytes (487 characters)
select _utf8mb4 'ваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑваÑÑ' as B;
select count(*) from events_statements_history where sql_text like "%...";
#
# MDEV-10486 MariaDB 10.x does not update rows_examined in performance_schema tables
# Verify that the rows_examined counter is set properly.
use test;
create table t1 (id int);
insert into t1 values (1), (2), (3);
truncate performance_schema.events_statements_history;
select * from t1;
insert into t1 select RAND()*10000 from t1;
select sql_text, rows_examined from performance_schema.events_statements_history;
drop table t1;
--echo #
--echo # MDEV-17896 Assertion `pfs->get_refcount() > 0' failed
--echo # in release_table_share
--echo #
# There must be at least one available slot in PFS table_share_array for
# this test to be meaningful. If there are no free slots we must
# restart mysqld, it is the only way to reset PFS table_share_array
let $query= SELECT COUNT(*)<@@performance_schema_max_table_instances FROM
performance_schema.objects_summary_global_by_type WHERE OBJECT_TYPE='TABLE';
let $free_slots_available= `$query`;
if (!$free_slots_available)
{
source include/restart_mysqld.inc;
}
eval $query;
CREATE TABLE t0(a INT);
# TABLE_SHARE must be cached in the table definition cache.
SELECT * FROM t0;
# Dropping t0 using DROP TEMPORARY frees up a slot in table_share_array,
# but the persistent table is not correctly dropped, i.e. TABLE_SHARE::m_psi
# still points to that slot in table_share_array.
DROP TEMPORARY TABLE IF EXISTS t0;
# Try re-using each and every slot in PFS table_share_array. If bug is
# there, we re-use t0 slot.
# The newly created table that re-uses the t0 slot ends up
# resetting the PFS_table_share refcount.
let $i= `SELECT @@performance_schema_max_table_instances`;
disable_query_log;
while ($i)
{
# Memory engine is here to reduce disk IO
eval CREATE TABLE t$i(a INT) ENGINE=MEMORY;
eval DROP TABLE t$i;
dec $i;
}
enable_query_log;
# FLUSH TABLE crashes the server when PFS_table_share is found with
# an unexpected refcount.
FLUSH TABLE t0;
DROP TABLE t0;
--echo #
--echo # MDEV-24364 Alter rename table does not remove PFS share
--echo #
create or replace table yt4 (x int) engine innodb;
alter table yt4 rename to t1, algorithm=copy;
drop tables t1;
select object_type, object_schema, object_name
from performance_schema.objects_summary_global_by_type
where object_schema="test";
--echo #
--echo # MDEV-28344: sys.ps_setup_save and dependent procedures fail
--echo # with ER_ILLEGAL_HA_CREATE_OPTION
--echo #
# It is not allowed to create temporary tables with performance schema
--error ER_ILLEGAL_HA_CREATE_OPTION
CREATE TEMPORARY TABLE t1 (t int) ENGINE = PERFORMANCE_SCHEMA;
--error ER_ILLEGAL_HA_CREATE_OPTION
CREATE TEMPORARY TABLE t1 LIKE performance_schema.setup_actors;
SET @default_storage_engine_old = @@default_storage_engine;
SET default_storage_engine = performance_schema;
--error ER_ILLEGAL_HA_CREATE_OPTION
CREATE TEMPORARY TABLE t1 (t int);
SET @@default_storage_engine = @default_storage_engine_old;
|