~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/alter_table.result

  • Committer: Brian Aker
  • Date: 2010-05-27 01:22:55 UTC
  • mto: This revision was merged to the branch mainline in revision 1568.
  • Revision ID: brian@gaz-20100527012255-ssmjt4un8ptpg4jv
Remove dead .opt files. Removed two options from Innodb which do not relate
to drizzle (backwards compatible options for old MySQL). 

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
9
9
col6 int not null, to_be_deleted int);
10
10
insert into t1 values (2,4,3,5,"PENDING",1,7);
11
 
SELECT * FROM t1;
12
 
col1    col2    col3    col4    col5    col6    to_be_deleted
13
 
2       4       3       5       PENDING 1       7
14
11
alter table t1
15
12
add column col4_5 varchar(20) not null after col4,
16
13
add column col7 varchar(30) not null after col5,
17
 
add column col8 datetime not null default '1000-01-01 00:00:00', drop column to_be_deleted,
18
 
change column col2 fourth varchar(30) not null after col3,
19
 
modify column col6 int not null first;
20
 
ERROR HY000: Either a DEFAULt value or NULL NULL description is required for a new column if table is not empty
21
 
alter table t1
22
 
add column col4_5 varchar(20) DEFAULT "added" not null after col4,
23
 
add column col7 varchar(30) DEFAULT "added" not null after col5,
24
 
add column col8 datetime not null default '1000-01-01 00:00:00',
25
 
drop column to_be_deleted,
 
14
add column col8 datetime not null, drop column to_be_deleted,
26
15
change column col2 fourth varchar(30) not null after col3,
27
16
modify column col6 int not null first;
28
17
select * from t1;
29
18
col6    col1    col3    fourth  col4    col4_5  col5    col7    col8
30
 
1       2       3       4       5       added   PENDING added   1000-01-01 00:00:00
 
19
1       2       3       4       5               PENDING         0000-00-00 00:00:00
31
20
drop table t1;
32
21
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
33
22
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
63
52
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
64
53
show COLUMNS FROM t1;
65
54
Field   Type    Null    Default Default_is_NULL On_Update
66
 
GROUP_ID        INTEGER NO      0       NO      
67
 
LANG_ID INTEGER NO      0       NO      
68
 
NAME    VARCHAR NO              NO      
 
55
GROUP_ID        INTEGER FALSE   0       FALSE   
 
56
LANG_ID INTEGER FALSE   0       FALSE   
 
57
NAME    VARCHAR FALSE           FALSE   
69
58
DROP TABLE t1;
70
59
create table t1 (n int);
71
60
insert into t1 values(9),(3),(12),(10);
128
117
alter table t1;
129
118
show keys from t1;
130
119
Table   Unique  Key_name        Seq_in_index    Column_name
131
 
t1      YES     n1      1       n1
132
 
t1      NO      n1_2    1       n1
133
 
t1      NO      n1_2    2       n2
134
 
t1      NO      n1_2    3       n3
135
 
t1      NO      n1_2    4       n4
136
 
t1      NO      n2      1       n2
137
 
t1      NO      n2      2       n3
138
 
t1      NO      n2      3       n4
139
 
t1      NO      n2      4       n1
140
 
t1      NO      n3      1       n3
141
 
t1      NO      n3      2       n4
142
 
t1      NO      n3      3       n1
143
 
t1      NO      n3      4       n2
144
 
t1      NO      n4      1       n4
145
 
t1      NO      n4      2       n1
146
 
t1      NO      n4      3       n2
147
 
t1      NO      n4      4       n3
 
120
t1      TRUE    n1      1       n1
 
121
t1      FALSE   n1_2    1       n1
 
122
t1      FALSE   n1_2    2       n2
 
123
t1      FALSE   n1_2    3       n3
 
124
t1      FALSE   n1_2    4       n4
 
125
t1      FALSE   n2      1       n2
 
126
t1      FALSE   n2      2       n3
 
127
t1      FALSE   n2      3       n4
 
128
t1      FALSE   n2      4       n1
 
129
t1      FALSE   n3      1       n3
 
130
t1      FALSE   n3      2       n4
 
131
t1      FALSE   n3      3       n1
 
132
t1      FALSE   n3      4       n2
 
133
t1      FALSE   n4      1       n4
 
134
t1      FALSE   n4      2       n1
 
135
t1      FALSE   n4      3       n2
 
136
t1      FALSE   n4      4       n3
148
137
set autocommit=0;
149
138
begin;
150
139
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
164
153
Note    1031    Table storage engine for 't1' doesn't have this option
165
154
show keys from t1;
166
155
Table   Unique  Key_name        Seq_in_index    Column_name
167
 
t1      YES     n1      1       n1
168
 
t1      NO      n1_2    1       n1
169
 
t1      NO      n1_2    2       n2
170
 
t1      NO      n1_2    3       n3
171
 
t1      NO      n1_2    4       n4
172
 
t1      NO      n2      1       n2
173
 
t1      NO      n2      2       n3
174
 
t1      NO      n2      3       n4
175
 
t1      NO      n2      4       n1
176
 
t1      NO      n3      1       n3
177
 
t1      NO      n3      2       n4
178
 
t1      NO      n3      3       n1
179
 
t1      NO      n3      4       n2
180
 
t1      NO      n4      1       n4
181
 
t1      NO      n4      2       n1
182
 
t1      NO      n4      3       n2
183
 
t1      NO      n4      4       n3
 
156
t1      TRUE    n1      1       n1
 
157
t1      FALSE   n1_2    1       n1
 
158
t1      FALSE   n1_2    2       n2
 
159
t1      FALSE   n1_2    3       n3
 
160
t1      FALSE   n1_2    4       n4
 
161
t1      FALSE   n2      1       n2
 
162
t1      FALSE   n2      2       n3
 
163
t1      FALSE   n2      3       n4
 
164
t1      FALSE   n2      4       n1
 
165
t1      FALSE   n3      1       n3
 
166
t1      FALSE   n3      2       n4
 
167
t1      FALSE   n3      3       n1
 
168
t1      FALSE   n3      4       n2
 
169
t1      FALSE   n4      1       n4
 
170
t1      FALSE   n4      2       n1
 
171
t1      FALSE   n4      3       n2
 
172
t1      FALSE   n4      4       n3
184
173
drop table t1;
185
174
create table t1 (i int not null auto_increment primary key);
186
175
alter table t1 rename t2;
187
176
alter table t2 rename t1, add c char(10) comment "no comment";
188
177
show columns from t1;
189
178
Field   Type    Null    Default Default_is_NULL On_Update
190
 
i       INTEGER NO              NO      
191
 
c       VARCHAR YES             YES     
 
179
i       INTEGER FALSE   0       FALSE   
 
180
c       VARCHAR TRUE            TRUE    
192
181
drop table t1;
193
182
create table t1 (a int, b int);
194
183
set autocommit=0;
298
287
alter table t1 add unique (a,b), add key (b);
299
288
show keys from t1;
300
289
Table   Unique  Key_name        Seq_in_index    Column_name
301
 
t1      YES     a       1       a
302
 
t1      YES     a       2       b
303
 
t1      NO      b       1       b
 
290
t1      TRUE    a       1       a
 
291
t1      TRUE    a       2       b
 
292
t1      FALSE   b       1       b
304
293
analyze table t1;
305
294
Table   Op      Msg_type        Msg_text
306
295
test.t1 analyze status  OK
307
296
show keys from t1;
308
297
Table   Unique  Key_name        Seq_in_index    Column_name
309
 
t1      YES     a       1       a
310
 
t1      YES     a       2       b
311
 
t1      NO      b       1       b
 
298
t1      TRUE    a       1       a
 
299
t1      TRUE    a       2       b
 
300
t1      FALSE   b       1       b
312
301
drop table t1;
313
302
CREATE TEMPORARY TABLE t1 (
314
303
Host varchar(16) NOT NULL default '',
364
353
SHOW CREATE TABLE t1;
365
354
Table   Create Table
366
355
t1      CREATE TABLE `t1` (
367
 
  `a` INT NOT NULL,
368
 
  `b` INT DEFAULT NULL,
 
356
  `a` int NOT NULL,
 
357
  `b` int DEFAULT NULL,
369
358
  UNIQUE KEY `b` (`b`)
370
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
359
) ENGINE=DEFAULT
371
360
ALTER TABLE t1 DROP PRIMARY KEY;
372
361
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
373
362
DROP TABLE t1;
389
378
create table t1 (a int, key(a));
390
379
show indexes from t1;
391
380
Table   Unique  Key_name        Seq_in_index    Column_name
392
 
t1      NO      a       1       a
 
381
t1      FALSE   a       1       a
393
382
"this used not to disable the index"
394
383
alter table t1 modify a int;
395
384
show indexes from t1;
396
385
Table   Unique  Key_name        Seq_in_index    Column_name
397
 
t1      NO      a       1       a
 
386
t1      FALSE   a       1       a
398
387
alter table t1 enable keys;
399
388
Warnings:
400
389
Note    1031    Table storage engine for 't1' doesn't have this option
401
390
show indexes from t1;
402
391
Table   Unique  Key_name        Seq_in_index    Column_name
403
 
t1      NO      a       1       a
 
392
t1      FALSE   a       1       a
404
393
alter table t1 modify a bigint;
405
394
show indexes from t1;
406
395
Table   Unique  Key_name        Seq_in_index    Column_name
407
 
t1      NO      a       1       a
 
396
t1      FALSE   a       1       a
408
397
alter table t1 enable keys;
409
398
Warnings:
410
399
Note    1031    Table storage engine for 't1' doesn't have this option
411
400
show indexes from t1;
412
401
Table   Unique  Key_name        Seq_in_index    Column_name
413
 
t1      NO      a       1       a
 
402
t1      FALSE   a       1       a
414
403
alter table t1 add b char(10);
415
404
show indexes from t1;
416
405
Table   Unique  Key_name        Seq_in_index    Column_name
417
 
t1      NO      a       1       a
 
406
t1      FALSE   a       1       a
418
407
alter table t1 add c decimal(10,2);
419
408
show indexes from t1;
420
409
Table   Unique  Key_name        Seq_in_index    Column_name
421
 
t1      NO      a       1       a
 
410
t1      FALSE   a       1       a
422
411
"this however did"
423
412
alter table t1;
424
413
show indexes from t1;
425
414
Table   Unique  Key_name        Seq_in_index    Column_name
426
 
t1      NO      a       1       a
 
415
t1      FALSE   a       1       a
427
416
desc t1;
428
417
Field   Type    Null    Default Default_is_NULL On_Update
429
 
a       BIGINT  YES             YES     
430
 
b       VARCHAR YES             YES     
431
 
c       DECIMAL YES             YES     
 
418
a       BIGINT  TRUE            TRUE    
 
419
b       VARCHAR TRUE            TRUE    
 
420
c       DECIMAL TRUE            TRUE    
432
421
alter table t1 add d decimal(15,5);
433
422
"The key should still be disabled"
434
423
show indexes from t1;
435
424
Table   Unique  Key_name        Seq_in_index    Column_name
436
 
t1      NO      a       1       a
 
425
t1      FALSE   a       1       a
437
426
drop table t1;
438
427
"Now will test with one unique index"
439
428
create table t1(a int, b char(10), unique(a));
440
429
show indexes from t1;
441
430
Table   Unique  Key_name        Seq_in_index    Column_name
442
 
t1      YES     a       1       a
 
431
t1      TRUE    a       1       a
443
432
alter table t1;
444
433
show indexes from t1;
445
434
Table   Unique  Key_name        Seq_in_index    Column_name
446
 
t1      YES     a       1       a
 
435
t1      TRUE    a       1       a
447
436
alter table t1 enable keys;
448
437
Warnings:
449
438
Note    1031    Table storage engine for 't1' doesn't have this option
452
441
alter table t1 modify a int;
453
442
show indexes from t1;
454
443
Table   Unique  Key_name        Seq_in_index    Column_name
455
 
t1      YES     a       1       a
 
444
t1      TRUE    a       1       a
456
445
"Change the type implying data copy"
457
446
"Unique index, no change"
458
447
alter table t1 modify a bigint;
459
448
show indexes from t1;
460
449
Table   Unique  Key_name        Seq_in_index    Column_name
461
 
t1      YES     a       1       a
 
450
t1      TRUE    a       1       a
462
451
alter table t1 modify a bigint;
463
452
show indexes from t1;
464
453
Table   Unique  Key_name        Seq_in_index    Column_name
465
 
t1      YES     a       1       a
 
454
t1      TRUE    a       1       a
466
455
alter table t1 modify a int;
467
456
show indexes from t1;
468
457
Table   Unique  Key_name        Seq_in_index    Column_name
469
 
t1      YES     a       1       a
 
458
t1      TRUE    a       1       a
470
459
drop table t1;
471
460
"Now will test with one unique and one non-unique index"
472
461
create table t1(a int, b char(10), unique(a), key(b));
473
462
show indexes from t1;
474
463
Table   Unique  Key_name        Seq_in_index    Column_name
475
 
t1      YES     a       1       a
476
 
t1      NO      b       1       b
 
464
t1      TRUE    a       1       a
 
465
t1      FALSE   b       1       b
477
466
alter table t1;
478
467
show indexes from t1;
479
468
Table   Unique  Key_name        Seq_in_index    Column_name
480
 
t1      YES     a       1       a
481
 
t1      NO      b       1       b
 
469
t1      TRUE    a       1       a
 
470
t1      FALSE   b       1       b
482
471
alter table t1 enable keys;
483
472
Warnings:
484
473
Note    1031    Table storage engine for 't1' doesn't have this option
487
476
alter table t1 modify a int;
488
477
show indexes from t1;
489
478
Table   Unique  Key_name        Seq_in_index    Column_name
490
 
t1      YES     a       1       a
491
 
t1      NO      b       1       b
 
479
t1      TRUE    a       1       a
 
480
t1      FALSE   b       1       b
492
481
alter table t1 enable keys;
493
482
Warnings:
494
483
Note    1031    Table storage engine for 't1' doesn't have this option
495
484
show indexes from t1;
496
485
Table   Unique  Key_name        Seq_in_index    Column_name
497
 
t1      YES     a       1       a
498
 
t1      NO      b       1       b
 
486
t1      TRUE    a       1       a
 
487
t1      FALSE   b       1       b
499
488
"Change the type implying data copy"
500
489
"The non-unique index will be disabled"
501
490
alter table t1 modify a bigint;
502
491
show indexes from t1;
503
492
Table   Unique  Key_name        Seq_in_index    Column_name
504
 
t1      YES     a       1       a
505
 
t1      NO      b       1       b
 
493
t1      TRUE    a       1       a
 
494
t1      FALSE   b       1       b
506
495
"Change again the type, but leave the indexes as_is"
507
496
alter table t1 modify a int;
508
497
show indexes from t1;
509
498
Table   Unique  Key_name        Seq_in_index    Column_name
510
 
t1      YES     a       1       a
511
 
t1      NO      b       1       b
 
499
t1      TRUE    a       1       a
 
500
t1      FALSE   b       1       b
512
501
"Try the same. When data is no copied on similar tables, this is noop"
513
502
alter table t1 modify a int;
514
503
show indexes from t1;
515
504
Table   Unique  Key_name        Seq_in_index    Column_name
516
 
t1      YES     a       1       a
517
 
t1      NO      b       1       b
 
505
t1      TRUE    a       1       a
 
506
t1      FALSE   b       1       b
518
507
drop table t1;
519
508
create database mysqltest;
520
509
create table t1 (c1 int);
527
516
use mysqltest;
528
517
drop database mysqltest;
529
518
alter table test.t1 rename t1;
530
 
ERROR 3D000: No schema selected
 
519
ERROR 3D000: No database selected
531
520
alter table test.t1 rename test.t1;
532
521
use test;
533
522
drop table t1;
536
525
SHOW CREATE TABLE t1;
537
526
Table   Create Table
538
527
t1      CREATE TABLE `t1` (
539
 
  `a` INT DEFAULT NULL,
 
528
  `a` int DEFAULT NULL,
540
529
  KEY `i1` (`a`)
541
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
530
) ENGINE=DEFAULT ROW_FORMAT='COMPACT'
542
531
DROP INDEX i1 ON t1;
543
532
SHOW CREATE TABLE t1;
544
533
Table   Create Table
545
534
t1      CREATE TABLE `t1` (
546
 
  `a` INT DEFAULT NULL
547
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
535
  `a` int DEFAULT NULL
 
536
) ENGINE=DEFAULT ROW_FORMAT='COMPACT'
548
537
DROP TABLE t1;
549
538
DROP TABLE IF EXISTS bug24219;
550
539
DROP TABLE IF EXISTS bug24219_2;
551
540
CREATE TABLE bug24219 (a INT, INDEX(a));
552
541
SHOW INDEX FROM bug24219;
553
542
Table   Unique  Key_name        Seq_in_index    Column_name
554
 
bug24219        NO      a       1       a
 
543
bug24219        FALSE   a       1       a
555
544
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
556
545
Warnings:
557
546
Note    1031    Table storage engine for 'bug24219' doesn't have this option
558
547
SHOW INDEX FROM bug24219_2;
559
548
Table   Unique  Key_name        Seq_in_index    Column_name
560
 
bug24219_2      NO      a       1       a
 
549
bug24219_2      FALSE   a       1       a
561
550
DROP TABLE bug24219_2;
562
551
drop table if exists table_24562;
563
552
create table table_24562(
674
663
alter table t1 alter column mycol set default 0;
675
664
desc t1;
676
665
Field   Type    Null    Default Default_is_NULL On_Update
677
 
mycol   INTEGER NO      0       NO      
 
666
mycol   INTEGER FALSE   0       FALSE   
678
667
drop table t1;
679
668
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
680
669
insert into t1 values (null);
810
799
SHOW CREATE TABLE `tt+1`;
811
800
Table   Create Table
812
801
tt+1    CREATE TEMPORARY TABLE `tt+1` (
813
 
  `c1` INT DEFAULT NULL
814
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
802
  `c1` int DEFAULT NULL
 
803
) ENGINE=DEFAULT
815
804
SHOW CREATE TABLE `tt+2`;
816
805
Table   Create Table
817
806
tt+2    CREATE TEMPORARY TABLE `tt+2` (
818
 
  `c1` INT DEFAULT NULL
819
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
807
  `c1` int DEFAULT NULL
 
808
) ENGINE=DEFAULT
820
809
DROP TABLE   `tt+1`, `tt+2`;
821
810
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
811
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
835
824
SHOW CREATE TABLE `#sql2`;
836
825
Table   Create Table
837
826
#sql2   CREATE TEMPORARY TABLE `#sql2` (
838
 
  `c1` INT DEFAULT NULL
839
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
827
  `c1` int DEFAULT NULL
 
828
) ENGINE=DEFAULT
840
829
SHOW CREATE TABLE `@0023sql1`;
841
830
Table   Create Table
842
831
@0023sql1       CREATE TEMPORARY TABLE `@0023sql1` (
843
 
  `c1` INT DEFAULT NULL
844
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
832
  `c1` int DEFAULT NULL
 
833
) ENGINE=DEFAULT
845
834
DROP TABLE `#sql2`, `@0023sql1`;
846
835
DROP TABLE IF EXISTS t1;
847
836
DROP TABLE IF EXISTS t2;
852
841
);
853
842
DESCRIBE t1;
854
843
Field   Type    Null    Default Default_is_NULL On_Update
855
 
int_field       INTEGER NO              NO      
856
 
char_field      VARCHAR YES             YES     
 
844
int_field       INTEGER FALSE           FALSE   
 
845
char_field      VARCHAR TRUE            TRUE    
857
846
SHOW INDEXES FROM t1;
858
847
Table   Unique  Key_name        Seq_in_index    Column_name
859
 
t1      NO      int_field       1       int_field
 
848
t1      FALSE   int_field       1       int_field
860
849
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
850
"Non-copy data change - new frm, but old data and index files"
862
851
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
863
852
SELECT * FROM t1 ORDER BY int_field;
864
 
ERROR 42S02: Unknown table 'test.t1'
 
853
ERROR 42S02: Table 'test.t1' doesn't exist
865
854
SELECT * FROM t2 ORDER BY unsigned_int_field;
866
855
unsigned_int_field      char_field
867
856
1       edno
871
860
5       pet
872
861
DESCRIBE t2;
873
862
Field   Type    Null    Default Default_is_NULL On_Update
874
 
unsigned_int_field      INTEGER NO              NO      
875
 
char_field      VARCHAR YES             YES     
 
863
unsigned_int_field      INTEGER FALSE           FALSE   
 
864
char_field      VARCHAR TRUE            TRUE    
876
865
DESCRIBE t2;
877
866
Field   Type    Null    Default Default_is_NULL On_Update
878
 
unsigned_int_field      INTEGER NO              NO      
879
 
char_field      VARCHAR YES             YES     
 
867
unsigned_int_field      INTEGER FALSE           FALSE   
 
868
char_field      VARCHAR TRUE            TRUE    
880
869
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
881
870
DESCRIBE t2;
882
871
Field   Type    Null    Default Default_is_NULL On_Update
883
 
unsigned_int_field      BIGINT  NO              NO      
884
 
char_field      VARCHAR YES             YES     
 
872
unsigned_int_field      BIGINT  FALSE           FALSE   
 
873
char_field      VARCHAR TRUE            TRUE    
885
874
DROP TABLE t2;
886
875
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
876
INSERT INTO t1 VALUES (1, 2, NULL);