| 1 |
|
| 2 |
--source include/have_debug.inc |
| 3 |
|
| 4 |
--disable_query_log |
| 5 |
|
| 6 |
--disable_warnings |
| 7 |
drop table if exists test.pfs_published_schema; |
| 8 |
drop table if exists test.pfs_check_table; |
| 9 |
drop procedure if exists test.pfs_check_proc; |
| 10 |
--enable_warnings |
| 11 |
|
| 12 |
--echo "Checking the data dictionary properties ..." |
| 13 |
|
| 14 |
SET SESSION debug= '+d,skip_dd_table_access_check'; |
| 15 |
SELECT SUBSTRING_INDEX(SUBSTRING(properties, LOCATE('PS_VERSION', properties), 30), ';', 1) |
| 16 |
FROM mysql.dd_properties; |
| 17 |
SET SESSION debug= '-d,skip_dd_table_access_check'; |
| 18 |
|
| 19 |
SET @old_group_concat_max_len = @@group_concat_max_len; |
| 20 |
|
| 21 |
# We need 1700 rows of varchar(64) concatenated |
| 22 |
SET group_concat_max_len = 200000; |
| 23 |
|
| 24 |
create table test.pfs_published_schema |
| 25 |
(version varchar(20), signature varchar(64), primary key (version)); |
| 26 |
|
| 27 |
# |
| 28 |
# MAINTAINER: |
| 29 |
# |
| 30 |
# ONCE A RELEASE IS PUBLISHED, |
| 31 |
# DO NOT EVER CHANGE THE SIGNATURES HERE. |
| 32 |
# |
| 33 |
# The whole point of this MTR test script is that |
| 34 |
# it will fail if any change to the performance schema |
| 35 |
# database structure is detected, acting as a fail safe. |
| 36 |
# |
| 37 |
# If a change was intended, then: |
| 38 |
# - (a) Go in storage/perfschema/pfs_dd_version.h |
| 39 |
# and create a new version number for this release |
| 40 |
# - (b) Add a row in table test.pfs_published_schema |
| 41 |
# for the new schema published, using the signature |
| 42 |
# of the new schema. |
| 43 |
# |
| 44 |
# (a) will ensure that upgrades from old releases |
| 45 |
# will notice the schema change, and upgrade |
| 46 |
# the performance_schema structure in the data dictionary accordingly. |
| 47 |
# (b) will ensure this test pass again without the SIGNAL complaining. |
| 48 |
# |
| 49 |
# BEWARE, failure to do (a) when doing (b) alone |
| 50 |
# **WILL** result in broken upgrades, |
| 51 |
# with a server binary using a new table definition |
| 52 |
# in the code and an old, different, table definition |
| 53 |
# in the data dictionary found on disk. |
| 54 |
# |
| 55 |
# This test is designed to be a reminder to do (a) |
| 56 |
# by detecting differences in (b) |
| 57 |
# |
| 58 |
# If you fail to properly update PFS_DD_VERSION, |
| 59 |
# git blame will find you. |
| 60 |
# |
| 61 |
|
| 62 |
# Keeping track of all signatures published in GA ... |
| 63 |
|
| 64 |
insert into test.pfs_published_schema |
| 65 |
values("MySQL 8.0.17", |
| 66 |
"b77ece4deaa3c4676d817ed98c3cc33f5b1a08a001bf610a7d02fb52a42b613d"); |
| 67 |
|
| 68 |
insert into test.pfs_published_schema |
| 69 |
values("MySQL 8.0.172", |
| 70 |
"4b2535cee3a558d09b93caaa1fe9021da9e758ffcacd0922bea81ae9799175dc"); |
| 71 |
|
| 72 |
insert into test.pfs_published_schema |
| 73 |
values("MySQL 8.0.18", |
| 74 |
"1d6747d842bb2483c860cd7b28e886bdc6111ff61fd6b4d07e367aa7b3e9d9bf"); |
| 75 |
|
| 76 |
insert into test.pfs_published_schema |
| 77 |
values("MySQL 8.0.19", |
| 78 |
"f58dba20c4234c34cedfcacd3b9a295dcac77a09b79d5f41d5f740878f272d4d"); |
| 79 |
|
| 80 |
insert into test.pfs_published_schema |
| 81 |
values("MySQL 8.0.20", |
| 82 |
"a9aa0ab4a94ca91622145d735e60bbb03577616970351032d3194d8bfd7a69c7"); |
| 83 |
|
| 84 |
insert into test.pfs_published_schema |
| 85 |
values("MySQL 8.0.21", |
| 86 |
"112972e1f7d2b3a351a14979ecc3b419efc81e79dc029078a3a94955be218e5a"); |
| 87 |
|
| 88 |
insert into test.pfs_published_schema |
| 89 |
values("MySQL 8.0.22", |
| 90 |
"b9000c4a106a8351d2274028965f19d7902c3ccb9faa9407603c9258812f77fe"); |
| 91 |
|
| 92 |
insert into test.pfs_published_schema |
| 93 |
values("MySQL 8.0.23", |
| 94 |
"903e1e93e60651094708033160338ba66b6e59a733111e773cac126adc932488"); |
| 95 |
|
| 96 |
insert into test.pfs_published_schema |
| 97 |
values("MySQL 8.0.24", |
| 98 |
"2db5b001fae56232df1c5fab4be6bbf10d47873a6ad55f36ad9d9be20632e973"); |
| 99 |
|
| 100 |
insert into test.pfs_published_schema |
| 101 |
values("MySQL 8.0.27", |
| 102 |
"b229e37b78fcb1a522fb01991615e092888071981515ceca629030d7c9ae66c4"); |
| 103 |
|
| 104 |
insert into test.pfs_published_schema |
| 105 |
values("MySQL 8.0.28", |
| 106 |
"9984eaa4462410f61339028551966d92815f4287dac45358ca326b5c55333ddf"); |
| 107 |
|
| 108 |
insert into test.pfs_published_schema |
| 109 |
values("MySQL 8.0.29", |
| 110 |
"94c77e0c2a4f4e6616648a8ec30aebc10eee06889338a06473434fd39dc80b3a"); |
| 111 |
|
| 112 |
insert into test.pfs_published_schema |
| 113 |
values("MySQL 8.0.30", |
| 114 |
"977641d414b2df02e404d2ca3b9fbdf6d0af30f196f7de729a67d5b6183c17a8"); |
| 115 |
|
| 116 |
insert into test.pfs_published_schema |
| 117 |
values("MySQL 8.0.31", |
| 118 |
"572cf94b0e4b955d16ae57de514a8d93ef746f7c97e74c16b6666687bff51c6d"); |
| 119 |
|
| 120 |
insert into test.pfs_published_schema |
| 121 |
values("MySQL 8.0.32", |
| 122 |
"f1f4333cbce3fb0e8840ecacd6d0d417abfdf7dcbf61b01180c73a837ec0753b"); |
| 123 |
|
| 124 |
insert into test.pfs_published_schema |
| 125 |
values("MySQL 8.0.33", |
| 126 |
"00421db55e31bdc58161e2051c78e6b2040250db74f63afe3e473441d43769b4"); |
| 127 |
|
| 128 |
insert into test.pfs_published_schema |
| 129 |
values("MySQL 8.0.40", |
| 130 |
"b56610322b2a64779b7cfe96976cd0b5c6542a098bec88dacb0bb8a1fe7be458"); |
| 131 |
|
| 132 |
create table test.pfs_check_table |
| 133 |
(id int NOT NULL AUTO_INCREMENT, |
| 134 |
t text NOT NULL, |
| 135 |
row_hash varchar(64) default null, |
| 136 |
PRIMARY KEY (id)); |
| 137 |
|
| 138 |
delimiter $$; |
| 139 |
|
| 140 |
create procedure test.pfs_check_proc() |
| 141 |
begin |
| 142 |
declare whole_schema longtext; |
| 143 |
declare max_length int; |
| 144 |
declare found_signature varchar(64); |
| 145 |
declare found_version varchar(20); |
| 146 |
|
| 147 |
insert into test.pfs_check_table(t) |
| 148 |
select concat(CATALOG_NAME, "-", |
| 149 |
SCHEMA_NAME, "-", |
| 150 |
DEFAULT_CHARACTER_SET_NAME, "-", |
| 151 |
DEFAULT_COLLATION_NAME, "-", |
| 152 |
ifnull(SQL_PATH, "NULL")) |
| 153 |
from INFORMATION_SCHEMA.SCHEMATA |
| 154 |
where SCHEMA_NAME = "performance_schema"; |
| 155 |
|
| 156 |
insert into test.pfs_check_table(t) |
| 157 |
select concat(TABLE_CATALOG, "-", |
| 158 |
TABLE_SCHEMA, "-", |
| 159 |
TABLE_NAME, "-", |
| 160 |
TABLE_TYPE, "-", |
| 161 |
ENGINE, "-", |
| 162 |
VERSION, "-", |
| 163 |
ROW_FORMAT, "-", |
| 164 |
ifnull(AUTO_INCREMENT, "no_auto_increment"), "-", |
| 165 |
ifnull(TABLE_COLLATION, "no_collation"), "-", |
| 166 |
ifnull(CREATE_OPTIONS, "no_create_options"), "-", |
| 167 |
ifnull(TABLE_COMMENT, "no_table_comments")) |
| 168 |
from INFORMATION_SCHEMA.TABLES |
| 169 |
where TABLE_SCHEMA = "performance_schema" |
| 170 |
order by TABLE_NAME; |
| 171 |
|
| 172 |
insert into test.pfs_check_table(t) |
| 173 |
select concat(TABLE_CATALOG, "-", |
| 174 |
TABLE_SCHEMA, "-", |
| 175 |
TABLE_NAME, "-", |
| 176 |
COLUMN_NAME, "-", |
| 177 |
ORDINAL_POSITION, "-", |
| 178 |
ifnull(COLUMN_DEFAULT, "no_default"), "-", |
| 179 |
IS_NULLABLE, "-", |
| 180 |
COLUMN_TYPE, "-", |
| 181 |
ifnull(CHARACTER_SET_NAME, "no_charset"), "-", |
| 182 |
ifnull(COLLATION_NAME, "no_collation"), "-", |
| 183 |
ifnull(COLUMN_COMMENT, "no_comment")) |
| 184 |
from INFORMATION_SCHEMA.COLUMNS |
| 185 |
where TABLE_SCHEMA = "performance_schema" |
| 186 |
order by TABLE_NAME, ORDINAL_POSITION; |
| 187 |
|
| 188 |
insert into test.pfs_check_table(t) |
| 189 |
select concat(TABLE_CATALOG, "-", |
| 190 |
TABLE_SCHEMA, "-", |
| 191 |
TABLE_NAME, "-", |
| 192 |
NON_UNIQUE, "-", |
| 193 |
INDEX_SCHEMA, "-", |
| 194 |
INDEX_NAME, "-", |
| 195 |
SEQ_IN_INDEX, "-", |
| 196 |
COLUMN_NAME, "-", |
| 197 |
NULLABLE, "-", |
| 198 |
INDEX_TYPE, "-", |
| 199 |
COMMENT) |
| 200 |
from INFORMATION_SCHEMA.STATISTICS |
| 201 |
where TABLE_SCHEMA = "performance_schema" |
| 202 |
order by TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX; |
| 203 |
|
| 204 |
/* |
| 205 |
There is a lot of data to crunch, |
| 206 |
doing an intermediate checksum by row. |
| 207 |
*/ |
| 208 |
|
| 209 |
update test.pfs_check_table |
| 210 |
set row_hash = sha2(t, 256); |
| 211 |
|
| 212 |
/* |
| 213 |
And then doing a checksum of all rows. |
| 214 |
*/ |
| 215 |
|
| 216 |
select group_concat(row_hash order by id) |
| 217 |
from test.pfs_check_table |
| 218 |
into whole_schema; |
| 219 |
|
| 220 |
select length(whole_schema) into max_length; |
| 221 |
|
| 222 |
if (max_length = @@group_concat_max_len) |
| 223 |
then |
| 224 |
signal sqlstate "50000" set message_text = "Failed to check, whole_schema string truncated"; |
| 225 |
end if; |
| 226 |
|
| 227 |
select SHA2(whole_schema, 256) into found_signature; |
| 228 |
|
| 229 |
select version into found_version from test.pfs_published_schema |
| 230 |
where signature = found_signature; |
| 231 |
|
| 232 |
if found_version is null |
| 233 |
then |
| 234 |
begin |
| 235 |
/* Limitation on SIGNAL */ |
| 236 |
declare full_msg text; |
| 237 |
|
| 238 |
/* |
| 239 |
Booby trap: some people do not analyze test failures and |
| 240 |
blindly mtr --record a test to make it 'pass'. |
| 241 |
Make sure, by using now(), that this will not happen. |
| 242 |
See the comments in the MAINTAINER section of this test. |
| 243 |
*/ |
| 244 |
select concat("Unknown signature ", |
| 245 |
found_signature, |
| 246 |
", fix PFS_DD_VERSION now (", |
| 247 |
now(), |
| 248 |
")") into full_msg; |
| 249 |
|
| 250 |
signal sqlstate "50000" set message_text = full_msg; |
| 251 |
end; |
| 252 |
end if; |
| 253 |
|
| 254 |
select concat("The tables in the performance_schema were last changed in ", |
| 255 |
found_version) as "CHECK STATUS"; |
| 256 |
|
| 257 |
end |
| 258 |
$$ |
| 259 |
|
| 260 |
delimiter ;$$ |
| 261 |
|
| 262 |
--echo "Checking the performance schema database structure ..." |
| 263 |
|
| 264 |
call test.pfs_check_proc(); |
| 265 |
|
| 266 |
# Debug |
| 267 |
# select count(*) from test.pfs_check_table; |
| 268 |
|
| 269 |
SET group_concat_max_len = @old_group_concat_max_len; |
| 270 |
|
| 271 |
drop table test.pfs_published_schema; |
| 272 |
drop table test.pfs_check_table; |
| 273 |
drop procedure test.pfs_check_proc; |
| 274 |
|
| 275 |
--enable_query_log |