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
|
TABLE: "host_cache"
INDEXES: PK (IP), KEY (HOST)
===== SETUP =====
## Connection Default
## Disable events from the default connection
## Create user1, user2, user3
CREATE USER user1@localhost;
CREATE USER user2@localhost;
CREATE USER user3@localhost;
GRANT ALL ON *.* to 'user1'@localhost;
GRANT ALL ON *.* to 'user2'@localhost;
GRANT ALL ON *.* to 'user3'@localhost;
## Setup test connection 1
## Setup test connection 2
## Setup test connection 3
## Default connection
## Create data tables
CREATE TABLE test.t1(a INT, b INT, c INT, d INT DEFAULT 0, PRIMARY KEY(a), INDEX index_b(b), INDEX index_cb(c, b));
CREATE TABLE test.t2 LIKE test.t1;
CREATE TABLE test.t3 LIKE test.t1;
## Generate event data from 3 connections
## Connection 1
## Connection 2
## Connection 3
## Connection 2
## Create prepared statements on connection 2
PREPARE st1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
PREPARE st3 FROM 'INSERT INTO test.t1 SELECT * FROM test.t1 WHERE a<=?';
PREPARE st4 FROM '(SELECT a FROM test.t1) UNION (SELECT a+10 FROM test.t1) ORDER BY RAND()*0+a';
## Create stored procedure connection 2
CREATE PROCEDURE SampleProc1()
BEGIN
SET @table = 'test.t1';
SET @s = CONCAT('SELECT * FROM ', @table);
PREPARE st2 FROM @s;
END|
Call SampleProc1() to prepare a statement
CALL SampleProc1();
## Connection default
## Use Connection 2 for default target thread id
## Create index_test() procedure
call mtr.add_suppression("192.0.2.4");
flush status;
TRUNCATE TABLE performance_schema.host_cache;
flush user_resources;
flush privileges;
select @@global.debug;
@@global.debug
select @@global.max_connect_errors;
@@global.max_connect_errors
100
select @@global.max_user_connections;
@@global.max_user_connections
0
select @@global.max_connections;
@@global.max_connections
151
select `User`, `Host` from mysql.`user` where `host` like '%\\%%';
User Host
select `User`, `Host` from mysql.`user` where `user` like '192.%';
User Host
select `User`, `Host` from mysql.`user` where `user` like '2001:%';
User Host
select `User`, `Host` from mysql.`user` where `user` like 'santa.claus.%';
User Host
CREATE USER 'user4'@'santa.claus.ipv4.example.com';
GRANT SELECT ON test.* TO 'user4'@'santa.claus.ipv4.example.com';
SET global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
SELECT "Con4 is alive" AS "";
Con4 is alive
SELECT current_user() AS "";
user4@santa.claus.ipv4.example.com
"Dumping performance_schema.host_cache"
IP 192.0.2.4
HOST santa.claus.ipv4.example.com
HOST_VALIDATED YES
SUM_CONNECT_ERRORS 0
COUNT_HOST_BLOCKED_ERRORS 0
COUNT_NAMEINFO_TRANSIENT_ERRORS 0
COUNT_NAMEINFO_PERMANENT_ERRORS 0
COUNT_FORMAT_ERRORS 0
COUNT_ADDRINFO_TRANSIENT_ERRORS 0
COUNT_ADDRINFO_PERMANENT_ERRORS 0
COUNT_FCRDNS_ERRORS 0
COUNT_HOST_ACL_ERRORS 0
COUNT_NO_AUTH_PLUGIN_ERRORS 0
COUNT_AUTH_PLUGIN_ERRORS 0
COUNT_HANDSHAKE_ERRORS 0
COUNT_PROXY_USER_ERRORS 0
COUNT_PROXY_USER_ACL_ERRORS 0
COUNT_AUTHENTICATION_ERRORS 0
COUNT_SSL_ERRORS 0
COUNT_MAX_USER_CONNECTIONS_ERRORS 0
COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS 0
COUNT_DEFAULT_DATABASE_ERRORS 0
COUNT_INIT_CONNECT_ERRORS 0
COUNT_LOCAL_ERRORS 0
COUNT_UNKNOWN_ERRORS 0
FIRST_ERROR_SEEN null
LAST_ERROR_SEEN null
SET global debug= default;
## Test IP
SET @pfs_columns = "IP, HOST";
===== BEGIN TEST =====
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE IP is null
OK: Handler_read_key
OK: Result set: Empty Expected: Empty
OK: Extra rows: 0 Missing rows: 0
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE IP is not null
OK: Handler_read_key
OK: Result set: Non-empty Expected: Non-empty
OK: Extra rows: 0 Missing rows: 0
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE IP = '192.0.2.4'
OK: Handler_read_key
OK: Result set: Non-empty Expected: Non-empty
OK: Extra rows: 0 Missing rows: 0
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE IP = 'impossible'
OK: Handler_read_key
OK: Result set: Empty Expected: Empty
OK: Extra rows: 0 Missing rows: 0
## Test HOST
SET @pfs_columns = "IP, HOST";
===== BEGIN TEST =====
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE host = 'santa.claus.ipv4.example.com'
OK: Handler_read_key
OK: Result set: Non-empty Expected: Non-empty
OK: Extra rows: 0 Missing rows: 0
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE host IS NULL
OK: Handler_read_key
OK: Result set: Empty Expected: Empty
OK: Extra rows: 0 Missing rows: 0
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE host IS NOT NULL
OK: Handler_read_key
OK: Result set: Non-empty Expected: Non-empty
OK: Extra rows: 0 Missing rows: 0
========
SELECT IP, HOST FROM performance_schema.host_cache WHERE host = 'nohost'
OK: Handler_read_key
OK: Result set: Empty Expected: Empty
OK: Extra rows: 0 Missing rows: 0
===== CLEAN UP =====
## Default connection
DEALLOCATE PREPARE st1;
DEALLOCATE PREPARE st2;
DEALLOCATE PREPARE st3;
DEALLOCATE PREPARE st4;
DROP PROCEDURE SampleProc1;
DROP PROCEDURE index_test;
DROP TABLE IF EXISTS test.indexes_off;
DROP TABLE IF EXISTS test.indexes_on;
DROP TABLE test.t1;
DROP TABLE test.t2;
DROP TABLE test.t3;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user2@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user3@localhost;
DROP USER user1@localhost;
DROP USER user2@localhost;
DROP USER user3@localhost;
UPDATE performance_schema.threads SET INSTRUMENTED = 'YES';
REVOKE SELECT ON test.* FROM 'user4'@'santa.claus.ipv4.example.com';
DROP USER 'user4'@'santa.claus.ipv4.example.com';
|