You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
6.3 KiB

18 years ago
18 years ago
18 years ago
  1. # Embedded server doesn't support external clients
  2. --source include/not_embedded.inc
  3. # check that CSV engine was compiled in, as the result of the test
  4. # depends on the presence of the log tables (which are CSV-based).
  5. --source include/have_csv.inc
  6. #
  7. # Clean up after previous tests
  8. #
  9. --disable_warnings
  10. DROP TABLE IF EXISTS t1, `t``1`, `t 1`;
  11. drop view if exists v1;
  12. drop database if exists client_test_db;
  13. # Repair any tables in mysql, sometimes the slow_log is marked as crashed
  14. # after server has been killed
  15. --exec $MYSQL_CHECK --repair --databases mysql > /dev/null 2>&1
  16. --enable_warnings
  17. #
  18. # Bug #13783 mysqlcheck tries to optimize and analyze information_schema
  19. #
  20. --replace_result 'Table is already up to date' OK
  21. --exec $MYSQL_CHECK --all-databases --analyze --optimize
  22. --replace_result 'Table is already up to date' OK
  23. --exec $MYSQL_CHECK --analyze --optimize --databases test information_schema mysql
  24. --exec $MYSQL_CHECK --analyze --optimize information_schema schemata
  25. #
  26. # Bug #16502: mysqlcheck tries to check views
  27. #
  28. create table t1 (a int);
  29. create view v1 as select * from t1;
  30. --replace_result 'Table is already up to date' OK
  31. --exec $MYSQL_CHECK --analyze --optimize --databases test
  32. --replace_result 'Table is already up to date' OK
  33. --exec $MYSQL_CHECK --all-in-1 --analyze --optimize --databases test
  34. drop view v1;
  35. drop table t1;
  36. #
  37. # Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
  38. #
  39. create table `t``1`(a int);
  40. create table `t 1`(a int);
  41. --replace_result 'Table is already up to date' OK
  42. --exec $MYSQL_CHECK --databases test
  43. drop table `t``1`, `t 1`;
  44. #
  45. # Bug#25347: mysqlcheck -A -r doesn't repair table marked as crashed
  46. #
  47. create database d_bug25347;
  48. use d_bug25347;
  49. create table t_bug25347 (a int);
  50. create view v_bug25347 as select * from t_bug25347;
  51. insert into t_bug25347 values (1),(2),(3);
  52. flush tables;
  53. let $MYSQLD_DATADIR= `select @@datadir`;
  54. --echo removing and creating
  55. --remove_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI
  56. --write_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI
  57. EOF
  58. --exec $MYSQL_CHECK --repair --databases d_bug25347
  59. --error 130
  60. insert into t_bug25347 values (4),(5),(6);
  61. --exec $MYSQL_CHECK --repair --use-frm --databases d_bug25347
  62. insert into t_bug25347 values (7),(8),(9);
  63. select * from t_bug25347;
  64. select * from v_bug25347;
  65. drop view v_bug25347;
  66. drop table t_bug25347;
  67. drop database d_bug25347;
  68. use test;
  69. #
  70. # Bug#39541 CHECK TABLE on information_schema myisam tables produces error
  71. #
  72. create view v1 as select * from information_schema.routines;
  73. check table v1, information_schema.routines;
  74. drop view v1;
  75. #
  76. # Bug#37527: mysqlcheck fails to report entire database
  77. # when frm file corruption
  78. #
  79. CREATE TABLE t1(a INT);
  80. CREATE TABLE t2(a INT);
  81. # backup then null t1.frm
  82. --copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t1.frm.bak
  83. --remove_file $MYSQLD_DATADIR/test/t1.frm
  84. --write_file $MYSQLD_DATADIR/test/t1.frm
  85. EOF
  86. --exec $MYSQL_CHECK test
  87. # restore t1.frm
  88. --remove_file $MYSQLD_DATADIR/test/t1.frm
  89. --copy_file $MYSQLD_DATADIR/test/t1.frm.bak $MYSQLD_DATADIR/test/t1.frm
  90. --remove_file $MYSQLD_DATADIR/test/t1.frm.bak
  91. DROP TABLE t1, t2;
  92. --echo End of 5.0 tests
  93. #
  94. # Bug #30679: 5.1 name encoding not performed for views during upgrade
  95. #
  96. create table t1(a int);
  97. create view v1 as select * from t1;
  98. show tables;
  99. let $MYSQLD_DATADIR= `select @@datadir`;
  100. --copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm
  101. show tables;
  102. --exec $MYSQL_CHECK --check-upgrade --fix-table-names --databases test
  103. show tables;
  104. drop view v1, `v-1`;
  105. drop table t1;
  106. #
  107. # Bug #33094: Error in upgrading from 5.0 to 5.1 when table contains triggers
  108. # Bug #41385: Crash when attempting to repair a #mysql50# upgraded table with
  109. # triggers
  110. #
  111. SET NAMES utf8;
  112. CREATE TABLE `#mysql50#@` (a INT);
  113. SHOW TABLES;
  114. SET NAMES DEFAULT;
  115. --echo mysqlcheck --fix-table-names --databases test
  116. --exec $MYSQL_CHECK --fix-table-names --databases test
  117. SET NAMES utf8;
  118. SHOW TABLES;
  119. DROP TABLE `@`;
  120. CREATE TABLE `я` (a INT);
  121. SET NAMES DEFAULT;
  122. --echo mysqlcheck --default-character-set="latin1" --databases test
  123. # Error returned depends on platform, replace it with "Table doesn't exist"
  124. call mtr.add_suppression("Can't find file: '..test.@003f.frm'");
  125. --replace_result "Can't find file: './test/@003f.frm' (errno: 22)" "Table doesn't exist" "Table 'test.?' doesn't exist" "Table doesn't exist"
  126. --exec $MYSQL_CHECK --default-character-set="latin1" --databases test
  127. --echo mysqlcheck --default-character-set="utf8" --databases test
  128. --exec $MYSQL_CHECK --default-character-set="utf8" --databases test
  129. SET NAMES utf8;
  130. DROP TABLE `я`;
  131. SET NAMES DEFAULT;
  132. CREATE DATABASE `#mysql50#a@b`;
  133. USE `#mysql50#a@b`;
  134. CREATE TABLE `#mysql50#c@d` (a INT);
  135. CREATE TABLE t1 (a INT);
  136. # Create 5.0 like triggers
  137. let $MYSQLTEST_VARDIR= `select @@datadir`;
  138. --write_file $MYSQLTEST_VARDIR/a@b/c@d.TRG
  139. TYPE=TRIGGERS
  140. triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON `c@d` FOR EACH ROW SET NEW.a = 10 * NEW.a'
  141. sql_modes=0
  142. definers='root@localhost'
  143. EOF
  144. --write_file $MYSQLTEST_VARDIR/a@b/tr1.TRN
  145. TYPE=TRIGGERNAME
  146. trigger_table=c@d
  147. EOF
  148. --write_file $MYSQLTEST_VARDIR/a@b/t1.TRG
  149. TYPE=TRIGGERS
  150. triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr2 BEFORE INSERT ON `a@b`.t1 FOR EACH ROW SET NEW.a = 100 * NEW.a'
  151. sql_modes=0
  152. definers='root@localhost'
  153. EOF
  154. --write_file $MYSQLTEST_VARDIR/a@b/tr2.TRN
  155. TYPE=TRIGGERNAME
  156. trigger_table=t1
  157. EOF
  158. SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
  159. WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name;
  160. --echo mysqlcheck --fix-db-names --fix-table-names --all-databases
  161. --exec $MYSQL_CHECK --fix-db-names --fix-table-names --all-databases
  162. USE `a@b`;
  163. SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
  164. WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name;
  165. INSERT INTO `c@d` VALUES (2), (1);
  166. SELECT * FROM `c@d`;
  167. INSERT INTO t1 VALUES (3), (5);
  168. SELECT * FROM t1;
  169. DROP DATABASE `a@b`;
  170. USE test;
  171. --echo #
  172. --echo # Bug #31821: --all-in-1 and --fix-table-names don't work together
  173. --echo #
  174. --disable_warnings
  175. drop table if exists `#mysql50#t1-1`;
  176. --enable_warnings
  177. create table `#mysql50#t1-1` (a int);
  178. --exec $MYSQL_CHECK --all-in-1 --fix-table-names --databases test
  179. show tables like 't1-1';
  180. drop table `t1-1`;
  181. create table `#mysql50#t1-1` (a int);
  182. --exec $MYSQL_CHECK --all-in-1 --fix-table-names test "#mysql50#t1-1"
  183. show tables like 't1-1';
  184. drop table `t1-1`;
  185. --echo End of 5.1 tests