|
| 1 | + |
| 2 | +--source include/have_aria.inc |
| 3 | + |
| 4 | +--disable_query_log |
| 5 | + |
| 6 | + |
| 7 | +DELIMITER //; |
| 8 | +CREATE PROCEDURE populate_data(IN t_name VARCHAR(64), IN num_rows INT) |
| 9 | +BEGIN |
| 10 | + DECLARE i INT DEFAULT 1; |
| 11 | + SET @query = CONCAT('INSERT INTO ', t_name, ' (id, str_val, blob_val) VALUES (?, ?, ?)'); |
| 12 | + PREPARE stmt FROM @query; |
| 13 | + |
| 14 | + WHILE i <= num_rows DO |
| 15 | + SET @str = CONCAT('_row_', i); |
| 16 | + # Generate a predictable but repeating blob based on the row index |
| 17 | + SET @blb = REPEAT(CHAR(97 + (i % 26)), 1500); |
| 18 | + EXECUTE stmt USING i, @str, @blb; |
| 19 | + SET i = i + 1; |
| 20 | + END WHILE; |
| 21 | + |
| 22 | + DEALLOCATE PREPARE stmt; |
| 23 | +END// |
| 24 | +DELIMITER ;// |
| 25 | + |
| 26 | +# Create this many tables transactional and non-transactional each |
| 27 | +let $tab_num= 200; |
| 28 | +let $num_rows= 5; |
| 29 | + |
| 30 | +let $i = 1; |
| 31 | +while ($i <= $tab_num) { |
| 32 | + |
| 33 | + let $tr=0; |
| 34 | + while ($tr <= 1) { |
| 35 | + |
| 36 | + let $suff= _$i; |
| 37 | + let $table_name= ta_tr$tr$suff; |
| 38 | + |
| 39 | + eval CREATE TABLE $table_name ( |
| 40 | + id INT PRIMARY KEY, |
| 41 | + str_val VARCHAR(255), |
| 42 | + blob_val BLOB, |
| 43 | + INDEX idx_str (str_val) |
| 44 | + ) ENGINE=Aria TRANSACTIONAL=$tr; |
| 45 | + |
| 46 | + eval CALL populate_data('$table_name', $num_rows); |
| 47 | + |
| 48 | + inc $tr; |
| 49 | + } |
| 50 | + |
| 51 | + inc $i; |
| 52 | +} |
| 53 | + |
| 54 | +--enable_query_log |
| 55 | + |
| 56 | +# All tables have the same data, so we query only one for reference |
| 57 | + |
| 58 | +let $sum_id= `SELECT SUM(id) FROM ta_tr0_1`; |
| 59 | +let $str_len= `SELECT SUM(LENGTH(str_val)) FROM ta_tr0_1`; |
| 60 | +let $blob_len= `SELECT SUM(LENGTH(blob_val)) FROM ta_tr0_1`; |
| 61 | + |
| 62 | +echo $sum_id $str_len $blob_len; |
| 63 | + |
| 64 | +--let $target_directory=$MYSQLTEST_VARDIR/some_directory |
| 65 | + |
| 66 | +# Clean up after a previous failed test, in case we are retrying. |
| 67 | +--error 0,1 |
| 68 | +--rmdir $target_directory |
| 69 | + |
| 70 | +--echo Back up the database |
| 71 | +evalp BACKUP SERVER TO '$target_directory' 4 CONCURRENT; |
| 72 | + |
| 73 | +--echo Restore the database |
| 74 | +--let $restart_parameters=--datadir=$target_directory |
| 75 | +--source include/restart_mysqld.inc |
| 76 | + |
| 77 | +--echo Check contents after restore |
| 78 | + |
| 79 | +--disable_query_log |
| 80 | +CREATE TEMPORARY TABLE table_checks ( |
| 81 | + tbl_name VARCHAR(64), |
| 82 | + sum_id INT, |
| 83 | + str_len INT, |
| 84 | + blob_len INT, |
| 85 | + num_rows INT |
| 86 | +) ENGINE=MEMORY; |
| 87 | + |
| 88 | +let $i = 1; |
| 89 | +while ($i <= $tab_num) { |
| 90 | + let $tr=0; |
| 91 | + while ($tr <= 1) { |
| 92 | + |
| 93 | + let $suff= _$i; |
| 94 | + let $table_name= ta_tr$tr$suff; |
| 95 | + |
| 96 | + let $r_sum_id= `SELECT SUM(id) FROM $table_name`; |
| 97 | + let $r_str_len= `SELECT SUM(LENGTH(str_val)) FROM $table_name`; |
| 98 | + let $r_blob_len= `SELECT SUM(LENGTH(blob_val)) FROM $table_name`; |
| 99 | + let $r_num_rows= `SELECT COUNT(*) FROM $table_name`; |
| 100 | + |
| 101 | + eval INSERT INTO table_checks VALUES ('$table_name', $r_sum_id, $r_str_len, $r_blob_len, $r_num_rows); |
| 102 | + |
| 103 | + inc $tr; |
| 104 | + } |
| 105 | + inc $i; |
| 106 | +} |
| 107 | + |
| 108 | +--enable_query_log |
| 109 | + |
| 110 | +SELECT COUNT(*) FROM table_checks; |
| 111 | + |
| 112 | +# We expect results in the table to always match the results captured before the BACKUP |
| 113 | +# Returned rowsets should be empty |
| 114 | +eval SELECT * FROM table_checks WHERE sum_id <> $sum_id; |
| 115 | +eval SELECT * FROM table_checks WHERE str_len <> $str_len; |
| 116 | +eval SELECT * FROM table_checks WHERE blob_len <> $blob_len; |
| 117 | +eval SELECT * FROM table_checks WHERE num_rows <> $num_rows; |
| 118 | + |
| 119 | +--echo Restart database in original data directory |
| 120 | +--let $restart_parameters= |
| 121 | +--source include/restart_mysqld.inc |
| 122 | + |
| 123 | +--echo Clean up |
| 124 | + |
| 125 | +--disable_query_log |
| 126 | + |
| 127 | +let $i = 1; |
| 128 | +while ($i <= $tab_num) { |
| 129 | + let $tr=0; |
| 130 | + while ($tr <= 1) { |
| 131 | + let $suff= _$i; |
| 132 | + let $table_name= ta_tr$tr$suff; |
| 133 | + eval DROP TABLE $table_name; |
| 134 | + inc $tr; |
| 135 | + } |
| 136 | + inc $i; |
| 137 | +} |
| 138 | + |
| 139 | +DROP PROCEDURE populate_data; |
| 140 | + |
| 141 | +--enable_query_log |
| 142 | + |
| 143 | +--rmdir $target_directory |
0 commit comments