~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/alter_table.result

  • Committer: Monty Taylor
  • Date: 2009-05-19 21:30:11 UTC
  • mto: (1022.4.2 update-to-gcc-44)
  • mto: This revision was merged to the branch mainline in revision 1031.
  • Revision ID: mordred@inaugust.com-20090519213011-4tpejk7l2f1q7wrh
Added support for using gnutls instead of openssl for the md5 plugin. On Debian,
linking openssl against GPL software is sort of frowned on because it's one
of those murky areas. In this case, we can support gnutls by just changing a
header, so it saves us an argument with someone down the road.

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);
61
50
PRIMARY KEY (GROUP_ID,LANG_ID),
62
51
KEY NAME (NAME));
63
52
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
64
 
show COLUMNS FROM t1;
65
 
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      
 
53
SHOW FULL COLUMNS FROM t1;
 
54
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
55
GROUP_ID        int     NULL    NO      PRI     0               #       
 
56
LANG_ID int     NULL    NO      PRI     0               #       
 
57
NAME    varchar(80)     utf8_general_ci NO      MUL     NULL            #       
69
58
DROP TABLE t1;
70
59
create table t1 (n int);
71
60
insert into t1 values(9),(3),(12),(10);
77
66
10
78
67
12
79
68
drop table t1;
80
 
CREATE TEMPORARY TABLE t1 (
 
69
CREATE TABLE t1 (
81
70
id int NOT NULL default '0',
82
71
category_id int NOT NULL default '0',
83
72
type_id int NOT NULL default '0',
88
77
) ENGINE=MyISAM;
89
78
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
90
79
DROP TABLE t1;
 
80
CREATE TABLE t1 (AnamneseId int NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
 
81
insert into t1 values (null,"hello");
 
82
LOCK TABLES t1 WRITE;
 
83
ALTER TABLE t1 ADD Column new_col int not null;
 
84
UNLOCK TABLES;
 
85
OPTIMIZE TABLE t1;
 
86
Table   Op      Msg_type        Msg_text
 
87
test.t1 optimize        status  OK
 
88
DROP TABLE t1;
91
89
create table t1 (i int not null auto_increment primary key);
92
90
insert into t1 values (null),(null),(null),(null);
93
91
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
110
108
name
111
109
mysqltest
112
110
alter table t1 rename mysqltest.t1;
113
 
ERROR 42S01: Table 'mysqltest.t1' already exists
 
111
ERROR 42S01: Table 't1' already exists
114
112
select * from t1;
115
113
name
116
114
current
127
125
key (n4, n1, n2, n3) );
128
126
alter table t1;
129
127
show keys from t1;
130
 
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
 
128
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
129
t1      0       n1      1       n1      A       0       NULL    NULL            BTREE           
 
130
t1      1       n1_2    1       n1      A       0       NULL    NULL            BTREE           
 
131
t1      1       n1_2    2       n2      A       0       NULL    NULL    YES     BTREE           
 
132
t1      1       n1_2    3       n3      A       0       NULL    NULL    YES     BTREE           
 
133
t1      1       n1_2    4       n4      A       0       NULL    NULL    YES     BTREE           
 
134
t1      1       n2      1       n2      A       0       NULL    NULL    YES     BTREE           
 
135
t1      1       n2      2       n3      A       0       NULL    NULL    YES     BTREE           
 
136
t1      1       n2      3       n4      A       0       NULL    NULL    YES     BTREE           
 
137
t1      1       n2      4       n1      A       0       NULL    NULL            BTREE           
 
138
t1      1       n3      1       n3      A       0       NULL    NULL    YES     BTREE           
 
139
t1      1       n3      2       n4      A       0       NULL    NULL    YES     BTREE           
 
140
t1      1       n3      3       n1      A       0       NULL    NULL            BTREE           
 
141
t1      1       n3      4       n2      A       0       NULL    NULL    YES     BTREE           
 
142
t1      1       n4      1       n4      A       0       NULL    NULL    YES     BTREE           
 
143
t1      1       n4      2       n1      A       0       NULL    NULL            BTREE           
 
144
t1      1       n4      3       n2      A       0       NULL    NULL    YES     BTREE           
 
145
t1      1       n4      4       n3      A       0       NULL    NULL    YES     BTREE           
148
146
set autocommit=0;
149
147
begin;
150
148
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
163
161
Warnings:
164
162
Note    1031    Table storage engine for 't1' doesn't have this option
165
163
show keys from t1;
166
 
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
 
164
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
165
t1      0       n1      1       n1      A       2       NULL    NULL            BTREE           
 
166
t1      1       n1_2    1       n1      A       2       NULL    NULL            BTREE           
 
167
t1      1       n1_2    2       n2      A       2       NULL    NULL    YES     BTREE           
 
168
t1      1       n1_2    3       n3      A       2       NULL    NULL    YES     BTREE           
 
169
t1      1       n1_2    4       n4      A       2       NULL    NULL    YES     BTREE           
 
170
t1      1       n2      1       n2      A       2       NULL    NULL    YES     BTREE           
 
171
t1      1       n2      2       n3      A       2       NULL    NULL    YES     BTREE           
 
172
t1      1       n2      3       n4      A       2       NULL    NULL    YES     BTREE           
 
173
t1      1       n2      4       n1      A       2       NULL    NULL            BTREE           
 
174
t1      1       n3      1       n3      A       2       NULL    NULL    YES     BTREE           
 
175
t1      1       n3      2       n4      A       2       NULL    NULL    YES     BTREE           
 
176
t1      1       n3      3       n1      A       2       NULL    NULL            BTREE           
 
177
t1      1       n3      4       n2      A       2       NULL    NULL    YES     BTREE           
 
178
t1      1       n4      1       n4      A       2       NULL    NULL    YES     BTREE           
 
179
t1      1       n4      2       n1      A       2       NULL    NULL            BTREE           
 
180
t1      1       n4      3       n2      A       2       NULL    NULL    YES     BTREE           
 
181
t1      1       n4      4       n3      A       2       NULL    NULL    YES     BTREE           
184
182
drop table t1;
185
183
create table t1 (i int not null auto_increment primary key);
186
184
alter table t1 rename t2;
187
185
alter table t2 rename t1, add c char(10) comment "no comment";
188
186
show columns from t1;
189
 
Field   Type    Null    Default Default_is_NULL On_Update
190
 
i       INTEGER NO              NO      
191
 
c       VARCHAR YES             YES     
 
187
Field   Type    Null    Key     Default Extra
 
188
i       int     NO      PRI     NULL    auto_increment
 
189
c       varchar(10)     YES             NULL    
192
190
drop table t1;
193
191
create table t1 (a int, b int);
194
192
set autocommit=0;
297
295
set autocommit=1;
298
296
alter table t1 add unique (a,b), add key (b);
299
297
show keys from t1;
300
 
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
 
298
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
299
t1      0       a       1       a       A       6       NULL    NULL    YES     BTREE           
 
300
t1      0       a       2       b       A       300     NULL    NULL    YES     BTREE           
 
301
t1      1       b       1       b       A       300     NULL    NULL    YES     BTREE           
304
302
analyze table t1;
305
303
Table   Op      Msg_type        Msg_text
306
304
test.t1 analyze status  OK
307
305
show keys from t1;
308
 
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
 
306
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
307
t1      0       a       1       a       A       6       NULL    NULL    YES     BTREE           
 
308
t1      0       a       2       b       A       300     NULL    NULL    YES     BTREE           
 
309
t1      1       b       1       b       A       300     NULL    NULL    YES     BTREE           
312
310
drop table t1;
313
 
CREATE TEMPORARY TABLE t1 (
314
 
Host varchar(16) NOT NULL default '',
315
 
User varchar(16) NOT NULL default '',
 
311
CREATE TABLE t1 (
 
312
Host varchar(16) binary NOT NULL default '',
 
313
User varchar(16) binary NOT NULL default '',
 
314
PRIMARY KEY  (Host,User)
 
315
) ENGINE=MyISAM;
 
316
ALTER TABLE t1 DISABLE KEYS;
 
317
LOCK TABLES t1 WRITE;
 
318
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
 
319
SHOW INDEX FROM t1;
 
320
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
321
t1      0       PRIMARY 1       Host    A       NULL    NULL    NULL            BTREE           
 
322
t1      0       PRIMARY 2       User    A       0       NULL    NULL            BTREE           
 
323
ALTER TABLE t1 ENABLE KEYS;
 
324
UNLOCK TABLES;
 
325
CHECK TABLES t1;
 
326
Table   Op      Msg_type        Msg_text
 
327
test.t1 check   status  OK
 
328
DROP TABLE t1;
 
329
CREATE TABLE t1 (
 
330
Host varchar(16) binary NOT NULL default '',
 
331
User varchar(16) binary NOT NULL default '',
316
332
PRIMARY KEY  (Host,User),
317
333
KEY  (Host)
318
334
) ENGINE=MyISAM;
319
335
ALTER TABLE t1 DISABLE KEYS;
 
336
SHOW INDEX FROM t1;
 
337
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
338
t1      0       PRIMARY 1       Host    A       NULL    NULL    NULL            BTREE           
 
339
t1      0       PRIMARY 2       User    A       0       NULL    NULL            BTREE           
 
340
t1      1       Host    1       Host    A       NULL    NULL    NULL            BTREE   disabled        
 
341
LOCK TABLES t1 WRITE;
320
342
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
 
343
SHOW INDEX FROM t1;
 
344
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
345
t1      0       PRIMARY 1       Host    A       NULL    NULL    NULL            BTREE           
 
346
t1      0       PRIMARY 2       User    A       0       NULL    NULL            BTREE           
 
347
t1      1       Host    1       Host    A       NULL    NULL    NULL            BTREE   disabled        
321
348
ALTER TABLE t1 ENABLE KEYS;
 
349
SHOW INDEX FROM t1;
 
350
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
351
t1      0       PRIMARY 1       Host    A       NULL    NULL    NULL            BTREE           
 
352
t1      0       PRIMARY 2       User    A       2       NULL    NULL            BTREE           
 
353
t1      1       Host    1       Host    A       1       NULL    NULL            BTREE           
 
354
UNLOCK TABLES;
322
355
CHECK TABLES t1;
323
356
Table   Op      Msg_type        Msg_text
324
357
test.t1 check   status  OK
 
358
LOCK TABLES t1 WRITE;
325
359
ALTER TABLE t1 RENAME t2;
 
360
UNLOCK TABLES;
326
361
select * from t2;
327
362
Host    User
328
363
localhost       
329
364
localhost       root
330
365
DROP TABLE t2;
 
366
CREATE TABLE t1 (
 
367
Host varchar(16) binary NOT NULL default '',
 
368
User varchar(16) binary NOT NULL default '',
 
369
PRIMARY KEY  (Host,User),
 
370
KEY  (Host)
 
371
) ENGINE=MyISAM;
 
372
LOCK TABLES t1 WRITE;
 
373
ALTER TABLE t1 DISABLE KEYS;
 
374
SHOW INDEX FROM t1;
 
375
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
376
t1      0       PRIMARY 1       Host    A       NULL    NULL    NULL            BTREE           
 
377
t1      0       PRIMARY 2       User    A       0       NULL    NULL            BTREE           
 
378
t1      1       Host    1       Host    A       NULL    NULL    NULL            BTREE   disabled        
 
379
DROP TABLE t1;
331
380
create table t1 (a int);
332
381
alter table t1 rename to ``;
333
382
ERROR 42000: Incorrect table name ''
337
386
drop table if exists t1;
338
387
Warnings:
339
388
Note    1051    Unknown table 't1'
340
 
create TEMPORARY table t1 ( a varchar(10) not null primary key ) engine=myisam;
 
389
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
341
390
flush tables;
342
391
alter table t1 modify a varchar(10);
343
392
flush tables;
344
393
alter table t1 modify a varchar(10) not null;
345
394
drop table if exists t1;
346
 
create TEMPORARY table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
 
395
create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
347
396
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
348
397
show table status like 't1';
349
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
350
 
#       test    t1      TEMPORARY       MyISAM  #       #       #       #       #
 
398
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
399
t1      MyISAM  X       Fixed   1       37      X       X       X       X       X       X       X       X       utf8_general_ci NULL            
351
400
alter table t1 modify a int;
352
401
show table status like 't1';
353
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
354
 
#       test    t1      TEMPORARY       MyISAM  #       #       #       #       #
 
402
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
403
t1      MyISAM  X       Fixed   1       37      X       X       X       X       X       X       X       X       utf8_general_ci NULL            
355
404
drop table t1;
356
 
create TEMPORARY table t1 (a int not null default 0, b int not null default 0, c int not null default 0, d int not null default 0, e int not null default 0, f int not null default 0, g int not null default 0, h int not null default 0,i int not null default 0, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
 
405
create table t1 (a int not null default 0, b int not null default 0, c int not null default 0, d int not null default 0, e int not null default 0, f int not null default 0, g int not null default 0, h int not null default 0,i int not null default 0, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
357
406
insert into t1 (a) values(1);
358
407
show table status like 't1';
359
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
360
 
#       test    t1      TEMPORARY       MyISAM  #       #       #       #       #
 
408
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
409
t1      MyISAM  X       Fixed   1       37      X       X       X       X       X       X       X       X       utf8_general_ci NULL            
361
410
drop table t1;
362
411
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
363
412
ALTER TABLE t1 DROP PRIMARY KEY;
364
413
SHOW CREATE TABLE t1;
365
414
Table   Create Table
366
415
t1      CREATE TABLE `t1` (
367
 
  `a` INT NOT NULL,
368
 
  `b` INT DEFAULT NULL,
 
416
  `a` int NOT NULL,
 
417
  `b` int DEFAULT NULL,
369
418
  UNIQUE KEY `b` (`b`)
370
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
419
) ENGINE=DEFAULT
371
420
ALTER TABLE t1 DROP PRIMARY KEY;
372
421
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
373
422
DROP TABLE t1;
377
426
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
378
427
alter table t1 drop key a;
379
428
drop table t1;
380
 
CREATE TEMPORARY TABLE T12207(a int) ENGINE=MYISAM;
 
429
CREATE TABLE T12207(a int) ENGINE=MYISAM;
381
430
ALTER TABLE T12207 DISCARD TABLESPACE;
382
431
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
383
432
DROP TABLE T12207;
388
437
drop table if exists t1;
389
438
create table t1 (a int, key(a));
390
439
show indexes from t1;
391
 
Table   Unique  Key_name        Seq_in_index    Column_name
392
 
t1      NO      a       1       a
 
440
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
441
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
393
442
"this used not to disable the index"
394
443
alter table t1 modify a int;
395
444
show indexes from t1;
396
 
Table   Unique  Key_name        Seq_in_index    Column_name
397
 
t1      NO      a       1       a
 
445
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
446
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
398
447
alter table t1 enable keys;
399
448
Warnings:
400
449
Note    1031    Table storage engine for 't1' doesn't have this option
401
450
show indexes from t1;
402
 
Table   Unique  Key_name        Seq_in_index    Column_name
403
 
t1      NO      a       1       a
 
451
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
452
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
404
453
alter table t1 modify a bigint;
405
454
show indexes from t1;
406
 
Table   Unique  Key_name        Seq_in_index    Column_name
407
 
t1      NO      a       1       a
 
455
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
456
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
408
457
alter table t1 enable keys;
409
458
Warnings:
410
459
Note    1031    Table storage engine for 't1' doesn't have this option
411
460
show indexes from t1;
412
 
Table   Unique  Key_name        Seq_in_index    Column_name
413
 
t1      NO      a       1       a
 
461
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
462
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
414
463
alter table t1 add b char(10);
415
464
show indexes from t1;
416
 
Table   Unique  Key_name        Seq_in_index    Column_name
417
 
t1      NO      a       1       a
 
465
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
466
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
418
467
alter table t1 add c decimal(10,2);
419
468
show indexes from t1;
420
 
Table   Unique  Key_name        Seq_in_index    Column_name
421
 
t1      NO      a       1       a
 
469
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
470
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
422
471
"this however did"
423
472
alter table t1;
424
473
show indexes from t1;
425
 
Table   Unique  Key_name        Seq_in_index    Column_name
426
 
t1      NO      a       1       a
 
474
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
475
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
427
476
desc t1;
428
 
Field   Type    Null    Default Default_is_NULL On_Update
429
 
a       BIGINT  YES             YES     
430
 
b       VARCHAR YES             YES     
431
 
c       DECIMAL YES             YES     
 
477
Field   Type    Null    Key     Default Extra
 
478
a       bigint  YES     MUL     NULL    
 
479
b       varchar(10)     YES             NULL    
 
480
c       decimal(10,2)   YES             NULL    
432
481
alter table t1 add d decimal(15,5);
433
482
"The key should still be disabled"
434
483
show indexes from t1;
435
 
Table   Unique  Key_name        Seq_in_index    Column_name
436
 
t1      NO      a       1       a
 
484
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
485
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
437
486
drop table t1;
438
487
"Now will test with one unique index"
439
488
create table t1(a int, b char(10), unique(a));
440
489
show indexes from t1;
441
 
Table   Unique  Key_name        Seq_in_index    Column_name
442
 
t1      YES     a       1       a
 
490
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
491
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
443
492
alter table t1;
444
493
show indexes from t1;
445
 
Table   Unique  Key_name        Seq_in_index    Column_name
446
 
t1      YES     a       1       a
 
494
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
495
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
447
496
alter table t1 enable keys;
448
497
Warnings:
449
498
Note    1031    Table storage engine for 't1' doesn't have this option
451
500
"Unique index, no change"
452
501
alter table t1 modify a int;
453
502
show indexes from t1;
454
 
Table   Unique  Key_name        Seq_in_index    Column_name
455
 
t1      YES     a       1       a
 
503
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
504
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
456
505
"Change the type implying data copy"
457
506
"Unique index, no change"
458
507
alter table t1 modify a bigint;
459
508
show indexes from t1;
460
 
Table   Unique  Key_name        Seq_in_index    Column_name
461
 
t1      YES     a       1       a
 
509
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
510
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
462
511
alter table t1 modify a bigint;
463
512
show indexes from t1;
464
 
Table   Unique  Key_name        Seq_in_index    Column_name
465
 
t1      YES     a       1       a
 
513
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
514
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
466
515
alter table t1 modify a int;
467
516
show indexes from t1;
468
 
Table   Unique  Key_name        Seq_in_index    Column_name
469
 
t1      YES     a       1       a
 
517
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
518
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
470
519
drop table t1;
471
520
"Now will test with one unique and one non-unique index"
472
521
create table t1(a int, b char(10), unique(a), key(b));
473
522
show indexes from t1;
474
 
Table   Unique  Key_name        Seq_in_index    Column_name
475
 
t1      YES     a       1       a
476
 
t1      NO      b       1       b
 
523
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
524
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
525
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
477
526
alter table t1;
478
527
show indexes from t1;
479
 
Table   Unique  Key_name        Seq_in_index    Column_name
480
 
t1      YES     a       1       a
481
 
t1      NO      b       1       b
 
528
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
529
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
530
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
482
531
alter table t1 enable keys;
483
532
Warnings:
484
533
Note    1031    Table storage engine for 't1' doesn't have this option
486
535
"The non-unique index will be disabled"
487
536
alter table t1 modify a int;
488
537
show indexes from t1;
489
 
Table   Unique  Key_name        Seq_in_index    Column_name
490
 
t1      YES     a       1       a
491
 
t1      NO      b       1       b
 
538
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
539
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
540
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
492
541
alter table t1 enable keys;
493
542
Warnings:
494
543
Note    1031    Table storage engine for 't1' doesn't have this option
495
544
show indexes from t1;
496
 
Table   Unique  Key_name        Seq_in_index    Column_name
497
 
t1      YES     a       1       a
498
 
t1      NO      b       1       b
 
545
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
546
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
547
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
499
548
"Change the type implying data copy"
500
549
"The non-unique index will be disabled"
501
550
alter table t1 modify a bigint;
502
551
show indexes from t1;
503
 
Table   Unique  Key_name        Seq_in_index    Column_name
504
 
t1      YES     a       1       a
505
 
t1      NO      b       1       b
 
552
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
553
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
554
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
506
555
"Change again the type, but leave the indexes as_is"
507
556
alter table t1 modify a int;
508
557
show indexes from t1;
509
 
Table   Unique  Key_name        Seq_in_index    Column_name
510
 
t1      YES     a       1       a
511
 
t1      NO      b       1       b
 
558
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
559
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
560
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
512
561
"Try the same. When data is no copied on similar tables, this is noop"
513
562
alter table t1 modify a int;
514
563
show indexes from t1;
515
 
Table   Unique  Key_name        Seq_in_index    Column_name
516
 
t1      YES     a       1       a
517
 
t1      NO      b       1       b
 
564
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
565
t1      0       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
566
t1      1       b       1       b       A       0       NULL    NULL    YES     BTREE           
518
567
drop table t1;
519
568
create database mysqltest;
520
569
create table t1 (c1 int);
527
576
use mysqltest;
528
577
drop database mysqltest;
529
578
alter table test.t1 rename t1;
530
 
ERROR 3D000: No schema selected
 
579
ERROR 3D000: No database selected
531
580
alter table test.t1 rename test.t1;
532
581
use test;
533
582
drop table t1;
534
 
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
 
583
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
 
584
Warnings:
 
585
Warning 1478    InnoDB: assuming ROW_FORMAT=COMPACT.
535
586
CREATE INDEX i1 ON t1(a);
536
587
SHOW CREATE TABLE t1;
537
588
Table   Create Table
538
589
t1      CREATE TABLE `t1` (
539
 
  `a` INT DEFAULT NULL,
 
590
  `a` int DEFAULT NULL,
540
591
  KEY `i1` (`a`)
541
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
592
) ENGINE=DEFAULT ROW_FORMAT=FIXED
542
593
DROP INDEX i1 ON t1;
543
594
SHOW CREATE TABLE t1;
544
595
Table   Create Table
545
596
t1      CREATE TABLE `t1` (
546
 
  `a` INT DEFAULT NULL
547
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
597
  `a` int DEFAULT NULL
 
598
) ENGINE=DEFAULT ROW_FORMAT=FIXED
548
599
DROP TABLE t1;
549
600
DROP TABLE IF EXISTS bug24219;
550
601
DROP TABLE IF EXISTS bug24219_2;
551
602
CREATE TABLE bug24219 (a INT, INDEX(a));
552
603
SHOW INDEX FROM bug24219;
553
 
Table   Unique  Key_name        Seq_in_index    Column_name
554
 
bug24219        NO      a       1       a
 
604
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
605
bug24219        1       a       1       a       A       0       NULL    NULL    YES     BTREE           
555
606
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
556
607
Warnings:
557
608
Note    1031    Table storage engine for 'bug24219' doesn't have this option
558
609
SHOW INDEX FROM bug24219_2;
559
 
Table   Unique  Key_name        Seq_in_index    Column_name
560
 
bug24219_2      NO      a       1       a
 
610
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
611
bug24219_2      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
561
612
DROP TABLE bug24219_2;
562
613
drop table if exists table_24562;
563
614
create table table_24562(
673
724
create table t1 (mycol int not null);
674
725
alter table t1 alter column mycol set default 0;
675
726
desc t1;
676
 
Field   Type    Null    Default Default_is_NULL On_Update
677
 
mycol   INTEGER NO      0       NO      
 
727
Field   Type    Null    Key     Default Extra
 
728
mycol   int     NO              0       
678
729
drop table t1;
679
 
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
 
730
create table t1(id int primary key auto_increment) engine=heap;
680
731
insert into t1 values (null);
681
732
insert into t1 values (null);
682
733
select * from t1;
691
742
1
692
743
2
693
744
50
694
 
alter table t1 engine = MEMORY;
 
745
alter table t1 engine = heap;
695
746
insert into t1 values (null);
696
747
select * from t1;
697
748
id
755
806
i       v
756
807
4       3r4f
757
808
drop table t1;
758
 
create TEMPORARY table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
 
809
create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
759
810
alter table t1 change t t text;
760
811
drop table t1;
761
 
CREATE TABLE t1 (s CHAR(8));
 
812
CREATE TABLE t1 (s CHAR(8) BINARY);
762
813
INSERT INTO t1 VALUES ('test');
763
814
SELECT LENGTH(s) FROM t1;
764
815
LENGTH(s)
765
816
4
766
 
ALTER TABLE t1 MODIFY s CHAR(10);
 
817
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
767
818
SELECT LENGTH(s) FROM t1;
768
819
LENGTH(s)
769
820
4
795
846
abc     5
796
847
DROP TABLE t1;
797
848
End of 5.0 tests
 
849
drop table if exists t1, t2, t3;
 
850
create table t1 (i int);
 
851
create table t3 (j int);
 
852
insert into t1 values ();
 
853
insert into t3 values ();
 
854
lock table t1 write, t3 read;
 
855
alter table t1 modify i int default 1;
 
856
insert into t1 values ();
 
857
select * from t1;
 
858
i
 
859
NULL
 
860
1
 
861
alter table t1 change i c char(10) default "Two";
 
862
insert into t1 values ();
 
863
select * from t1;
 
864
c
 
865
NULL
 
866
1
 
867
Two
 
868
alter table t1 modify c char(10) default "Three", rename to t2;
 
869
select * from t1;
 
870
ERROR HY000: Table 't1' was not locked with LOCK TABLES
 
871
select * from t2;
 
872
ERROR HY000: Table 't2' was not locked with LOCK TABLES
 
873
select * from t3;
 
874
j
 
875
NULL
 
876
unlock tables;
 
877
insert into t2 values ();
 
878
select * from t2;
 
879
c
 
880
NULL
 
881
1
 
882
Two
 
883
Three
 
884
lock table t2 write, t3 read;
 
885
alter table t2 change c vc varchar(100) default "Four", rename to t1;
 
886
select * from t1;
 
887
ERROR HY000: Table 't1' was not locked with LOCK TABLES
 
888
select * from t2;
 
889
ERROR HY000: Table 't2' was not locked with LOCK TABLES
 
890
select * from t3;
 
891
j
 
892
NULL
 
893
unlock tables;
 
894
insert into t1 values ();
 
895
select * from t1;
 
896
vc
 
897
NULL
 
898
1
 
899
Two
 
900
Three
 
901
Four
 
902
drop tables t1, t3;
798
903
DROP TABLE IF EXISTS `t+1`, `t+2`;
799
904
CREATE TABLE `t+1` (c1 INT);
800
905
ALTER TABLE  `t+1` RENAME `t+2`;
801
906
CREATE TABLE `t+1` (c1 INT);
802
907
ALTER TABLE  `t+1` RENAME `t+2`;
803
 
ERROR 42S01: Table 'test.t+2' already exists
 
908
ERROR 42S01: Table 't+2' already exists
804
909
DROP TABLE   `t+1`, `t+2`;
805
910
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
806
911
ALTER TABLE  `tt+1` RENAME `tt+2`;
807
912
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
808
913
ALTER TABLE  `tt+1` RENAME `tt+2`;
809
 
ERROR 42S01: Table 'test.#tt+2' already exists
 
914
ERROR 42S01: Table 'tt+2' already exists
810
915
SHOW CREATE TABLE `tt+1`;
811
916
Table   Create Table
812
917
tt+1    CREATE TEMPORARY TABLE `tt+1` (
813
 
  `c1` INT DEFAULT NULL
814
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
918
  `c1` int DEFAULT NULL
 
919
) ENGINE=DEFAULT
815
920
SHOW CREATE TABLE `tt+2`;
816
921
Table   Create Table
817
922
tt+2    CREATE TEMPORARY TABLE `tt+2` (
818
 
  `c1` INT DEFAULT NULL
819
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
923
  `c1` int DEFAULT NULL
 
924
) ENGINE=DEFAULT
820
925
DROP TABLE   `tt+1`, `tt+2`;
821
926
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
927
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
823
928
SHOW TABLES;
824
929
Tables_in_test
825
 
#sql1
826
 
@0023sql2
827
930
ALTER TABLE `#sql1`      RENAME `@0023sql1`;
828
931
ALTER TABLE `@0023sql2`  RENAME `#sql2`;
829
932
SHOW TABLES;
830
933
Tables_in_test
831
 
#sql2
832
 
@0023sql1
833
934
INSERT INTO `#sql2`      VALUES (1);
834
935
INSERT INTO `@0023sql1`  VALUES (2);
835
936
SHOW CREATE TABLE `#sql2`;
836
937
Table   Create Table
837
938
#sql2   CREATE TEMPORARY TABLE `#sql2` (
838
 
  `c1` INT DEFAULT NULL
839
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
939
  `c1` int DEFAULT NULL
 
940
) ENGINE=DEFAULT
840
941
SHOW CREATE TABLE `@0023sql1`;
841
942
Table   Create Table
842
943
@0023sql1       CREATE TEMPORARY TABLE `@0023sql1` (
843
 
  `c1` INT DEFAULT NULL
844
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
944
  `c1` int DEFAULT NULL
 
945
) ENGINE=DEFAULT
845
946
DROP TABLE `#sql2`, `@0023sql1`;
846
947
DROP TABLE IF EXISTS t1;
847
948
DROP TABLE IF EXISTS t2;
851
952
INDEX(`int_field`)
852
953
);
853
954
DESCRIBE t1;
854
 
Field   Type    Null    Default Default_is_NULL On_Update
855
 
int_field       INTEGER NO              NO      
856
 
char_field      VARCHAR YES             YES     
 
955
Field   Type    Null    Key     Default Extra
 
956
int_field       int     NO      MUL     NULL    
 
957
char_field      varchar(10)     YES             NULL    
857
958
SHOW INDEXES FROM t1;
858
 
Table   Unique  Key_name        Seq_in_index    Column_name
859
 
t1      NO      int_field       1       int_field
 
959
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
960
t1      1       int_field       1       int_field       A       0       NULL    NULL            BTREE           
860
961
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
962
"Non-copy data change - new frm, but old data and index files"
862
963
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
870
971
3       tri
871
972
5       pet
872
973
DESCRIBE t2;
873
 
Field   Type    Null    Default Default_is_NULL On_Update
874
 
unsigned_int_field      INTEGER NO              NO      
875
 
char_field      VARCHAR YES             YES     
 
974
Field   Type    Null    Key     Default Extra
 
975
unsigned_int_field      int     NO      MUL     NULL    
 
976
char_field      varchar(10)     YES             NULL    
876
977
DESCRIBE t2;
877
 
Field   Type    Null    Default Default_is_NULL On_Update
878
 
unsigned_int_field      INTEGER NO              NO      
879
 
char_field      VARCHAR YES             YES     
 
978
Field   Type    Null    Key     Default Extra
 
979
unsigned_int_field      int     NO      MUL     NULL    
 
980
char_field      varchar(10)     YES             NULL    
880
981
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
881
982
DESCRIBE t2;
882
 
Field   Type    Null    Default Default_is_NULL On_Update
883
 
unsigned_int_field      BIGINT  NO              NO      
884
 
char_field      VARCHAR YES             YES     
 
983
Field   Type    Null    Key     Default Extra
 
984
unsigned_int_field      bigint  NO      MUL     NULL    
 
985
char_field      varchar(10)     YES             NULL    
885
986
DROP TABLE t2;
886
987
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
988
INSERT INTO t1 VALUES (1, 2, NULL);
897
998
f1      f2      f3
898
999
1       2       NULL
899
1000
DROP TABLE t1;
 
1001
create table t1 (c char(10) default "Two");
 
1002
lock table t1 write;
 
1003
insert into t1 values ();
 
1004
alter table t1 modify c char(10) default "Three";
 
1005
unlock tables;
 
1006
select * from t1;
 
1007
c
 
1008
Two
 
1009
check table t1;
 
1010
Table   Op      Msg_type        Msg_text
 
1011
test.t1 check   status  OK
 
1012
drop table t1;