| 1 |
################### suite/perfschema/t/show_coverage.test ###################### |
| 2 |
# # |
| 3 |
# Testcases to increase DGCOV coverage of the status and system variable # |
| 4 |
# implementation in the Performance Schema. # |
| 5 |
# # |
| 6 |
################################################################################ |
| 7 |
--source include/have_perfschema.inc |
| 8 |
--source include/not_embedded.inc |
| 9 |
--source include/no_protocol.inc |
| 10 |
--source include/count_sessions.inc |
| 11 |
|
| 12 |
--echo # |
| 13 |
--echo # TEST 1 |
| 14 |
--echo # Handling of SHOW STATUS/VARIABLES ... WHERE |
| 15 |
--echo # |
| 16 |
SHOW STATUS WHERE VARIABLE_NAME LIKE "foo"; |
| 17 |
--echo # |
| 18 |
SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo"; |
| 19 |
--echo # |
| 20 |
SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo"; |
| 21 |
--echo # |
| 22 |
SHOW VARIABLES WHERE VARIABLE_NAME LIKE "foo"; |
| 23 |
--echo # |
| 24 |
SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo"; |
| 25 |
--echo # |
| 26 |
SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo"; |
| 27 |
|
| 28 |
--echo # |
| 29 |
--echo # TEST 2 |
| 30 |
--echo # CREATE..SELECT -- Expect correct ER_WARN_DEPRECATED_SYNTAX |
| 31 |
--echo # |
| 32 |
USE test; |
| 33 |
CREATE TABLE t0 SELECT * FROM information_schema.global_status WHERE variable_name = 'COM_SELECT'; |
| 34 |
DROP TABLE t0; |
| 35 |
|
| 36 |
--echo # |
| 37 |
--echo # TEST 3 |
| 38 |
--echo # Select status and system variable tables using ORDER BY to exercise the |
| 39 |
--echo # rnd_pos() method |
| 40 |
--echo # |
| 41 |
use performance_schema; |
| 42 |
--disable_result_log |
| 43 |
select * from global_variables order by variable_name; |
| 44 |
select * from variables_by_thread order by variable_name; |
| 45 |
select * from session_variables order by variable_name; |
| 46 |
select * from global_status order by variable_name; |
| 47 |
select * from session_status order by variable_name; |
| 48 |
select * from status_by_thread order by variable_name; |
| 49 |
select * from status_by_user order by variable_name; |
| 50 |
select * from status_by_host order by variable_name; |
| 51 |
select * from status_by_account order by variable_name; |
| 52 |
--enable_result_log |
| 53 |
|
| 54 |
--echo # |
| 55 |
--echo # TEST 4 |
| 56 |
--echo # Handling of SHOW STATUS/VARIABLES ... WHERE |
| 57 |
--echo # |
| 58 |
SHOW STATUS WHERE VARIABLE_NAME LIKE "foo"; |
| 59 |
--echo # |
| 60 |
SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo"; |
| 61 |
--echo # |
| 62 |
SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo"; |
| 63 |
--echo # |
| 64 |
SHOW VARIABLES WHERE VARIABLE_NAME LIKE "foo"; |
| 65 |
--echo # |
| 66 |
SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo"; |
| 67 |
--echo # |
| 68 |
SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo"; |
| 69 |
|
| 70 |
--echo # |
| 71 |
--echo # TEST 5 |
| 72 |
--echo # Confirm FLUSH STATUS resets counters for all threads. |
| 73 |
--echo # |
| 74 |
--echo # |
| 75 |
--echo # Create a new connection |
| 76 |
--connect(con1, localhost, root,,) |
| 77 |
--echo # |
| 78 |
--echo # Record thread id |
| 79 |
let $thread_id= `SELECT THREAD_ID FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID()`; |
| 80 |
--echo # |
| 81 |
--echo # Increase bytes_received for new connection |
| 82 |
USE test; |
| 83 |
SHOW TABLES; |
| 84 |
--connection default |
| 85 |
USE performance_schema; |
| 86 |
--disable_query_log |
| 87 |
eval SELECT $thread_id INTO @thread_id; |
| 88 |
--enable_query_log |
| 89 |
|
| 90 |
--echo # |
| 91 |
--echo # Record bytes_received for other connection |
| 92 |
SELECT variable_value FROM status_by_thread |
| 93 |
WHERE variable_name = "bytes_received" and thread_id = @thread_id INTO @bytes_before; |
| 94 |
--echo # |
| 95 |
--echo # Reset status counters |
| 96 |
FLUSH GLOBAL STATUS; |
| 97 |
--echo # |
| 98 |
--echo # Record bytes_received after reset |
| 99 |
SELECT variable_value FROM status_by_thread |
| 100 |
WHERE variable_name = "bytes_received" and thread_id = @thread_id INTO @bytes_after; |
| 101 |
--echo # |
| 102 |
--echo # Expect bytes_before > bytes_after |
| 103 |
SELECT @bytes_before > @bytes_after AS 'Expect 1'; |
| 104 |
--echo # |
| 105 |
--echo # Expect bytes_after is zero |
| 106 |
SELECT @bytes_after AS 'Expect 0'; |
| 107 |
|
| 108 |
disconnect con1; |
| 109 |
--source include/wait_until_count_sessions.inc |
| 110 |
|
| 111 |
|
| 112 |
--echo # |
| 113 |
--echo # TEST 6 |
| 114 |
--echo # |
| 115 |
--echo # Bug#28291258 FLUSH STATUS ADDS TWICE TO GLOBAL VALUES |
| 116 |
--echo # |
| 117 |
|
| 118 |
--echo # |
| 119 |
--echo # Default connection |
| 120 |
--let $initial_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1) |
| 121 |
|
| 122 |
--source include/count_sessions.inc |
| 123 |
|
| 124 |
--echo # |
| 125 |
--echo # First connection |
| 126 |
--connect (con1, localhost, root,,) |
| 127 |
|
| 128 |
## Global value requested from the first session must not change |
| 129 |
--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1) |
| 130 |
--let $assert_cond = $current_global_value - $initial_global_value = 0 |
| 131 |
--let $assert_text = Global value requested from the first session must not change |
| 132 |
--source include/assert.inc |
| 133 |
|
| 134 |
--echo # |
| 135 |
--echo # Generate a slow query |
| 136 |
--echo # |
| 137 |
SET long_query_time = 2; |
| 138 |
SELECT SLEEP(4); |
| 139 |
SET long_query_time = @@global.long_query_time; |
| 140 |
--echo # |
| 141 |
|
| 142 |
## Global value requested from the first session after SLEEP() must increase by 1 |
| 143 |
--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1) |
| 144 |
--let $first_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1) |
| 145 |
--let $assert_cond = $current_global_value - $initial_global_value = 1 |
| 146 |
--let $assert_text = Global value requested from the first session after SLEEP() must increase by 1 |
| 147 |
--source include/assert.inc |
| 148 |
--let $assert_cond = $first_session_value = 1 |
| 149 |
--let $assert_text = First session value must increase by 1 |
| 150 |
--source include/assert.inc |
| 151 |
|
| 152 |
--connection default |
| 153 |
--disconnect con1 |
| 154 |
--source include/wait_until_count_sessions.inc |
| 155 |
|
| 156 |
--echo # |
| 157 |
--echo # Default connection |
| 158 |
--connection default |
| 159 |
|
| 160 |
## Global value requested from the default session after DISCONNECT must remain the same |
| 161 |
--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1) |
| 162 |
--let $default_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1) |
| 163 |
--let $assert_cond = $current_global_value - $initial_global_value = 1 |
| 164 |
--let $assert_text = Global value requested from the default session after DISCONNECT must remain the same |
| 165 |
--source include/assert.inc |
| 166 |
|
| 167 |
## Default session value must remain zero |
| 168 |
--let $assert_cond = $default_session_value = 0 |
| 169 |
--let $assert_text = Default session value must remain zero |
| 170 |
--source include/assert.inc |
| 171 |
|
| 172 |
--echo # |
| 173 |
FLUSH GLOBAL STATUS; |
| 174 |
--echo # |
| 175 |
|
| 176 |
## Global value requested from the default session after FLUSH must remain the same |
| 177 |
--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1) |
| 178 |
--let $default_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1) |
| 179 |
--let $assert_cond = $current_global_value - $initial_global_value = 1 |
| 180 |
--let $assert_text = Global value requested from the default session after FLUSH must remain the same |
| 181 |
--source include/assert.inc |
| 182 |
|
| 183 |
## Default session value after FLUSH must remain zero |
| 184 |
--let $assert_cond = $default_session_value = 0 |
| 185 |
--let $assert_text = Default session value after FLUSH must remain zero |
| 186 |
--source include/assert.inc |