~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/mysql-test/innodb-index.test

  • Committer: Monty Taylor
  • Date: 2008-08-02 01:03:15 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080802010315-65h5938pymg9d99z
Moved m4 macros to top-level m4 dir, per GNU standards (and where gettext wanted it :)

Show diffs side-by-side

added added

removed removed

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