polardbxengine/mysql-test/suite/x/t/performance_schema.test

1031 lines
23 KiB
Plaintext

## Tests detecting presence of xplugin objects in PERFORMANCE_SCHEMA.
## Preamble
--source ../include/have_performance_schema_threads.inc
--source include/xplugin_preamble.inc
--source include/xplugin_create_user.inc
# Tests
--write_file $MYSQL_TMP_DIR/performance_schema.tmp
-->quiet
-->sql
update performance_schema.setup_instruments set ENABLED='YES' where NAME like '%mysqlx%';
update performance_schema.setup_instruments set ENABLED='NO' where NAME like 'wait/synch/mutex/mysqlx/lock_list_access';
update performance_schema.setup_instruments set ENABLED='NO' where NAME like 'wait/synch/mutex/mysqlx/scheduler_dynamic_worker_pending';
update performance_schema.setup_instruments set ENABLED='NO' where NAME like 'wait/synch/cond/mysqlx/scheduler_dynamic_worker_pending';
update performance_schema.setup_consumers set ENABLED='YES' where NAME like 'events_waits%';
TRUNCATE TABLE performance_schema.events_waits_history_long;
TRUNCATE TABLE performance_schema.events_waits_history;
SELECT DISTINCT name FROM performance_schema.threads WHERE name
LIKE 'thread/mysqlx/%' ORDER BY name;
SELECT DISTINCT name FROM performance_schema.mutex_instances WHERE name
LIKE 'wait/synch/mutex/mysqlx/%' AND name NOT LIKE '%unix%' ORDER BY name;
SELECT DISTINCT name FROM performance_schema.cond_instances WHERE name
LIKE 'wait/synch/cond/mysqlx/%' AND name NOT LIKE '%unix%' ORDER BY name;
SELECT DISTINCT name FROM performance_schema.rwlock_instances WHERE name
LIKE 'wait/synch/rwlock/mysqlx/%' AND name NOT LIKE '%unix%' ORDER BY name;
SELECT * FROM performance_schema.setup_instruments WHERE name like '%mysqlx%'
AND name NOT LIKE '%unix%';
# Threads Table Functional Scenario
##########################################################################
update performance_schema.threads
set instrumented= 'NO' where PROCESSLIST_ID=connection_id();
select instrumented from performance_schema.threads
where PROCESSLIST_ID=connection_id();
update performance_schema.threads
set instrumented= 'YES' where PROCESSLIST_ID=connection_id();
select instrumented from performance_schema.threads
where PROCESSLIST_ID=connection_id();
LOCK TABLES performance_schema.threads READ;
UNLOCK TABLES;
LOCK TABLES performance_schema.threads WRITE;
UNLOCK TABLES;
###########################################################################
# DDL and DML Error Scenarios
###########################################################################
# DDL Operations Check
###########################################################################
# error ER_DBACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.mutex_instances add column foo integer;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.cond_instances add column foo integer;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.threads add column foo integer;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.rwlock_instances add column foo integer;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.socket_instances add column foo integer;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.socket_summary_by_event_name add column foo integer;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
alter table performance_schema.socket_summary_by_instance add column foo integer;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
truncate table performance_schema.mutex_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
truncate table performance_schema.cond_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
truncate table performance_schema.threads;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
truncate table performance_schema.rwlock_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
truncate table performance_schema.socket_instances;
-->endsql
-->sql
truncate table performance_schema.socket_summary_by_event_name;
-->endsql
-->sql
truncate table performance_schema.socket_summary_by_instance;
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.mutex_instances ADD INDEX test_index(NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.cond_instances ADD INDEX test_index(NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.threads ADD INDEX test_index(PROCESSLIST_ID);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.rwlock_instances ADD INDEX test_index(NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.rwlock_instances ADD INDEX socket_instances(STATE);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.rwlock_instances ADD INDEX socket_summary_by_event_name(EVENT_NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
ALTER TABLE performance_schema.rwlock_instances ADD INDEX socket_summary_by_instance(EVENT_NAME);
# error ER_DBACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.mutex_instances(NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.cond_instances(NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.threads(PROCESSLIST_ID);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.rwlock_instances(NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.socket_instances(STATE);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.socket_summary_by_event_name(EVENT_NAME);
-->endsql
-->expecterror ER_DBACCESS_DENIED_ERROR
-->sql
CREATE UNIQUE INDEX test_index ON performance_schema.socket_summary_by_instance(EVENT_NAME);
# DML Operations Check
###########################################################################
# error ER_TABLEACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.mutex_instances
set name='FOO', object_instance_begin=12;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.cond_instances
set name='FOO', object_instance_begin=12;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.threads
set name='FOO', thread_id=1, processlist_id=2;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.rwlock_instances
set name='FOO', object_instance_begin=12;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.socket_instances
set ip='', port=12;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.socket_summary_by_event_name
set event_name='FOO', count_read=12;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
insert into performance_schema.socket_summary_by_instance
set event_name='FOO', count_misc=12;
# error ER_TABLEACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
update performance_schema.mutex_instances
set name='FOO';
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
update performance_schema.cond_instances
set name='FOO';
-->endsql
-->expecterror ER_WRONG_PERFSCHEMA_USAGE
-->sql
update performance_schema.threads
set thread_id=12 where PROCESSLIST_ID=connection_id();
-->endsql
-->expecterror ER_WRONG_PERFSCHEMA_USAGE
-->sql
update performance_schema.threads
set thread_id=12;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
update performance_schema.rwlock_instances
set name='FOO';
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
update performance_schema.socket_instances
set ip='FOO';
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
update performance_schema.socket_summary_by_event_name
set event_name='FOO';
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
update performance_schema.socket_summary_by_instance
set event_name='FOO';
# error ER_TABLEACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.mutex_instances
where name like "wait/%";
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.cond_instances
where name like "wait/%";
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.threads
where id=1;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.rwlock_instances
where name like "wait/%";
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.socket_instances
where event_name like "wait/%";
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.socket_summary_by_event_name
where event_name like "wait/%";
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.socket_summary_by_instance
where event_name like "wait/%";
# error ER_TABLEACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.mutex_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.cond_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.threads;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.rwlock_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.socket_instances;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.socket_summary_by_event_name;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
delete from performance_schema.socket_summary_by_instance;
# error ER_TABLEACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.mutex_instances READ;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.cond_instances READ;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.rwlock_instances READ;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.socket_instances READ;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.socket_summary_by_event_name READ;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.socket_summary_by_instance READ;
UNLOCK TABLES;
# error ER_TABLEACCESS_DENIED_ERROR
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.mutex_instances WRITE;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.cond_instances WRITE;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.rwlock_instances WRITE;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.socket_instances WRITE;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.socket_summary_by_event_name WRITE;
UNLOCK TABLES;
-->endsql
-->expecterror ER_TABLEACCESS_DENIED_ERROR
-->sql
LOCK TABLES performance_schema.socket_summary_by_instance WRITE;
UNLOCK TABLES;
-->endsql
# Checking the tables with Mysql Crud Find
#================================================
Mysqlx.Crud.Find {
collection {
name: "threads"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "name"
}
}
}
}
alias: "name"
}
criteria {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "mutex_instances"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "name"
}
}
}
}
alias: "name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "cond_instances"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "name"
}
}
}
}
alias: "name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "rwlock_instances"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "name"
}
}
}
}
alias: "name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "socket_instances"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
alias: "event_name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "socket_instances"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
alias: "event_name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "socket_summary_by_event_name"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
alias: "event_name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
-->recvresult
Mysqlx.Crud.Find {
collection {
name: "socket_summary_by_instance"
schema: "performance_schema"
}
data_model: TABLE
projection {
source {
type: FUNC_CALL
function_call {
name {
name: "DISTINCT"
}
param {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
alias: "event_name"
}
criteria {
type: OPERATOR
operator {
name: "&&"
param {
type: OPERATOR
operator {
name: "like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%mysqlx%"}
}
}
}
}
param {
type: OPERATOR
operator {
name: "not_like"
param {
type: IDENT
identifier {
name: "event_name"
}
}
param {
type: LITERAL
literal {
type: V_OCTETS
v_octets {value:"%unix%"}
}
}
}
}
}
}
order {
expr {
type: IDENT
identifier {
name: "event_name"
}
}
}
}
-->recvresult
-->stmtadmin ping
-->stmtsql select sleep(1);
-->stmtadmin ping
-->stmtadmin ping
-->recvresult
-->recvresult
-->recvresult
-->recvresult
EOF
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/performance_schema.tmp 2>&1
## Needs rework
## select DISTINCT EVENT_NAME from performance_schema.events_waits_current
## where EVENT_NAME like '%mysqlx%' ORDER BY EVENT_NAME;
select DISTINCT EVENT_NAME from performance_schema.events_waits_history
where EVENT_NAME rlike '^wait/synch/mutex/mysqlx/(client_session|obuffer|queue)$' ORDER BY EVENT_NAME;
select DISTINCT EVENT_NAME from performance_schema.events_waits_history_long
where EVENT_NAME rlike '^wait/synch/(cond|mutex)/mysqlx/(queue|client_session|obuffer|queue)$' ORDER BY EVENT_NAME;
## Cleanup
update performance_schema.setup_instruments set ENABLED='YES'
where NAME rlike '^wait/synch/(cond|mutex)/mysqlx/(lock_list_access|scheduler_dynamic_worker_pending)$';
-- echo # Check if any classes are not lost, this may happen if they are already
-- echo # just on the limit
SELECT * FROM performance_schema.global_status
WHERE variable_name LIKE '%_LOST' AND variable_value > 0;
--remove_file $MYSQL_TMP_DIR/performance_schema.tmp
--source include/xplugin_drop_user.inc