~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/alter_table.result

  • Committer: Brian Aker
  • Date: 2010-03-01 22:24:10 UTC
  • mto: (1309.2.12 build)
  • mto: This revision was merged to the branch mainline in revision 1317.
  • Revision ID: brian@gaz-20100301222410-w509prhp73pg6z4n
Update the code so use a faster index lookup method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
key (n4, n1, n2, n3) );
120
120
alter table t1;
121
121
show keys from t1;
122
 
Table   Key_name        Seq_in_index    Column_name
123
 
t1      n1      0       n1
124
 
t1      n1_2    0       n1
125
 
t1      n1_2    1       n2
126
 
t1      n1_2    2       n3
127
 
t1      n1_2    3       n4
128
 
t1      n2      0       n2
129
 
t1      n2      1       n3
130
 
t1      n2      2       n4
131
 
t1      n2      3       n1
132
 
t1      n3      0       n3
133
 
t1      n3      1       n4
134
 
t1      n3      2       n1
135
 
t1      n3      3       n2
136
 
t1      n4      0       n4
137
 
t1      n4      1       n1
138
 
t1      n4      2       n2
139
 
t1      n4      3       n3
 
122
Table   Unique  Key_name        Seq_in_index    Column_name
 
123
t1      TRUE    n1      1       n1
 
124
t1      FALSE   n1_2    1       n1
 
125
t1      FALSE   n1_2    2       n2
 
126
t1      FALSE   n1_2    3       n3
 
127
t1      FALSE   n1_2    4       n4
 
128
t1      FALSE   n2      1       n2
 
129
t1      FALSE   n2      2       n3
 
130
t1      FALSE   n2      3       n4
 
131
t1      FALSE   n2      4       n1
 
132
t1      FALSE   n3      1       n3
 
133
t1      FALSE   n3      2       n4
 
134
t1      FALSE   n3      3       n1
 
135
t1      FALSE   n3      4       n2
 
136
t1      FALSE   n4      1       n4
 
137
t1      FALSE   n4      2       n1
 
138
t1      FALSE   n4      3       n2
 
139
t1      FALSE   n4      4       n3
140
140
set autocommit=0;
141
141
begin;
142
142
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
155
155
Warnings:
156
156
Note    1031    Table storage engine for 't1' doesn't have this option
157
157
show keys from t1;
158
 
Table   Key_name        Seq_in_index    Column_name
159
 
t1      n1      0       n1
160
 
t1      n1_2    0       n1
161
 
t1      n1_2    1       n2
162
 
t1      n1_2    2       n3
163
 
t1      n1_2    3       n4
164
 
t1      n2      0       n2
165
 
t1      n2      1       n3
166
 
t1      n2      2       n4
167
 
t1      n2      3       n1
168
 
t1      n3      0       n3
169
 
t1      n3      1       n4
170
 
t1      n3      2       n1
171
 
t1      n3      3       n2
172
 
t1      n4      0       n4
173
 
t1      n4      1       n1
174
 
t1      n4      2       n2
175
 
t1      n4      3       n3
 
158
Table   Unique  Key_name        Seq_in_index    Column_name
 
159
t1      TRUE    n1      1       n1
 
160
t1      FALSE   n1_2    1       n1
 
161
t1      FALSE   n1_2    2       n2
 
162
t1      FALSE   n1_2    3       n3
 
163
t1      FALSE   n1_2    4       n4
 
164
t1      FALSE   n2      1       n2
 
165
t1      FALSE   n2      2       n3
 
166
t1      FALSE   n2      3       n4
 
167
t1      FALSE   n2      4       n1
 
168
t1      FALSE   n3      1       n3
 
169
t1      FALSE   n3      2       n4
 
170
t1      FALSE   n3      3       n1
 
171
t1      FALSE   n3      4       n2
 
172
t1      FALSE   n4      1       n4
 
173
t1      FALSE   n4      2       n1
 
174
t1      FALSE   n4      3       n2
 
175
t1      FALSE   n4      4       n3
176
176
drop table t1;
177
177
create table t1 (i int not null auto_increment primary key);
178
178
alter table t1 rename t2;
289
289
set autocommit=1;
290
290
alter table t1 add unique (a,b), add key (b);
291
291
show keys from t1;
292
 
Table   Key_name        Seq_in_index    Column_name
293
 
t1      a       0       a
294
 
t1      a       1       b
295
 
t1      b       0       b
 
292
Table   Unique  Key_name        Seq_in_index    Column_name
 
293
t1      TRUE    a       1       a
 
294
t1      TRUE    a       2       b
 
295
t1      FALSE   b       1       b
296
296
analyze table t1;
297
297
Table   Op      Msg_type        Msg_text
298
298
test.t1 analyze status  OK
299
299
show keys from t1;
300
 
Table   Key_name        Seq_in_index    Column_name
301
 
t1      a       0       a
302
 
t1      a       1       b
303
 
t1      b       0       b
 
300
Table   Unique  Key_name        Seq_in_index    Column_name
 
301
t1      TRUE    a       1       a
 
302
t1      TRUE    a       2       b
 
303
t1      FALSE   b       1       b
304
304
drop table t1;
305
305
CREATE TEMPORARY TABLE t1 (
306
306
Host varchar(16) NOT NULL default '',
380
380
drop table if exists t1;
381
381
create table t1 (a int, key(a));
382
382
show indexes from t1;
383
 
Table   Key_name        Seq_in_index    Column_name
384
 
t1      a       0       a
 
383
Table   Unique  Key_name        Seq_in_index    Column_name
 
384
t1      FALSE   a       1       a
385
385
"this used not to disable the index"
386
386
alter table t1 modify a int;
387
387
show indexes from t1;
388
 
Table   Key_name        Seq_in_index    Column_name
389
 
t1      a       0       a
 
388
Table   Unique  Key_name        Seq_in_index    Column_name
 
389
t1      FALSE   a       1       a
390
390
alter table t1 enable keys;
391
391
Warnings:
392
392
Note    1031    Table storage engine for 't1' doesn't have this option
393
393
show indexes from t1;
394
 
Table   Key_name        Seq_in_index    Column_name
395
 
t1      a       0       a
 
394
Table   Unique  Key_name        Seq_in_index    Column_name
 
395
t1      FALSE   a       1       a
396
396
alter table t1 modify a bigint;
397
397
show indexes from t1;
398
 
Table   Key_name        Seq_in_index    Column_name
399
 
t1      a       0       a
 
398
Table   Unique  Key_name        Seq_in_index    Column_name
 
399
t1      FALSE   a       1       a
400
400
alter table t1 enable keys;
401
401
Warnings:
402
402
Note    1031    Table storage engine for 't1' doesn't have this option
403
403
show indexes from t1;
404
 
Table   Key_name        Seq_in_index    Column_name
405
 
t1      a       0       a
 
404
Table   Unique  Key_name        Seq_in_index    Column_name
 
405
t1      FALSE   a       1       a
406
406
alter table t1 add b char(10);
407
407
show indexes from t1;
408
 
Table   Key_name        Seq_in_index    Column_name
409
 
t1      a       0       a
 
408
Table   Unique  Key_name        Seq_in_index    Column_name
 
409
t1      FALSE   a       1       a
410
410
alter table t1 add c decimal(10,2);
411
411
show indexes from t1;
412
 
Table   Key_name        Seq_in_index    Column_name
413
 
t1      a       0       a
 
412
Table   Unique  Key_name        Seq_in_index    Column_name
 
413
t1      FALSE   a       1       a
414
414
"this however did"
415
415
alter table t1;
416
416
show indexes from t1;
417
 
Table   Key_name        Seq_in_index    Column_name
418
 
t1      a       0       a
 
417
Table   Unique  Key_name        Seq_in_index    Column_name
 
418
t1      FALSE   a       1       a
419
419
desc t1;
420
420
Field   Type    Null    Default Default is NULL On Update
421
421
a       BIGINT  TRUE            TRUE    
424
424
alter table t1 add d decimal(15,5);
425
425
"The key should still be disabled"
426
426
show indexes from t1;
427
 
Table   Key_name        Seq_in_index    Column_name
428
 
t1      a       0       a
 
427
Table   Unique  Key_name        Seq_in_index    Column_name
 
428
t1      FALSE   a       1       a
429
429
drop table t1;
430
430
"Now will test with one unique index"
431
431
create table t1(a int, b char(10), unique(a));
432
432
show indexes from t1;
433
 
Table   Key_name        Seq_in_index    Column_name
434
 
t1      a       0       a
 
433
Table   Unique  Key_name        Seq_in_index    Column_name
 
434
t1      TRUE    a       1       a
435
435
alter table t1;
436
436
show indexes from t1;
437
 
Table   Key_name        Seq_in_index    Column_name
438
 
t1      a       0       a
 
437
Table   Unique  Key_name        Seq_in_index    Column_name
 
438
t1      TRUE    a       1       a
439
439
alter table t1 enable keys;
440
440
Warnings:
441
441
Note    1031    Table storage engine for 't1' doesn't have this option
443
443
"Unique index, no change"
444
444
alter table t1 modify a int;
445
445
show indexes from t1;
446
 
Table   Key_name        Seq_in_index    Column_name
447
 
t1      a       0       a
 
446
Table   Unique  Key_name        Seq_in_index    Column_name
 
447
t1      TRUE    a       1       a
448
448
"Change the type implying data copy"
449
449
"Unique index, no change"
450
450
alter table t1 modify a bigint;
451
451
show indexes from t1;
452
 
Table   Key_name        Seq_in_index    Column_name
453
 
t1      a       0       a
 
452
Table   Unique  Key_name        Seq_in_index    Column_name
 
453
t1      TRUE    a       1       a
454
454
alter table t1 modify a bigint;
455
455
show indexes from t1;
456
 
Table   Key_name        Seq_in_index    Column_name
457
 
t1      a       0       a
 
456
Table   Unique  Key_name        Seq_in_index    Column_name
 
457
t1      TRUE    a       1       a
458
458
alter table t1 modify a int;
459
459
show indexes from t1;
460
 
Table   Key_name        Seq_in_index    Column_name
461
 
t1      a       0       a
 
460
Table   Unique  Key_name        Seq_in_index    Column_name
 
461
t1      TRUE    a       1       a
462
462
drop table t1;
463
463
"Now will test with one unique and one non-unique index"
464
464
create table t1(a int, b char(10), unique(a), key(b));
465
465
show indexes from t1;
466
 
Table   Key_name        Seq_in_index    Column_name
467
 
t1      a       0       a
468
 
t1      b       0       b
 
466
Table   Unique  Key_name        Seq_in_index    Column_name
 
467
t1      TRUE    a       1       a
 
468
t1      FALSE   b       1       b
469
469
alter table t1;
470
470
show indexes from t1;
471
 
Table   Key_name        Seq_in_index    Column_name
472
 
t1      a       0       a
473
 
t1      b       0       b
 
471
Table   Unique  Key_name        Seq_in_index    Column_name
 
472
t1      TRUE    a       1       a
 
473
t1      FALSE   b       1       b
474
474
alter table t1 enable keys;
475
475
Warnings:
476
476
Note    1031    Table storage engine for 't1' doesn't have this option
478
478
"The non-unique index will be disabled"
479
479
alter table t1 modify a int;
480
480
show indexes from t1;
481
 
Table   Key_name        Seq_in_index    Column_name
482
 
t1      a       0       a
483
 
t1      b       0       b
 
481
Table   Unique  Key_name        Seq_in_index    Column_name
 
482
t1      TRUE    a       1       a
 
483
t1      FALSE   b       1       b
484
484
alter table t1 enable keys;
485
485
Warnings:
486
486
Note    1031    Table storage engine for 't1' doesn't have this option
487
487
show indexes from t1;
488
 
Table   Key_name        Seq_in_index    Column_name
489
 
t1      a       0       a
490
 
t1      b       0       b
 
488
Table   Unique  Key_name        Seq_in_index    Column_name
 
489
t1      TRUE    a       1       a
 
490
t1      FALSE   b       1       b
491
491
"Change the type implying data copy"
492
492
"The non-unique index will be disabled"
493
493
alter table t1 modify a bigint;
494
494
show indexes from t1;
495
 
Table   Key_name        Seq_in_index    Column_name
496
 
t1      a       0       a
497
 
t1      b       0       b
 
495
Table   Unique  Key_name        Seq_in_index    Column_name
 
496
t1      TRUE    a       1       a
 
497
t1      FALSE   b       1       b
498
498
"Change again the type, but leave the indexes as_is"
499
499
alter table t1 modify a int;
500
500
show indexes from t1;
501
 
Table   Key_name        Seq_in_index    Column_name
502
 
t1      a       0       a
503
 
t1      b       0       b
 
501
Table   Unique  Key_name        Seq_in_index    Column_name
 
502
t1      TRUE    a       1       a
 
503
t1      FALSE   b       1       b
504
504
"Try the same. When data is no copied on similar tables, this is noop"
505
505
alter table t1 modify a int;
506
506
show indexes from t1;
507
 
Table   Key_name        Seq_in_index    Column_name
508
 
t1      a       0       a
509
 
t1      b       0       b
 
507
Table   Unique  Key_name        Seq_in_index    Column_name
 
508
t1      TRUE    a       1       a
 
509
t1      FALSE   b       1       b
510
510
drop table t1;
511
511
create database mysqltest;
512
512
create table t1 (c1 int);
542
542
DROP TABLE IF EXISTS bug24219_2;
543
543
CREATE TABLE bug24219 (a INT, INDEX(a));
544
544
SHOW INDEX FROM bug24219;
545
 
Table   Key_name        Seq_in_index    Column_name
546
 
bug24219        a       0       a
 
545
Table   Unique  Key_name        Seq_in_index    Column_name
 
546
bug24219        FALSE   a       1       a
547
547
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
548
548
Warnings:
549
549
Note    1031    Table storage engine for 'bug24219' doesn't have this option
550
550
SHOW INDEX FROM bug24219_2;
551
 
Table   Key_name        Seq_in_index    Column_name
552
 
bug24219_2      a       0       a
 
551
Table   Unique  Key_name        Seq_in_index    Column_name
 
552
bug24219_2      FALSE   a       1       a
553
553
DROP TABLE bug24219_2;
554
554
drop table if exists table_24562;
555
555
create table table_24562(
847
847
int_field       INTEGER FALSE           FALSE   
848
848
char_field      VARCHAR TRUE            TRUE    
849
849
SHOW INDEXES FROM t1;
850
 
Table   Key_name        Seq_in_index    Column_name
851
 
t1      int_field       0       int_field
 
850
Table   Unique  Key_name        Seq_in_index    Column_name
 
851
t1      FALSE   int_field       1       int_field
852
852
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
853
853
"Non-copy data change - new frm, but old data and index files"
854
854
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;