|
| 1 | +# |
| 2 | +# Performance Schema |
| 3 | +# |
| 4 | +# Verify that the Performance Schema correctly identifies normal and temporary |
| 5 | +# tables with non-standard names. |
| 6 | + |
| 7 | +# The server uses the table name prefix "#sql" for temporary and intermediate |
| 8 | +# tables, however user-defined tables having the "#sql" prefix are also permitted. |
| 9 | +# Independent of the table name, temporary or intermediate tables always have the |
| 10 | +# "#sql" prefix in the filename. (For non-temporary tables starting with "#", |
| 11 | +# the "#" is encoded to @0023 in the filename.) |
| 12 | +# |
| 13 | +# Given the ambiguity with temporary table names, the Performance Schema identifies |
| 14 | +# temporary tables tables either by the table category or by the filename. |
| 15 | +# |
| 16 | +--source include/have_perfschema.inc |
| 17 | +--source include/have_innodb.inc |
| 18 | +--source include/not_embedded.inc |
| 19 | + |
| 20 | +--echo |
| 21 | +--echo # |
| 22 | +--echo # TEST 1: Normal tables prefixed with "#sql" and "sql". |
| 23 | +--echo # |
| 24 | +USE test; |
| 25 | +CREATE TABLE `#sql_1` (a int, b text); |
| 26 | +# INSERT forces path through get_table_share() |
| 27 | +INSERT INTO `#sql_1` VALUES(1,'one'); |
| 28 | +--echo |
| 29 | +CREATE TABLE `sql_1` (a int, b text); |
| 30 | +INSERT INTO `sql_1` VALUES(1,'one'); |
| 31 | +--echo |
| 32 | +--echo # Verify that the tables are treated as normal tables . |
| 33 | +--echo |
| 34 | +SELECT object_type, object_schema, object_name |
| 35 | +FROM performance_schema.objects_summary_global_by_type |
| 36 | +WHERE object_schema="test"; |
| 37 | +--echo |
| 38 | +--echo # Drop the tables, verify that the table objects are removed. |
| 39 | +--echo |
| 40 | +DROP TABLE `#sql_1`; |
| 41 | +DROP TABLE `sql_1`; |
| 42 | +--echo |
| 43 | +SELECT object_type, object_schema, object_name |
| 44 | +FROM performance_schema.objects_summary_global_by_type |
| 45 | +WHERE object_schema="test"; |
| 46 | + |
| 47 | +--echo |
| 48 | +--echo # |
| 49 | +--echo # TEST 2: Temporary tables, no special prefix. |
| 50 | +--echo # |
| 51 | +CREATE TEMPORARY TABLE sql_temp2_myisam (a int, b text) ENGINE=MYISAM; |
| 52 | +INSERT INTO sql_temp2_myisam VALUES(1,'one'); |
| 53 | +--echo |
| 54 | +CREATE TEMPORARY TABLE sql_temp2_innodb (a int, b text) ENGINE=INNODB; |
| 55 | +INSERT INTO sql_temp2_innodb VALUES(1,'one'); |
| 56 | +--echo |
| 57 | +--echo # Confirm that the temporary tables are ignored. |
| 58 | +--echo |
| 59 | +SELECT object_type, object_schema, object_name |
| 60 | +FROM performance_schema.objects_summary_global_by_type |
| 61 | +WHERE object_schema="test"; |
| 62 | +--echo |
| 63 | +--echo # Drop the tables, verify that the table objects are not created. |
| 64 | +--echo |
| 65 | +DROP TABLE sql_temp2_myisam; |
| 66 | +DROP TABLE sql_temp2_innodb; |
| 67 | +--echo |
| 68 | +SELECT object_type, object_schema, object_name |
| 69 | +FROM performance_schema.objects_summary_global_by_type |
| 70 | +WHERE object_schema="test"; |
| 71 | + |
| 72 | +--echo |
| 73 | +--echo # |
| 74 | +--echo # TEST 3: Temporary tables with the "#sql" prefix. |
| 75 | +--echo # |
| 76 | +CREATE TEMPORARY TABLE `#sql_temp3_myisam` (a int, b text) ENGINE=MYISAM; |
| 77 | +CHECK TABLE `#sql_temp3_myisam`; |
| 78 | +INSERT INTO `#sql_temp3_myisam` VALUES(1,'one'); |
| 79 | +--echo |
| 80 | +CREATE TEMPORARY TABLE `#sql_temp3_innodb` (a int, b text) ENGINE=INNODB; |
| 81 | +CHECK TABLE `#sql_temp3_innodb`; |
| 82 | +INSERT INTO `#sql_temp3_innodb` VALUES(1,'one'); |
| 83 | +--echo |
| 84 | +--echo # Confirm that the temporary tables are ignored. |
| 85 | +--echo |
| 86 | +SELECT object_type, object_schema, object_name |
| 87 | +FROM performance_schema.objects_summary_global_by_type |
| 88 | +WHERE object_schema="test"; |
| 89 | +--echo |
| 90 | +--echo # Drop the temporary tables. |
| 91 | +--echo |
| 92 | +DROP TABLE `#sql_temp3_myisam`; |
| 93 | +DROP TABLE `#sql_temp3_innodb`; |
| 94 | +--echo |
| 95 | +--echo # Confirm that the temporary tables are still ignored. |
| 96 | +--echo |
| 97 | +SELECT object_type, object_schema, object_name |
| 98 | +FROM performance_schema.objects_summary_global_by_type |
| 99 | +WHERE object_schema="test"; |
| 100 | + |
| 101 | +--echo |
| 102 | +--echo # |
| 103 | +--echo # TEST 4: Special case: MyISAM temporary tables are recreated as non-temporary |
| 104 | +--echo # when they are truncated. |
| 105 | +--echo # |
| 106 | +CREATE TEMPORARY TABLE `sql_temp4_myisam` (a int, b text) ENGINE=MYISAM; |
| 107 | +INSERT INTO `sql_temp4_myisam` VALUES(1,'one'); |
| 108 | +--echo |
| 109 | +CREATE TEMPORARY TABLE `#sql_temp4_myisam` (a int, b text) ENGINE=MYISAM; |
| 110 | +INSERT INTO `#sql_temp4_myisam` VALUES(1,'one'); |
| 111 | +--echo |
| 112 | +--echo # Confirm that the MyISAM temporary tables are ignored. |
| 113 | +--echo |
| 114 | +SELECT object_type, object_schema, object_name |
| 115 | +FROM performance_schema.objects_summary_global_by_type |
| 116 | +WHERE object_schema="test"; |
| 117 | +--echo |
| 118 | +--echo # Truncate the MyISAM temporary tables, forcing them to be recreated as non-temporary. |
| 119 | +--echo |
| 120 | +TRUNCATE TABLE `sql_temp4_myisam`; |
| 121 | +TRUNCATE TABLE `#sql_temp4_myisam`; |
| 122 | +--echo |
| 123 | +--echo # Confirm that the recreated MyISAM tables are still regarded as temporary and ignored. |
| 124 | +--echo |
| 125 | +SELECT object_type, object_schema, object_name |
| 126 | +FROM performance_schema.objects_summary_global_by_type |
| 127 | +WHERE object_schema="test"; |
| 128 | +--echo |
| 129 | +--echo # Drop the recreated MyISAM tables; |
| 130 | +--echo |
| 131 | +DROP TABLE `sql_temp4_myisam`; |
| 132 | +DROP TABLE `#sql_temp4_myisam`; |
| 133 | +--echo |
| 134 | +--echo # Confirm that the recreated temporary tables are still ignored. |
| 135 | +--echo |
| 136 | +SELECT object_type, object_schema, object_name |
| 137 | +FROM performance_schema.objects_summary_global_by_type |
| 138 | +WHERE object_schema="test"; |
| 139 | + |
| 140 | +--echo |
| 141 | +--echo # |
| 142 | +--echo # TEST 5: Generate temporary tables with ALTER MyISAM table. |
| 143 | +--echo # |
| 144 | +USE test; |
| 145 | +CREATE TABLE t1 (a int) ENGINE=MYISAM; |
| 146 | +INSERT INTO t1 VALUES (1), (2), (3); |
| 147 | +# Force a path throug mysql_alter_table() and ha_create_table(). |
| 148 | +ALTER TABLE t1 ADD COLUMN (b int); |
| 149 | +--echo |
| 150 | +--echo # Confirm that the recreated temporary tables are still ignored. |
| 151 | +--echo |
| 152 | +SELECT object_type, object_schema, object_name |
| 153 | +FROM performance_schema.objects_summary_global_by_type |
| 154 | +WHERE object_schema="test"; |
| 155 | +--echo |
| 156 | +--echo # Drop the MyISAM table |
| 157 | +--echo |
| 158 | +DROP TABLE t1; |
| 159 | + |
| 160 | +--echo |
| 161 | +--echo # Confirm that no tables remain; |
| 162 | +--echo |
| 163 | +SELECT object_type, object_schema, object_name |
| 164 | +FROM performance_schema.objects_summary_global_by_type |
| 165 | +WHERE object_schema="test"; |
0 commit comments