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.

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