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.

550 lines
18 KiB

Applying InnoDB Plugin 1.0.6 snapshot, part 7 Fixes several test cases. applied revisions: r6181, r6182, r6183, r6184 r6183 - changes are made only to tests in innodb suite which is only innodb-consistent-master.opt Detailed revision comments: r6181 | vasil | 2009-11-17 12:21:41 +0200 (Tue, 17 Nov 2009) | 33 lines branches/zip: At the end of innodb-index.test: restore the environment as it was before the test was started to silence this warning: MTR's internal check of the test case 'main.innodb-index' failed. This means that the test case does not preserve the state that existed before the test case was executed. Most likely the test case did not do a proper clean-up. This is the diff of the states of the servers before and after the test case was executed: mysqltest: Logging to '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.log'. mysqltest: Results saved in '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result'. mysqltest: Connecting to server localhost:13000 (socket /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock) as 'root', connection 'default', attempt 0 ... mysqltest: ... Connected. mysqltest: Start processing test commands from './include/check-testcase.test' ... mysqltest: ... Done processing test commands. --- /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result 2009-11-17 13:10:40.000000000 +0300 +++ /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.reject 2009-11-17 13:10:54.000000000 +0300 @@ -84,7 +84,7 @@ INNODB_DOUBLEWRITE ON INNODB_FAST_SHUTDOWN 1 INNODB_FILE_FORMAT Antelope -INNODB_FILE_FORMAT_CHECK Antelope +INNODB_FILE_FORMAT_CHECK Barracuda INNODB_FILE_PER_TABLE OFF INNODB_FLUSH_LOG_AT_TRX_COMMIT 1 INNODB_FLUSH_METHOD mysqltest: Result content mismatch not ok r6182 | marko | 2009-11-17 13:49:15 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: Set svn:eol-style on mysql-test files. r6183 | marko | 2009-11-17 13:51:16 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: Prepend loose_ to plugin-only mysql-test options. r6184 | marko | 2009-11-17 13:52:01 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: innodb-index.test: Restore innodb_file_format_check.
16 years ago
Applying InnoDB Plugin 1.0.6 snapshot, part 7 Fixes several test cases. applied revisions: r6181, r6182, r6183, r6184 r6183 - changes are made only to tests in innodb suite which is only innodb-consistent-master.opt Detailed revision comments: r6181 | vasil | 2009-11-17 12:21:41 +0200 (Tue, 17 Nov 2009) | 33 lines branches/zip: At the end of innodb-index.test: restore the environment as it was before the test was started to silence this warning: MTR's internal check of the test case 'main.innodb-index' failed. This means that the test case does not preserve the state that existed before the test case was executed. Most likely the test case did not do a proper clean-up. This is the diff of the states of the servers before and after the test case was executed: mysqltest: Logging to '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.log'. mysqltest: Results saved in '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result'. mysqltest: Connecting to server localhost:13000 (socket /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock) as 'root', connection 'default', attempt 0 ... mysqltest: ... Connected. mysqltest: Start processing test commands from './include/check-testcase.test' ... mysqltest: ... Done processing test commands. --- /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result 2009-11-17 13:10:40.000000000 +0300 +++ /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.reject 2009-11-17 13:10:54.000000000 +0300 @@ -84,7 +84,7 @@ INNODB_DOUBLEWRITE ON INNODB_FAST_SHUTDOWN 1 INNODB_FILE_FORMAT Antelope -INNODB_FILE_FORMAT_CHECK Antelope +INNODB_FILE_FORMAT_CHECK Barracuda INNODB_FILE_PER_TABLE OFF INNODB_FLUSH_LOG_AT_TRX_COMMIT 1 INNODB_FLUSH_METHOD mysqltest: Result content mismatch not ok r6182 | marko | 2009-11-17 13:49:15 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: Set svn:eol-style on mysql-test files. r6183 | marko | 2009-11-17 13:51:16 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: Prepend loose_ to plugin-only mysql-test options. r6184 | marko | 2009-11-17 13:52:01 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: innodb-index.test: Restore innodb_file_format_check.
16 years ago
Applying InnoDB Plugin 1.0.6 snapshot, part 7 Fixes several test cases. applied revisions: r6181, r6182, r6183, r6184 r6183 - changes are made only to tests in innodb suite which is only innodb-consistent-master.opt Detailed revision comments: r6181 | vasil | 2009-11-17 12:21:41 +0200 (Tue, 17 Nov 2009) | 33 lines branches/zip: At the end of innodb-index.test: restore the environment as it was before the test was started to silence this warning: MTR's internal check of the test case 'main.innodb-index' failed. This means that the test case does not preserve the state that existed before the test case was executed. Most likely the test case did not do a proper clean-up. This is the diff of the states of the servers before and after the test case was executed: mysqltest: Logging to '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.log'. mysqltest: Results saved in '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result'. mysqltest: Connecting to server localhost:13000 (socket /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock) as 'root', connection 'default', attempt 0 ... mysqltest: ... Connected. mysqltest: Start processing test commands from './include/check-testcase.test' ... mysqltest: ... Done processing test commands. --- /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result 2009-11-17 13:10:40.000000000 +0300 +++ /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.reject 2009-11-17 13:10:54.000000000 +0300 @@ -84,7 +84,7 @@ INNODB_DOUBLEWRITE ON INNODB_FAST_SHUTDOWN 1 INNODB_FILE_FORMAT Antelope -INNODB_FILE_FORMAT_CHECK Antelope +INNODB_FILE_FORMAT_CHECK Barracuda INNODB_FILE_PER_TABLE OFF INNODB_FLUSH_LOG_AT_TRX_COMMIT 1 INNODB_FLUSH_METHOD mysqltest: Result content mismatch not ok r6182 | marko | 2009-11-17 13:49:15 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: Set svn:eol-style on mysql-test files. r6183 | marko | 2009-11-17 13:51:16 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: Prepend loose_ to plugin-only mysql-test options. r6184 | marko | 2009-11-17 13:52:01 +0200 (Tue, 17 Nov 2009) | 1 line branches/zip: innodb-index.test: Restore innodb_file_format_check.
16 years ago
  1. -- source include/have_innodb.inc
  2. let $MYSQLD_DATADIR= `select @@datadir`;
  3. let $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
  4. create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;
  5. insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak');
  6. commit;
  7. --error ER_DUP_KEYNAME
  8. alter table t1 add index b (b), add index b (b);
  9. --error ER_DUP_FIELDNAME
  10. alter table t1 add index (b,b);
  11. alter table t1 add index d2 (d);
  12. show create table t1;
  13. explain select * from t1 force index(d2) order by d;
  14. select * from t1 force index (d2) order by d;
  15. --error ER_DUP_ENTRY
  16. alter table t1 add unique index (b);
  17. show create table t1;
  18. alter table t1 add index (b);
  19. show create table t1;
  20. # Check how existing tables interfere with temporary tables.
  21. CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
  22. --error 156
  23. alter table t1 add unique index (c), add index (d);
  24. rename table `t1#1` to `t1#2`;
  25. --error 156
  26. alter table t1 add unique index (c), add index (d);
  27. drop table `t1#2`;
  28. alter table t1 add unique index (c), add index (d);
  29. show create table t1;
  30. explain select * from t1 force index(c) order by c;
  31. alter table t1 add primary key (a), drop index c;
  32. show create table t1;
  33. --error ER_MULTIPLE_PRI_KEY
  34. alter table t1 add primary key (c);
  35. --error ER_DUP_ENTRY
  36. alter table t1 drop primary key, add primary key (b);
  37. create unique index c on t1 (c);
  38. show create table t1;
  39. explain select * from t1 force index(c) order by c;
  40. select * from t1 force index(c) order by c;
  41. alter table t1 drop index b, add index (b);
  42. show create table t1;
  43. insert into t1 values(6,1,'ggg','ggg');
  44. select * from t1;
  45. select * from t1 force index(b) order by b;
  46. select * from t1 force index(c) order by c;
  47. select * from t1 force index(d) order by d;
  48. explain select * from t1 force index(b) order by b;
  49. explain select * from t1 force index(c) order by c;
  50. explain select * from t1 force index(d) order by d;
  51. show create table t1;
  52. drop table t1;
  53. create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
  54. insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe');
  55. commit;
  56. alter table t1 add index (c(2));
  57. show create table t1;
  58. alter table t1 add unique index (d(10));
  59. show create table t1;
  60. insert into t1 values(5,1,'ggg','ggg');
  61. select * from t1;
  62. select * from t1 force index(c) order by c;
  63. select * from t1 force index(d) order by d;
  64. explain select * from t1 order by b;
  65. explain select * from t1 force index(c) order by c;
  66. explain select * from t1 force index(d) order by d;
  67. show create table t1;
  68. alter table t1 drop index d;
  69. insert into t1 values(8,9,'fff','fff');
  70. select * from t1;
  71. select * from t1 force index(c) order by c;
  72. explain select * from t1 order by b;
  73. explain select * from t1 force index(c) order by c;
  74. explain select * from t1 order by d;
  75. show create table t1;
  76. drop table t1;
  77. create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
  78. insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
  79. commit;
  80. alter table t1 add unique index (b,c);
  81. insert into t1 values(8,9,'fff','fff');
  82. select * from t1;
  83. select * from t1 force index(b) order by b;
  84. explain select * from t1 force index(b) order by b;
  85. show create table t1;
  86. alter table t1 add index (b,c);
  87. insert into t1 values(11,11,'kkk','kkk');
  88. select * from t1;
  89. select * from t1 force index(b) order by b;
  90. explain select * from t1 force index(b) order by b;
  91. show create table t1;
  92. alter table t1 add unique index (c,d);
  93. insert into t1 values(13,13,'yyy','aaa');
  94. select * from t1;
  95. select * from t1 force index(b) order by b;
  96. select * from t1 force index(c) order by c;
  97. explain select * from t1 force index(b) order by b;
  98. explain select * from t1 force index(c) order by c;
  99. show create table t1;
  100. drop table t1;
  101. create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb;
  102. create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb;
  103. create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb;
  104. create table t2(a int not null, b int not null, c int not null, d int not null, e int,
  105. foreign key (b) references t1(b) on delete cascade,
  106. foreign key (c) references t3(c), foreign key (d) references t4(d))
  107. engine = innodb;
  108. --error ER_DROP_INDEX_FK
  109. alter table t1 drop index b;
  110. --error ER_DROP_INDEX_FK
  111. alter table t3 drop index c;
  112. --error ER_DROP_INDEX_FK
  113. alter table t4 drop index d;
  114. --error ER_DROP_INDEX_FK
  115. alter table t2 drop index b;
  116. --error ER_DROP_INDEX_FK
  117. alter table t2 drop index b, drop index c, drop index d;
  118. # Apparently, the following makes mysql_alter_table() drop index d.
  119. create unique index dc on t2 (d,c);
  120. create index dc on t1 (b,c);
  121. # This should preserve the foreign key constraints.
  122. alter table t2 add primary key (a);
  123. insert into t1 values (1,1,1);
  124. insert into t3 values (1,1,1);
  125. insert into t4 values (1,1,1);
  126. insert into t2 values (1,1,1,1,1);
  127. commit;
  128. alter table t4 add constraint dc foreign key (a) references t1(a);
  129. show create table t4;
  130. --replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
  131. # a foreign key 'test/dc' already exists
  132. --error ER_CANT_CREATE_TABLE
  133. alter table t3 add constraint dc foreign key (a) references t1(a);
  134. show create table t3;
  135. # this should be fixed by MySQL (see Bug #51451)
  136. --error ER_WRONG_NAME_FOR_INDEX
  137. alter table t2 drop index b, add index (b);
  138. show create table t2;
  139. --error ER_ROW_IS_REFERENCED_2
  140. delete from t1;
  141. --error ER_CANT_DROP_FIELD_OR_KEY
  142. drop index dc on t4;
  143. # there is no foreign key dc on t3
  144. --replace_regex /'[^']*test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/
  145. # Embedded server doesn't chdir to data directory
  146. --replace_result $MYSQLD_DATADIR ./ master-data/ ''
  147. --error ER_ERROR_ON_RENAME
  148. alter table t3 drop foreign key dc;
  149. alter table t4 drop foreign key dc;
  150. select * from t2;
  151. delete from t1;
  152. select * from t2;
  153. drop table t2,t4,t3,t1;
  154. -- let charset = utf8
  155. -- source suite/innodb/include/innodb-index.inc
  156. create table t1(a int not null, b int) engine = innodb;
  157. insert into t1 values (1,1),(1,1),(1,1),(1,1);
  158. --error ER_DUP_ENTRY
  159. alter table t1 add unique index (a);
  160. --error ER_DUP_ENTRY
  161. alter table t1 add unique index (b);
  162. --error ER_DUP_ENTRY
  163. alter table t1 add unique index (a), add unique index(b);
  164. show create table t1;
  165. drop table t1;
  166. create table t1(a int not null, c int not null,b int, primary key(a), unique key(c), key(b)) engine = innodb;
  167. alter table t1 drop index c, drop index b;
  168. show create table t1;
  169. drop table t1;
  170. create table t1(a int not null, b int, primary key(a)) engine = innodb;
  171. alter table t1 add index (b);
  172. show create table t1;
  173. drop table t1;
  174. create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
  175. insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ac','ac'),(4,4,'afe','afe'),(5,4,'affe','affe');
  176. --error ER_DUP_ENTRY
  177. alter table t1 add unique index (b), add unique index (c), add unique index (d);
  178. --error ER_DUP_ENTRY
  179. alter table t1 add unique index (c), add unique index (b), add index (d);
  180. show create table t1;
  181. drop table t1;
  182. create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb;
  183. insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1);
  184. alter table t1 add unique index (b);
  185. insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17);
  186. show create table t1;
  187. check table t1;
  188. explain select * from t1 force index(c) order by c;
  189. explain select * from t1 order by a;
  190. explain select * from t1 force index(b) order by b;
  191. select * from t1 order by a;
  192. select * from t1 force index(b) order by b;
  193. select * from t1 force index(c) order by c;
  194. drop table t1;
  195. create table t1(a int not null, b int not null) engine=innodb;
  196. insert into t1 values (1,1);
  197. alter table t1 add primary key(b);
  198. insert into t1 values (2,2);
  199. show create table t1;
  200. check table t1;
  201. select * from t1;
  202. explain select * from t1;
  203. explain select * from t1 order by a;
  204. explain select * from t1 order by b;
  205. checksum table t1;
  206. drop table t1;
  207. create table t1(a int not null) engine=innodb;
  208. insert into t1 values (1);
  209. alter table t1 add primary key(a);
  210. insert into t1 values (2);
  211. show create table t1;
  212. check table t1;
  213. commit;
  214. select * from t1;
  215. explain select * from t1;
  216. explain select * from t1 order by a;
  217. drop table t1;
  218. create table t2(d varchar(17) primary key) engine=innodb default charset=utf8;
  219. create table t3(a int primary key) engine=innodb;
  220. insert into t3 values(22),(44),(33),(55),(66);
  221. insert into t2 values ('jejdkrun87'),('adfd72nh9k'),
  222. ('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik');
  223. create table t1(a int, b blob, c text, d text not null)
  224. engine=innodb default charset = utf8;
  225. # r2667 The following test is disabled because MySQL behavior changed.
  226. # r2667 The test was added with this comment:
  227. # r2667
  228. # r2667 ------------------------------------------------------------------------
  229. # r2667 r1699 | marko | 2007-08-10 19:53:19 +0300 (Fri, 10 Aug 2007) | 5 lines
  230. # r2667
  231. # r2667 branches/zip: Add changes that accidentally omitted from r1698:
  232. # r2667
  233. # r2667 innodb-index.test, innodb-index.result: Add a test for creating
  234. # r2667 a PRIMARY KEY on a column that contains a NULL value.
  235. # r2667 ------------------------------------------------------------------------
  236. # r2667
  237. # r2667 but in BZR-r2667:
  238. # r2667 http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/revision/davi%40mysql.com-20080617141221-8yre8ys9j4uw3xx5?start_revid=joerg%40mysql.com-20080630105418-7qoe5ehomgrcdb89
  239. # r2667 MySQL changed the behavior to do full table copy when creating PRIMARY INDEX
  240. # r2667 on a non-NULL column instead of calling ::add_index() which would fail (and
  241. # r2667 this is what we were testing here). Before r2667 the code execution path was
  242. # r2667 like this (when adding PRIMARY INDEX on a non-NULL column with ALTER TABLE):
  243. # r2667
  244. # r2667 mysql_alter_table()
  245. # r2667 compare_tables() // would return ALTER_TABLE_INDEX_CHANGED
  246. # r2667 ::add_index() // would fail with "primary index cannot contain NULL"
  247. # r2667
  248. # r2667 after r2667 the code execution path is the following:
  249. # r2667
  250. # r2667 mysql_alter_table()
  251. # r2667 compare_tables() // returns ALTER_TABLE_DATA_CHANGED
  252. # r2667 full copy is done, without calling ::add_index()
  253. # r2667
  254. # r2667 To enable, remove "# r2667: " below.
  255. # r2667
  256. # r2667: insert into t1 values (null,null,null,'null');
  257. insert into t1
  258. select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3;
  259. drop table t2, t3;
  260. select count(*) from t1 where a=44;
  261. select a,
  262. length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
  263. # r2667: --error ER_PRIMARY_CANT_HAVE_NULL
  264. # r2667: alter table t1 add primary key (a), add key (b(20));
  265. # r2667: delete from t1 where d='null';
  266. --error ER_DUP_ENTRY
  267. alter table t1 add primary key (a), add key (b(20));
  268. delete from t1 where a%2;
  269. check table t1;
  270. alter table t1 add primary key (a,b(255),c(255)), add key (b(767));
  271. select count(*) from t1 where a=44;
  272. select a,
  273. length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
  274. show create table t1;
  275. check table t1;
  276. explain select * from t1 where b like 'adfd%';
  277. #
  278. # Test locking
  279. #
  280. create table t2(a int, b varchar(255), primary key(a,b)) engine=innodb;
  281. insert into t2 select a,left(b,255) from t1;
  282. drop table t1;
  283. rename table t2 to t1;
  284. connect (a,localhost,root,,);
  285. connect (b,localhost,root,,);
  286. connection a;
  287. set innodb_lock_wait_timeout=1;
  288. begin;
  289. # Obtain an IX lock on the table
  290. select a from t1 limit 1 for update;
  291. connection b;
  292. set innodb_lock_wait_timeout=1;
  293. # This would require an S lock on the table, conflicting with the IX lock.
  294. --error ER_LOCK_WAIT_TIMEOUT
  295. create index t1ba on t1 (b,a);
  296. connection a;
  297. commit;
  298. begin;
  299. # Obtain an IS lock on the table
  300. select a from t1 limit 1 lock in share mode;
  301. connection b;
  302. # This will require an S lock on the table. No conflict with the IS lock.
  303. create index t1ba on t1 (b,a);
  304. # This would require an X lock on the table, conflicting with the IS lock.
  305. --error ER_LOCK_WAIT_TIMEOUT
  306. drop index t1ba on t1;
  307. connection a;
  308. commit;
  309. explain select a from t1 order by b;
  310. --send
  311. select a,sleep(2+a/100) from t1 order by b limit 3;
  312. # The following DROP INDEX will succeed, altough the SELECT above has
  313. # opened a read view. However, during the execution of the SELECT,
  314. # MySQL should hold a table lock that should block the execution
  315. # of the DROP INDEX below.
  316. connection b;
  317. select sleep(1);
  318. drop index t1ba on t1;
  319. # After the index was dropped, subsequent SELECTs will use the same
  320. # read view, but they should not be accessing the dropped index any more.
  321. connection a;
  322. reap;
  323. explain select a from t1 order by b;
  324. select a from t1 order by b limit 3;
  325. commit;
  326. connection default;
  327. disconnect a;
  328. disconnect b;
  329. drop table t1;
  330. let $per_table=`select @@innodb_file_per_table`;
  331. let $format=`select @@innodb_file_format`;
  332. set global innodb_file_per_table=on;
  333. set global innodb_file_format='Barracuda';
  334. # Test creating a table that could lead to undo log overflow.
  335. # In the undo log, we write a 768-byte prefix (REC_MAX_INDEX_COL_LEN)
  336. # of each externally stored column that appears as a column prefix in an index.
  337. # For this test case, it would suffice to write 1 byte, though.
  338. create table t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob,
  339. i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob,
  340. q blob,r blob,s blob,t blob,u blob)
  341. engine=innodb row_format=dynamic;
  342. create index t1a on t1 (a(1));
  343. create index t1b on t1 (b(1));
  344. create index t1c on t1 (c(1));
  345. create index t1d on t1 (d(1));
  346. create index t1e on t1 (e(1));
  347. create index t1f on t1 (f(1));
  348. create index t1g on t1 (g(1));
  349. create index t1h on t1 (h(1));
  350. create index t1i on t1 (i(1));
  351. create index t1j on t1 (j(1));
  352. create index t1k on t1 (k(1));
  353. create index t1l on t1 (l(1));
  354. create index t1m on t1 (m(1));
  355. create index t1n on t1 (n(1));
  356. create index t1o on t1 (o(1));
  357. create index t1p on t1 (p(1));
  358. create index t1q on t1 (q(1));
  359. create index t1r on t1 (r(1));
  360. create index t1s on t1 (s(1));
  361. create index t1t on t1 (t(1));
  362. --error 139
  363. create index t1u on t1 (u(1));
  364. --error 139
  365. create index t1ut on t1 (u(1), t(1));
  366. create index t1st on t1 (s(1), t(1));
  367. show create table t1;
  368. --error 139
  369. create index t1u on t1 (u(1));
  370. alter table t1 row_format=compact;
  371. create index t1u on t1 (u(1));
  372. drop table t1;
  373. eval set global innodb_file_per_table=$per_table;
  374. eval set global innodb_file_format=$format;
  375. eval set global innodb_file_format_check=$format;
  376. #
  377. # Test to check whether CREATE INDEX handles implicit foreign key
  378. # constraint modifications (Issue #70, Bug #38786)
  379. #
  380. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  381. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  382. CREATE TABLE t1(
  383. c1 BIGINT(12) NOT NULL,
  384. PRIMARY KEY (c1)
  385. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  386. CREATE TABLE t2(
  387. c1 BIGINT(16) NOT NULL,
  388. c2 BIGINT(12) NOT NULL,
  389. c3 BIGINT(12) NOT NULL,
  390. PRIMARY KEY (c1)
  391. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  392. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  393. FOREIGN KEY (c3) REFERENCES t1(c1);
  394. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  395. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  396. SHOW CREATE TABLE t2;
  397. CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
  398. SHOW CREATE TABLE t2;
  399. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  400. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  401. --error ER_NO_REFERENCED_ROW_2
  402. INSERT INTO t2 VALUES(0,0,0);
  403. INSERT INTO t1 VALUES(0);
  404. INSERT INTO t2 VALUES(0,0,0);
  405. DROP TABLE t2;
  406. CREATE TABLE t2(
  407. c1 BIGINT(16) NOT NULL,
  408. c2 BIGINT(12) NOT NULL,
  409. c3 BIGINT(12) NOT NULL,
  410. PRIMARY KEY (c1,c2,c3)
  411. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  412. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  413. FOREIGN KEY (c3) REFERENCES t1(c1);
  414. SHOW CREATE TABLE t2;
  415. CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
  416. SHOW CREATE TABLE t2;
  417. --error ER_NO_REFERENCED_ROW_2
  418. INSERT INTO t2 VALUES(0,0,1);
  419. INSERT INTO t2 VALUES(0,0,0);
  420. --error ER_ROW_IS_REFERENCED_2
  421. DELETE FROM t1;
  422. DELETE FROM t2;
  423. DROP TABLE t2;
  424. DROP TABLE t1;
  425. CREATE TABLE t1(
  426. c1 BIGINT(12) NOT NULL,
  427. c2 INT(4) NOT NULL,
  428. PRIMARY KEY (c2,c1)
  429. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  430. CREATE TABLE t2(
  431. c1 BIGINT(16) NOT NULL,
  432. c2 BIGINT(12) NOT NULL,
  433. c3 BIGINT(12) NOT NULL,
  434. PRIMARY KEY (c1)
  435. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  436. --replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
  437. --error ER_CANT_CREATE_TABLE
  438. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  439. FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1);
  440. --replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
  441. --error ER_CANT_CREATE_TABLE
  442. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  443. FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2);
  444. --replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
  445. --error ER_CANT_CREATE_TABLE
  446. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  447. FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1);
  448. ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL;
  449. --replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
  450. --error ER_CANT_CREATE_TABLE
  451. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  452. FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2);
  453. ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca
  454. FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1);
  455. SHOW CREATE TABLE t1;
  456. SHOW CREATE TABLE t2;
  457. CREATE INDEX i_t2_c2_c1 ON t2(c2, c1);
  458. SHOW CREATE TABLE t2;
  459. CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2);
  460. SHOW CREATE TABLE t2;
  461. CREATE INDEX i_t2_c3_c2 ON t2(c3, c2);
  462. SHOW CREATE TABLE t2;
  463. DROP TABLE t2;
  464. DROP TABLE t1;
  465. connect (a,localhost,root,,);
  466. connect (b,localhost,root,,);
  467. connection a;
  468. CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB;
  469. INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e');
  470. connection b;
  471. BEGIN;
  472. SELECT * FROM t1;
  473. connection a;
  474. CREATE INDEX t1a ON t1(a);
  475. connection b;
  476. SELECT * FROM t1;
  477. --error ER_TABLE_DEF_CHANGED
  478. SELECT * FROM t1 FORCE INDEX(t1a) ORDER BY a;
  479. SELECT * FROM t1;
  480. COMMIT;
  481. SELECT * FROM t1 FORCE INDEX(t1a) ORDER BY a;
  482. connection default;
  483. disconnect a;
  484. disconnect b;
  485. DROP TABLE t1;
  486. #
  487. # restore environment to the state it was before this test execution
  488. #
  489. -- disable_query_log
  490. eval SET GLOBAL innodb_file_format_check=$innodb_file_format_check_orig;