~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/alter_table.result

code clean move Item_func_abs, Item_func_int_exp, Item_func_ln, Item_func_log to functions directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
PRIMARY KEY (GROUP_ID,LANG_ID),
51
51
KEY NAME (NAME));
52
52
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
53
 
show COLUMNS FROM t1;
54
 
Field   Type    Null    Default Default_is_NULL On_Update
55
 
GROUP_ID        INTEGER FALSE   0       FALSE   
56
 
LANG_ID INTEGER FALSE   0       FALSE   
57
 
NAME    VARCHAR FALSE           FALSE   
 
53
SHOW FULL COLUMNS FROM t1;
 
54
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
55
GROUP_ID        int     NULL    NO      PRI     NULL            #       
 
56
LANG_ID int     NULL    NO      PRI     NULL            #       
 
57
NAME    varchar(80)     utf8_general_ci NO      MUL     NULL            #       
58
58
DROP TABLE t1;
59
59
create table t1 (n int);
60
60
insert into t1 values(9),(3),(12),(10);
66
66
10
67
67
12
68
68
drop table t1;
69
 
CREATE TEMPORARY TABLE t1 (
 
69
CREATE TABLE t1 (
70
70
id int NOT NULL default '0',
71
71
category_id int NOT NULL default '0',
72
72
type_id int NOT NULL default '0',
77
77
) ENGINE=MyISAM;
78
78
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
79
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;
80
89
create table t1 (i int not null auto_increment primary key);
81
90
insert into t1 values (null),(null),(null),(null);
82
91
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
99
108
name
100
109
mysqltest
101
110
alter table t1 rename mysqltest.t1;
102
 
ERROR 42S01: Table 'mysqltest.t1' already exists
 
111
ERROR 42S01: Table 't1' already exists
103
112
select * from t1;
104
113
name
105
114
current
116
125
key (n4, n1, n2, n3) );
117
126
alter table t1;
118
127
show keys from t1;
119
 
Table   Unique  Key_name        Seq_in_index    Column_name
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
 
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           
137
146
set autocommit=0;
138
147
begin;
139
148
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
152
161
Warnings:
153
162
Note    1031    Table storage engine for 't1' doesn't have this option
154
163
show keys from t1;
155
 
Table   Unique  Key_name        Seq_in_index    Column_name
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
 
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           
173
182
drop table t1;
174
183
create table t1 (i int not null auto_increment primary key);
175
184
alter table t1 rename t2;
176
185
alter table t2 rename t1, add c char(10) comment "no comment";
177
186
show columns from t1;
178
 
Field   Type    Null    Default Default_is_NULL On_Update
179
 
i       INTEGER FALSE   0       FALSE   
180
 
c       VARCHAR TRUE            TRUE    
 
187
Field   Type    Null    Key     Default Extra
 
188
i       int     NO      PRI     NULL    auto_increment
 
189
c       varchar(10)     YES             NULL    
181
190
drop table t1;
182
191
create table t1 (a int, b int);
183
192
set autocommit=0;
286
295
set autocommit=1;
287
296
alter table t1 add unique (a,b), add key (b);
288
297
show keys from t1;
289
 
Table   Unique  Key_name        Seq_in_index    Column_name
290
 
t1      TRUE    a       1       a
291
 
t1      TRUE    a       2       b
292
 
t1      FALSE   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           
293
302
analyze table t1;
294
303
Table   Op      Msg_type        Msg_text
295
304
test.t1 analyze status  OK
296
305
show keys from t1;
297
 
Table   Unique  Key_name        Seq_in_index    Column_name
298
 
t1      TRUE    a       1       a
299
 
t1      TRUE    a       2       b
300
 
t1      FALSE   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           
301
310
drop table t1;
302
 
CREATE TEMPORARY TABLE t1 (
303
 
Host varchar(16) NOT NULL default '',
304
 
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 '',
305
332
PRIMARY KEY  (Host,User),
306
333
KEY  (Host)
307
334
) ENGINE=MyISAM;
308
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;
309
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        
310
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;
311
355
CHECK TABLES t1;
312
356
Table   Op      Msg_type        Msg_text
313
357
test.t1 check   status  OK
 
358
LOCK TABLES t1 WRITE;
314
359
ALTER TABLE t1 RENAME t2;
 
360
UNLOCK TABLES;
315
361
select * from t2;
316
362
Host    User
317
363
localhost       
318
364
localhost       root
319
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;
320
380
create table t1 (a int);
321
381
alter table t1 rename to ``;
322
382
ERROR 42000: Incorrect table name ''
326
386
drop table if exists t1;
327
387
Warnings:
328
388
Note    1051    Unknown table 't1'
329
 
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;
330
390
flush tables;
331
391
alter table t1 modify a varchar(10);
332
392
flush tables;
333
393
alter table t1 modify a varchar(10) not null;
334
394
drop table if exists t1;
335
 
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;
336
 
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
 
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;
 
396
insert into t1 (a) values(1);
337
397
show table status like 't1';
338
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
339
 
#       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  10      Fixed   1       37      X       X       X       X       X       X       X       X       utf8_general_ci NULL            
340
400
alter table t1 modify a int;
341
401
show table status like 't1';
342
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
343
 
#       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  10      Fixed   1       37      X       X       X       X       X       X       X       X       utf8_general_ci NULL            
344
404
drop table t1;
345
 
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;
346
406
insert into t1 (a) values(1);
347
407
show table status like 't1';
348
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
349
 
#       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  10      Fixed   1       37      X       X       X       X       X       X       X       X       utf8_general_ci NULL            
350
410
drop table t1;
351
411
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
352
412
ALTER TABLE t1 DROP PRIMARY KEY;
354
414
Table   Create Table
355
415
t1      CREATE TABLE `t1` (
356
416
  `a` int NOT NULL,
357
 
  `b` int DEFAULT NULL,
 
417
  `b` int,
358
418
  UNIQUE KEY `b` (`b`)
359
 
) ENGINE=DEFAULT
 
419
) ENGINE=InnoDB
360
420
ALTER TABLE t1 DROP PRIMARY KEY;
361
421
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
362
422
DROP TABLE t1;
366
426
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
367
427
alter table t1 drop key a;
368
428
drop table t1;
369
 
CREATE TEMPORARY TABLE T12207(a int) ENGINE=MYISAM;
 
429
CREATE TABLE T12207(a int) ENGINE=MYISAM;
370
430
ALTER TABLE T12207 DISCARD TABLESPACE;
371
431
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
372
432
DROP TABLE T12207;
377
437
drop table if exists t1;
378
438
create table t1 (a int, key(a));
379
439
show indexes from t1;
380
 
Table   Unique  Key_name        Seq_in_index    Column_name
381
 
t1      FALSE   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           
382
442
"this used not to disable the index"
383
443
alter table t1 modify a int;
384
444
show indexes from t1;
385
 
Table   Unique  Key_name        Seq_in_index    Column_name
386
 
t1      FALSE   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           
387
447
alter table t1 enable keys;
388
448
Warnings:
389
449
Note    1031    Table storage engine for 't1' doesn't have this option
390
450
show indexes from t1;
391
 
Table   Unique  Key_name        Seq_in_index    Column_name
392
 
t1      FALSE   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           
393
453
alter table t1 modify a bigint;
394
454
show indexes from t1;
395
 
Table   Unique  Key_name        Seq_in_index    Column_name
396
 
t1      FALSE   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           
397
457
alter table t1 enable keys;
398
458
Warnings:
399
459
Note    1031    Table storage engine for 't1' doesn't have this option
400
460
show indexes from t1;
401
 
Table   Unique  Key_name        Seq_in_index    Column_name
402
 
t1      FALSE   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           
403
463
alter table t1 add b char(10);
404
464
show indexes from t1;
405
 
Table   Unique  Key_name        Seq_in_index    Column_name
406
 
t1      FALSE   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           
407
467
alter table t1 add c decimal(10,2);
408
468
show indexes from t1;
409
 
Table   Unique  Key_name        Seq_in_index    Column_name
410
 
t1      FALSE   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           
411
471
"this however did"
412
472
alter table t1;
413
473
show indexes from t1;
414
 
Table   Unique  Key_name        Seq_in_index    Column_name
415
 
t1      FALSE   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           
416
476
desc t1;
417
 
Field   Type    Null    Default Default_is_NULL On_Update
418
 
a       BIGINT  TRUE            TRUE    
419
 
b       VARCHAR TRUE            TRUE    
420
 
c       DECIMAL TRUE            TRUE    
 
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    
421
481
alter table t1 add d decimal(15,5);
422
482
"The key should still be disabled"
423
483
show indexes from t1;
424
 
Table   Unique  Key_name        Seq_in_index    Column_name
425
 
t1      FALSE   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           
426
486
drop table t1;
427
487
"Now will test with one unique index"
428
488
create table t1(a int, b char(10), unique(a));
429
489
show indexes from t1;
430
 
Table   Unique  Key_name        Seq_in_index    Column_name
431
 
t1      TRUE    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           
432
492
alter table t1;
433
493
show indexes from t1;
434
 
Table   Unique  Key_name        Seq_in_index    Column_name
435
 
t1      TRUE    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           
436
496
alter table t1 enable keys;
437
497
Warnings:
438
498
Note    1031    Table storage engine for 't1' doesn't have this option
440
500
"Unique index, no change"
441
501
alter table t1 modify a int;
442
502
show indexes from t1;
443
 
Table   Unique  Key_name        Seq_in_index    Column_name
444
 
t1      TRUE    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           
445
505
"Change the type implying data copy"
446
506
"Unique index, no change"
447
507
alter table t1 modify a bigint;
448
508
show indexes from t1;
449
 
Table   Unique  Key_name        Seq_in_index    Column_name
450
 
t1      TRUE    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           
451
511
alter table t1 modify a bigint;
452
512
show indexes from t1;
453
 
Table   Unique  Key_name        Seq_in_index    Column_name
454
 
t1      TRUE    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           
455
515
alter table t1 modify a int;
456
516
show indexes from t1;
457
 
Table   Unique  Key_name        Seq_in_index    Column_name
458
 
t1      TRUE    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           
459
519
drop table t1;
460
520
"Now will test with one unique and one non-unique index"
461
521
create table t1(a int, b char(10), unique(a), key(b));
462
522
show indexes from t1;
463
 
Table   Unique  Key_name        Seq_in_index    Column_name
464
 
t1      TRUE    a       1       a
465
 
t1      FALSE   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           
466
526
alter table t1;
467
527
show indexes from t1;
468
 
Table   Unique  Key_name        Seq_in_index    Column_name
469
 
t1      TRUE    a       1       a
470
 
t1      FALSE   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           
471
531
alter table t1 enable keys;
472
532
Warnings:
473
533
Note    1031    Table storage engine for 't1' doesn't have this option
475
535
"The non-unique index will be disabled"
476
536
alter table t1 modify a int;
477
537
show indexes from t1;
478
 
Table   Unique  Key_name        Seq_in_index    Column_name
479
 
t1      TRUE    a       1       a
480
 
t1      FALSE   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           
481
541
alter table t1 enable keys;
482
542
Warnings:
483
543
Note    1031    Table storage engine for 't1' doesn't have this option
484
544
show indexes from t1;
485
 
Table   Unique  Key_name        Seq_in_index    Column_name
486
 
t1      TRUE    a       1       a
487
 
t1      FALSE   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           
488
548
"Change the type implying data copy"
489
549
"The non-unique index will be disabled"
490
550
alter table t1 modify a bigint;
491
551
show indexes from t1;
492
 
Table   Unique  Key_name        Seq_in_index    Column_name
493
 
t1      TRUE    a       1       a
494
 
t1      FALSE   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           
495
555
"Change again the type, but leave the indexes as_is"
496
556
alter table t1 modify a int;
497
557
show indexes from t1;
498
 
Table   Unique  Key_name        Seq_in_index    Column_name
499
 
t1      TRUE    a       1       a
500
 
t1      FALSE   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           
501
561
"Try the same. When data is no copied on similar tables, this is noop"
502
562
alter table t1 modify a int;
503
563
show indexes from t1;
504
 
Table   Unique  Key_name        Seq_in_index    Column_name
505
 
t1      TRUE    a       1       a
506
 
t1      FALSE   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           
507
567
drop table t1;
508
568
create database mysqltest;
509
569
create table t1 (c1 int);
520
580
alter table test.t1 rename test.t1;
521
581
use test;
522
582
drop table t1;
523
 
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
 
583
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
524
584
CREATE INDEX i1 ON t1(a);
525
585
SHOW CREATE TABLE t1;
526
586
Table   Create Table
527
587
t1      CREATE TABLE `t1` (
528
 
  `a` int DEFAULT NULL,
 
588
  `a` int,
529
589
  KEY `i1` (`a`)
530
 
) ENGINE=DEFAULT ROW_FORMAT=COMPACT
 
590
) ENGINE=InnoDB ROW_FORMAT=FIXED
531
591
DROP INDEX i1 ON t1;
532
592
SHOW CREATE TABLE t1;
533
593
Table   Create Table
534
594
t1      CREATE TABLE `t1` (
535
 
  `a` int DEFAULT NULL
536
 
) ENGINE=DEFAULT ROW_FORMAT=COMPACT
 
595
  `a` int
 
596
) ENGINE=InnoDB ROW_FORMAT=FIXED
537
597
DROP TABLE t1;
538
598
DROP TABLE IF EXISTS bug24219;
539
599
DROP TABLE IF EXISTS bug24219_2;
540
600
CREATE TABLE bug24219 (a INT, INDEX(a));
541
601
SHOW INDEX FROM bug24219;
542
 
Table   Unique  Key_name        Seq_in_index    Column_name
543
 
bug24219        FALSE   a       1       a
 
602
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
603
bug24219        1       a       1       a       A       0       NULL    NULL    YES     BTREE           
544
604
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
545
605
Warnings:
546
606
Note    1031    Table storage engine for 'bug24219' doesn't have this option
547
607
SHOW INDEX FROM bug24219_2;
548
 
Table   Unique  Key_name        Seq_in_index    Column_name
549
 
bug24219_2      FALSE   a       1       a
 
608
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
609
bug24219_2      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
550
610
DROP TABLE bug24219_2;
551
611
drop table if exists table_24562;
552
612
create table table_24562(
651
711
3       3       Stored Functions        You
652
712
2       3       Server  Me
653
713
alter table table_24562 order by 12;
654
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '12' at line 1
 
714
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '12' at line 1
655
715
alter table table_24562 order by (section + 12);
656
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '(section + 12)' at line 1
 
716
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(section + 12)' at line 1
657
717
alter table table_24562 order by length(title);
658
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '(title)' at line 1
 
718
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(title)' at line 1
659
719
alter table table_24562 order by no_such_col;
660
720
ERROR 42S22: Unknown column 'no_such_col' in 'order clause'
661
721
drop table table_24562;
662
722
create table t1 (mycol int not null);
663
723
alter table t1 alter column mycol set default 0;
664
724
desc t1;
665
 
Field   Type    Null    Default Default_is_NULL On_Update
666
 
mycol   INTEGER FALSE   0       FALSE   
 
725
Field   Type    Null    Key     Default Extra
 
726
mycol   int     NO              NULL    
667
727
drop table t1;
668
 
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
 
728
create table t1(id int primary key auto_increment) engine=heap;
669
729
insert into t1 values (null);
670
730
insert into t1 values (null);
671
731
select * from t1;
680
740
1
681
741
2
682
742
50
683
 
alter table t1 engine = MEMORY;
 
743
alter table t1 engine = heap;
684
744
insert into t1 values (null);
685
745
select * from t1;
686
746
id
744
804
i       v
745
805
4       3r4f
746
806
drop table t1;
747
 
create TEMPORARY table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
 
807
create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
748
808
alter table t1 change t t text;
749
809
drop table t1;
750
 
CREATE TABLE t1 (s CHAR(8));
 
810
CREATE TABLE t1 (s CHAR(8) BINARY);
751
811
INSERT INTO t1 VALUES ('test');
752
812
SELECT LENGTH(s) FROM t1;
753
813
LENGTH(s)
754
814
4
755
 
ALTER TABLE t1 MODIFY s CHAR(10);
 
815
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
756
816
SELECT LENGTH(s) FROM t1;
757
817
LENGTH(s)
758
818
4
784
844
abc     5
785
845
DROP TABLE t1;
786
846
End of 5.0 tests
 
847
drop table if exists t1, t2, t3;
 
848
create table t1 (i int);
 
849
create table t3 (j int);
 
850
insert into t1 values ();
 
851
insert into t3 values ();
 
852
lock table t1 write, t3 read;
 
853
alter table t1 modify i int default 1;
 
854
insert into t1 values ();
 
855
select * from t1;
 
856
i
 
857
NULL
 
858
1
 
859
alter table t1 change i c char(10) default "Two";
 
860
insert into t1 values ();
 
861
select * from t1;
 
862
c
 
863
NULL
 
864
1
 
865
Two
 
866
alter table t1 modify c char(10) default "Three", rename to t2;
 
867
select * from t1;
 
868
ERROR HY000: Table 't1' was not locked with LOCK TABLES
 
869
select * from t2;
 
870
ERROR HY000: Table 't2' was not locked with LOCK TABLES
 
871
select * from t3;
 
872
j
 
873
NULL
 
874
unlock tables;
 
875
insert into t2 values ();
 
876
select * from t2;
 
877
c
 
878
NULL
 
879
1
 
880
Two
 
881
Three
 
882
lock table t2 write, t3 read;
 
883
alter table t2 change c vc varchar(100) default "Four", rename to t1;
 
884
select * from t1;
 
885
ERROR HY000: Table 't1' was not locked with LOCK TABLES
 
886
select * from t2;
 
887
ERROR HY000: Table 't2' was not locked with LOCK TABLES
 
888
select * from t3;
 
889
j
 
890
NULL
 
891
unlock tables;
 
892
insert into t1 values ();
 
893
select * from t1;
 
894
vc
 
895
NULL
 
896
1
 
897
Two
 
898
Three
 
899
Four
 
900
drop tables t1, t3;
787
901
DROP TABLE IF EXISTS `t+1`, `t+2`;
788
902
CREATE TABLE `t+1` (c1 INT);
789
903
ALTER TABLE  `t+1` RENAME `t+2`;
790
904
CREATE TABLE `t+1` (c1 INT);
791
905
ALTER TABLE  `t+1` RENAME `t+2`;
792
 
ERROR 42S01: Table 'test.t+2' already exists
 
906
ERROR 42S01: Table 't+2' already exists
793
907
DROP TABLE   `t+1`, `t+2`;
794
908
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
795
909
ALTER TABLE  `tt+1` RENAME `tt+2`;
796
910
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
797
911
ALTER TABLE  `tt+1` RENAME `tt+2`;
798
 
ERROR 42S01: Table 'test.#tt+2' already exists
 
912
ERROR 42S01: Table 'tt+2' already exists
799
913
SHOW CREATE TABLE `tt+1`;
800
914
Table   Create Table
801
915
tt+1    CREATE TEMPORARY TABLE `tt+1` (
802
 
  `c1` int DEFAULT NULL
803
 
) ENGINE=DEFAULT
 
916
  `c1` int
 
917
) ENGINE=InnoDB
804
918
SHOW CREATE TABLE `tt+2`;
805
919
Table   Create Table
806
920
tt+2    CREATE TEMPORARY TABLE `tt+2` (
807
 
  `c1` int DEFAULT NULL
808
 
) ENGINE=DEFAULT
 
921
  `c1` int
 
922
) ENGINE=InnoDB
809
923
DROP TABLE   `tt+1`, `tt+2`;
810
924
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
811
925
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
812
926
SHOW TABLES;
813
927
Tables_in_test
814
 
#sql1
815
 
@0023sql2
816
928
ALTER TABLE `#sql1`      RENAME `@0023sql1`;
817
929
ALTER TABLE `@0023sql2`  RENAME `#sql2`;
818
930
SHOW TABLES;
819
931
Tables_in_test
820
 
#sql2
821
 
@0023sql1
822
932
INSERT INTO `#sql2`      VALUES (1);
823
933
INSERT INTO `@0023sql1`  VALUES (2);
824
934
SHOW CREATE TABLE `#sql2`;
825
935
Table   Create Table
826
936
#sql2   CREATE TEMPORARY TABLE `#sql2` (
827
 
  `c1` int DEFAULT NULL
828
 
) ENGINE=DEFAULT
 
937
  `c1` int
 
938
) ENGINE=InnoDB
829
939
SHOW CREATE TABLE `@0023sql1`;
830
940
Table   Create Table
831
941
@0023sql1       CREATE TEMPORARY TABLE `@0023sql1` (
832
 
  `c1` int DEFAULT NULL
833
 
) ENGINE=DEFAULT
 
942
  `c1` int
 
943
) ENGINE=InnoDB
834
944
DROP TABLE `#sql2`, `@0023sql1`;
835
945
DROP TABLE IF EXISTS t1;
836
946
DROP TABLE IF EXISTS t2;
840
950
INDEX(`int_field`)
841
951
);
842
952
DESCRIBE t1;
843
 
Field   Type    Null    Default Default_is_NULL On_Update
844
 
int_field       INTEGER FALSE           FALSE   
845
 
char_field      VARCHAR TRUE            TRUE    
 
953
Field   Type    Null    Key     Default Extra
 
954
int_field       int     NO      MUL     NULL    
 
955
char_field      varchar(10)     YES             NULL    
846
956
SHOW INDEXES FROM t1;
847
 
Table   Unique  Key_name        Seq_in_index    Column_name
848
 
t1      FALSE   int_field       1       int_field
 
957
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
958
t1      1       int_field       1       int_field       A       0       NULL    NULL            BTREE           
849
959
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
850
960
"Non-copy data change - new frm, but old data and index files"
851
961
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
859
969
3       tri
860
970
5       pet
861
971
DESCRIBE t2;
862
 
Field   Type    Null    Default Default_is_NULL On_Update
863
 
unsigned_int_field      INTEGER FALSE           FALSE   
864
 
char_field      VARCHAR TRUE            TRUE    
 
972
Field   Type    Null    Key     Default Extra
 
973
unsigned_int_field      int     NO      MUL     NULL    
 
974
char_field      varchar(10)     YES             NULL    
865
975
DESCRIBE t2;
866
 
Field   Type    Null    Default Default_is_NULL On_Update
867
 
unsigned_int_field      INTEGER FALSE           FALSE   
868
 
char_field      VARCHAR TRUE            TRUE    
 
976
Field   Type    Null    Key     Default Extra
 
977
unsigned_int_field      int     NO      MUL     NULL    
 
978
char_field      varchar(10)     YES             NULL    
869
979
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
870
980
DESCRIBE t2;
871
 
Field   Type    Null    Default Default_is_NULL On_Update
872
 
unsigned_int_field      BIGINT  FALSE           FALSE   
873
 
char_field      VARCHAR TRUE            TRUE    
 
981
Field   Type    Null    Key     Default Extra
 
982
unsigned_int_field      bigint  NO      MUL     NULL    
 
983
char_field      varchar(10)     YES             NULL    
874
984
DROP TABLE t2;
875
985
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
876
986
INSERT INTO t1 VALUES (1, 2, NULL);
886
996
f1      f2      f3
887
997
1       2       NULL
888
998
DROP TABLE t1;
 
999
create table t1 (c char(10) default "Two");
 
1000
lock table t1 write;
 
1001
insert into t1 values ();
 
1002
alter table t1 modify c char(10) default "Three";
 
1003
unlock tables;
 
1004
select * from t1;
 
1005
c
 
1006
Two
 
1007
check table t1;
 
1008
Table   Op      Msg_type        Msg_text
 
1009
test.t1 check   status  OK
 
1010
drop table t1;