~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/r/alter_table.result

  • Committer: Brian Aker
  • Date: 2008-07-01 20:14:24 UTC
  • Revision ID: brian@tangent.org-20080701201424-rsof5enxl7gkr50p
More cleanup on pread()

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
col6    col1    col3    fourth  col4    col4_5  col5    col7    col8
19
19
1       2       3       4       5               PENDING         0000-00-00 00:00:00
20
20
drop table t1;
21
 
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
 
21
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
22
22
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
23
 
alter table t1 add column new_col int;
 
23
alter table t1 add column new_col int, order by payoutid,bandid;
24
24
select * from t1;
25
25
bandID  payoutID        new_col
 
26
6       1       NULL
 
27
3       4       NULL
26
28
1       6       NULL
27
29
2       6       NULL
28
 
3       4       NULL
29
30
4       9       NULL
30
31
5       10      NULL
31
 
6       1       NULL
32
32
7       12      NULL
33
33
8       12      NULL
34
 
alter table t1;
 
34
alter table t1 order by bandid,payoutid;
35
35
select * from t1;
36
36
bandID  payoutID        new_col
37
37
1       6       NULL
44
44
8       12      NULL
45
45
drop table t1;
46
46
CREATE TABLE t1 (
47
 
GROUP_ID int DEFAULT '0' NOT NULL,
48
 
LANG_ID int DEFAULT '0' NOT NULL,
 
47
GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
 
48
LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
49
49
NAME varchar(80) DEFAULT '' NOT NULL,
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
53
SHOW FULL COLUMNS FROM t1;
54
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            #       
 
55
GROUP_ID        int(10) unsigned        NULL    NO      PRI     0               #       
 
56
LANG_ID smallint(5) unsigned    NULL    NO      PRI     0               #       
 
57
NAME    char(80)        latin1_swedish_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);
67
67
12
68
68
drop table t1;
69
69
CREATE TABLE t1 (
70
 
id int NOT NULL default '0',
71
 
category_id int NOT NULL default '0',
72
 
type_id int NOT NULL default '0',
 
70
id int(11) unsigned NOT NULL default '0',
 
71
category_id tinyint(4) unsigned NOT NULL default '0',
 
72
type_id tinyint(4) unsigned NOT NULL default '0',
73
73
body text NOT NULL,
74
 
user_id int NOT NULL default '0',
 
74
user_id int(11) unsigned NOT NULL default '0',
75
75
status enum('new','old') NOT NULL default 'new',
76
76
PRIMARY KEY (id)
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;
 
80
CREATE TABLE t1 (AnamneseId int(10) unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
81
81
insert into t1 values (null,"hello");
82
82
LOCK TABLES t1 WRITE;
83
83
ALTER TABLE t1 ADD Column new_col int not null;
86
86
Table   Op      Msg_type        Msg_text
87
87
test.t1 optimize        status  OK
88
88
DROP TABLE t1;
89
 
create table t1 (i int not null auto_increment primary key);
 
89
create table t1 (i int unsigned not null auto_increment primary key);
90
90
insert into t1 values (null),(null),(null),(null);
91
 
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
 
91
alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
92
92
select * from t1;
93
93
i
94
94
1
123
123
key (n2, n3, n4, n1),
124
124
key (n3, n4, n1, n2),
125
125
key (n4, n1, n2, n3) );
126
 
alter table t1;
 
126
alter table t1 disable keys;
127
127
show keys from t1;
128
128
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
129
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           
146
 
set autocommit=0;
147
 
begin;
 
130
t1      1       n1_2    1       n1      A       NULL    NULL    NULL            BTREE   disabled        
 
131
t1      1       n1_2    2       n2      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
132
t1      1       n1_2    3       n3      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
133
t1      1       n1_2    4       n4      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
134
t1      1       n2      1       n2      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
135
t1      1       n2      2       n3      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
136
t1      1       n2      3       n4      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
137
t1      1       n2      4       n1      A       NULL    NULL    NULL            BTREE   disabled        
 
138
t1      1       n3      1       n3      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
139
t1      1       n3      2       n4      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
140
t1      1       n3      3       n1      A       NULL    NULL    NULL            BTREE   disabled        
 
141
t1      1       n3      4       n2      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
142
t1      1       n4      1       n4      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
143
t1      1       n4      2       n1      A       NULL    NULL    NULL            BTREE   disabled        
 
144
t1      1       n4      3       n2      A       NULL    NULL    NULL    YES     BTREE   disabled        
 
145
t1      1       n4      4       n3      A       NULL    NULL    NULL    YES     BTREE   disabled        
148
146
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
149
147
insert into t1 values(9,RAND()*1000,RAND()*1000,RAND());
150
148
insert into t1 values(8,RAND()*1000,RAND()*1000,RAND());
155
153
insert into t1 values(3,RAND()*1000,RAND()*1000,RAND());
156
154
insert into t1 values(2,RAND()*1000,RAND()*1000,RAND());
157
155
insert into t1 values(1,RAND()*1000,RAND()*1000,RAND());
158
 
commit;
159
 
set autocommit=1;
160
156
alter table t1 enable keys;
161
 
Warnings:
162
 
Note    1031    Table storage engine for 't1' doesn't have this option
163
157
show keys from t1;
164
158
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           
 
159
t1      0       n1      1       n1      A       10      NULL    NULL            BTREE           
 
160
t1      1       n1_2    1       n1      A       10      NULL    NULL            BTREE           
 
161
t1      1       n1_2    2       n2      A       10      NULL    NULL    YES     BTREE           
 
162
t1      1       n1_2    3       n3      A       10      NULL    NULL    YES     BTREE           
 
163
t1      1       n1_2    4       n4      A       10      NULL    NULL    YES     BTREE           
 
164
t1      1       n2      1       n2      A       10      NULL    NULL    YES     BTREE           
 
165
t1      1       n2      2       n3      A       10      NULL    NULL    YES     BTREE           
 
166
t1      1       n2      3       n4      A       10      NULL    NULL    YES     BTREE           
 
167
t1      1       n2      4       n1      A       10      NULL    NULL            BTREE           
 
168
t1      1       n3      1       n3      A       10      NULL    NULL    YES     BTREE           
 
169
t1      1       n3      2       n4      A       10      NULL    NULL    YES     BTREE           
 
170
t1      1       n3      3       n1      A       10      NULL    NULL            BTREE           
 
171
t1      1       n3      4       n2      A       10      NULL    NULL    YES     BTREE           
 
172
t1      1       n4      1       n4      A       10      NULL    NULL    YES     BTREE           
 
173
t1      1       n4      2       n1      A       10      NULL    NULL            BTREE           
 
174
t1      1       n4      3       n2      A       10      NULL    NULL    YES     BTREE           
 
175
t1      1       n4      4       n3      A       10      NULL    NULL    YES     BTREE           
182
176
drop table t1;
183
 
create table t1 (i int not null auto_increment primary key);
 
177
create table t1 (i int unsigned not null auto_increment primary key);
184
178
alter table t1 rename t2;
185
179
alter table t2 rename t1, add c char(10) comment "no comment";
186
180
show columns from t1;
187
181
Field   Type    Null    Key     Default Extra
188
 
i       int     NO      PRI     NULL    auto_increment
189
 
c       varchar(10)     YES             NULL    
 
182
i       int(10) unsigned        NO      PRI     NULL    auto_increment
 
183
c       char(10)        YES             NULL    
190
184
drop table t1;
191
185
create table t1 (a int, b int);
192
 
set autocommit=0;
193
 
begin;
194
186
insert into t1 values(1,100), (2,100), (3, 100);
195
187
insert into t1 values(1,99), (2,99), (3, 99);
196
188
insert into t1 values(1,98), (2,98), (3, 98);
291
283
insert into t1 values(1,3), (2,3), (3, 3);
292
284
insert into t1 values(1,2), (2,2), (3, 2);
293
285
insert into t1 values(1,1), (2,1), (3, 1);
294
 
commit;
295
 
set autocommit=1;
296
286
alter table t1 add unique (a,b), add key (b);
297
287
show keys from t1;
298
288
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           
 
289
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
290
t1      0       a       2       b       A       NULL    NULL    NULL    YES     BTREE           
 
291
t1      1       b       1       b       A       100     NULL    NULL    YES     BTREE           
302
292
analyze table t1;
303
293
Table   Op      Msg_type        Msg_text
304
294
test.t1 analyze status  OK
305
295
show keys from t1;
306
296
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           
 
297
t1      0       a       1       a       A       3       NULL    NULL    YES     BTREE           
308
298
t1      0       a       2       b       A       300     NULL    NULL    YES     BTREE           
309
 
t1      1       b       1       b       A       300     NULL    NULL    YES     BTREE           
 
299
t1      1       b       1       b       A       100     NULL    NULL    YES     BTREE           
 
300
drop table t1;
 
301
CREATE TABLE t1 (i int(10), index(i) );
 
302
ALTER TABLE t1 DISABLE KEYS;
 
303
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
 
304
ALTER TABLE t1 ENABLE KEYS;
310
305
drop table t1;
311
306
CREATE TABLE t1 (
312
307
Host varchar(16) binary NOT NULL default '',
396
391
insert into t1 (a) values(1);
397
392
show table status like 't1';
398
393
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            
 
394
t1      MyISAM  10      Fixed   1       37      X       X       X       X       X       X       X       X       latin1_swedish_ci       NULL            
400
395
alter table t1 modify a int;
401
396
show table status like 't1';
402
397
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            
 
398
t1      MyISAM  10      Fixed   1       37      X       X       X       X       X       X       X       X       latin1_swedish_ci       NULL            
404
399
drop table t1;
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;
 
400
create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
406
401
insert into t1 (a) values(1);
 
402
Warnings:
 
403
Warning 1364    Field 'b' doesn't have a default value
 
404
Warning 1364    Field 'c' doesn't have a default value
 
405
Warning 1364    Field 'd' doesn't have a default value
 
406
Warning 1364    Field 'e' doesn't have a default value
 
407
Warning 1364    Field 'f' doesn't have a default value
 
408
Warning 1364    Field 'g' doesn't have a default value
 
409
Warning 1364    Field 'h' doesn't have a default value
 
410
Warning 1364    Field 'i' doesn't have a default value
407
411
show table status like 't1';
408
412
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            
 
413
t1      MyISAM  10      Fixed   1       37      X       X       X       X       X       X       X       X       latin1_swedish_ci       NULL            
 
414
drop table t1;
 
415
set names koi8r;
 
416
create table t1 (a char(10) character set koi8r);
 
417
insert into t1 values ('����');
 
418
select a,hex(a) from t1;
 
419
a       hex(a)
 
420
����    D4C5D3D4
 
421
alter table t1 change a a char(10) character set cp1251;
 
422
select a,hex(a) from t1;
 
423
a       hex(a)
 
424
����    F2E5F1F2
 
425
alter table t1 change a a binary(4);
 
426
select a,hex(a) from t1;
 
427
a       hex(a)
 
428
����    F2E5F1F2
 
429
alter table t1 change a a char(10) character set cp1251;
 
430
select a,hex(a) from t1;
 
431
a       hex(a)
 
432
����    F2E5F1F2
 
433
alter table t1 change a a char(10) character set koi8r;
 
434
select a,hex(a) from t1;
 
435
a       hex(a)
 
436
����    D4C5D3D4
 
437
alter table t1 change a a varchar(10) character set cp1251;
 
438
select a,hex(a) from t1;
 
439
a       hex(a)
 
440
����    F2E5F1F2
 
441
alter table t1 change a a char(10) character set koi8r;
 
442
select a,hex(a) from t1;
 
443
a       hex(a)
 
444
����    D4C5D3D4
 
445
alter table t1 change a a text character set cp1251;
 
446
select a,hex(a) from t1;
 
447
a       hex(a)
 
448
����    F2E5F1F2
 
449
alter table t1 change a a char(10) character set koi8r;
 
450
select a,hex(a) from t1;
 
451
a       hex(a)
 
452
����    D4C5D3D4
 
453
delete from t1;
 
454
show create table t1;
 
455
Table   Create Table
 
456
t1      CREATE TABLE `t1` (
 
457
  `a` char(10) CHARACTER SET koi8r DEFAULT NULL
 
458
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
459
alter table t1 DEFAULT CHARACTER SET latin1;
 
460
show create table t1;
 
461
Table   Create Table
 
462
t1      CREATE TABLE `t1` (
 
463
  `a` char(10) CHARACTER SET koi8r DEFAULT NULL
 
464
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
465
alter table t1 CONVERT TO CHARACTER SET latin1;
 
466
show create table t1;
 
467
Table   Create Table
 
468
t1      CREATE TABLE `t1` (
 
469
  `a` char(10) DEFAULT NULL
 
470
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
471
alter table t1 DEFAULT CHARACTER SET cp1251;
 
472
show create table t1;
 
473
Table   Create Table
 
474
t1      CREATE TABLE `t1` (
 
475
  `a` char(10) CHARACTER SET latin1 DEFAULT NULL
 
476
) ENGINE=MyISAM DEFAULT CHARSET=cp1251
 
477
drop table t1;
 
478
create table t1 (myblob longblob,mytext longtext) 
 
479
default charset latin1 collate latin1_general_cs;
 
480
show create table t1;
 
481
Table   Create Table
 
482
t1      CREATE TABLE `t1` (
 
483
  `myblob` longblob,
 
484
  `mytext` longtext COLLATE latin1_general_cs
 
485
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
 
486
alter table t1 character set latin2;
 
487
show create table t1;
 
488
Table   Create Table
 
489
t1      CREATE TABLE `t1` (
 
490
  `myblob` longblob,
 
491
  `mytext` longtext CHARACTER SET latin1 COLLATE latin1_general_cs
 
492
) ENGINE=MyISAM DEFAULT CHARSET=latin2
410
493
drop table t1;
411
494
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
412
495
ALTER TABLE t1 DROP PRIMARY KEY;
413
496
SHOW CREATE TABLE t1;
414
497
Table   Create Table
415
498
t1      CREATE TABLE `t1` (
416
 
  `a` int NOT NULL,
417
 
  `b` int,
 
499
  `a` int(11) NOT NULL,
 
500
  `b` int(11) DEFAULT NULL,
418
501
  UNIQUE KEY `b` (`b`)
419
 
) ENGINE=InnoDB
 
502
) ENGINE=MyISAM DEFAULT CHARSET=latin1
420
503
ALTER TABLE t1 DROP PRIMARY KEY;
421
504
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
422
505
DROP TABLE t1;
430
513
ALTER TABLE T12207 DISCARD TABLESPACE;
431
514
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
432
515
DROP TABLE T12207;
 
516
create table t1 (a text) character set koi8r;
 
517
insert into t1 values (_koi8r'����');
 
518
select hex(a) from t1;
 
519
hex(a)
 
520
D4C5D3D4
 
521
alter table t1 convert to character set cp1251;
 
522
select hex(a) from t1;
 
523
hex(a)
 
524
F2E5F1F2
 
525
drop table t1;
433
526
create table t1 ( a timestamp );
434
527
alter table t1 add unique ( a(1) );
435
528
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
438
531
create table t1 (a int, key(a));
439
532
show indexes from t1;
440
533
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           
 
534
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
442
535
"this used not to disable the index"
443
 
alter table t1 modify a int;
444
 
show indexes from t1;
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           
447
 
alter table t1 enable keys;
448
 
Warnings:
449
 
Note    1031    Table storage engine for 't1' doesn't have this option
450
 
show indexes from t1;
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           
453
 
alter table t1 modify a bigint;
454
 
show indexes from t1;
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           
457
 
alter table t1 enable keys;
458
 
Warnings:
459
 
Note    1031    Table storage engine for 't1' doesn't have this option
460
 
show indexes from t1;
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           
463
 
alter table t1 add b char(10);
464
 
show indexes from t1;
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           
467
 
alter table t1 add c decimal(10,2);
468
 
show indexes from t1;
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           
 
536
alter table t1 modify a int, disable keys;
 
537
show indexes from t1;
 
538
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
539
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
 
540
alter table t1 enable keys;
 
541
show indexes from t1;
 
542
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
543
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
544
alter table t1 modify a bigint, disable keys;
 
545
show indexes from t1;
 
546
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
547
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
 
548
alter table t1 enable keys;
 
549
show indexes from t1;
 
550
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
551
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
552
alter table t1 add b char(10), disable keys;
 
553
show indexes from t1;
 
554
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
555
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
 
556
alter table t1 add c decimal(10,2), enable keys;
 
557
show indexes from t1;
 
558
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
559
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
471
560
"this however did"
472
 
alter table t1;
 
561
alter table t1 disable keys;
473
562
show indexes from t1;
474
563
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           
 
564
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
476
565
desc t1;
477
566
Field   Type    Null    Key     Default Extra
478
 
a       bigint  YES     MUL     NULL    
479
 
b       varchar(10)     YES             NULL    
 
567
a       bigint(20)      YES     MUL     NULL    
 
568
b       char(10)        YES             NULL    
480
569
c       decimal(10,2)   YES             NULL    
481
570
alter table t1 add d decimal(15,5);
482
571
"The key should still be disabled"
483
572
show indexes from t1;
484
573
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           
 
574
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
486
575
drop table t1;
487
576
"Now will test with one unique index"
488
577
create table t1(a int, b char(10), unique(a));
489
578
show indexes from t1;
490
579
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           
492
 
alter table t1;
 
580
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
581
alter table t1 disable keys;
493
582
show indexes from t1;
494
583
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           
 
584
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
496
585
alter table t1 enable keys;
497
 
Warnings:
498
 
Note    1031    Table storage engine for 't1' doesn't have this option
499
586
"If no copy on noop change, this won't touch the data file"
500
587
"Unique index, no change"
501
 
alter table t1 modify a int;
 
588
alter table t1 modify a int, disable keys;
502
589
show indexes from t1;
503
590
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           
 
591
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
505
592
"Change the type implying data copy"
506
593
"Unique index, no change"
507
 
alter table t1 modify a bigint;
508
 
show indexes from t1;
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           
511
 
alter table t1 modify a bigint;
512
 
show indexes from t1;
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           
 
594
alter table t1 modify a bigint, disable keys;
 
595
show indexes from t1;
 
596
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
597
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
598
alter table t1 modify a bigint;
 
599
show indexes from t1;
 
600
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
601
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
515
602
alter table t1 modify a int;
516
603
show indexes from t1;
517
604
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           
 
605
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
519
606
drop table t1;
520
607
"Now will test with one unique and one non-unique index"
521
608
create table t1(a int, b char(10), unique(a), key(b));
522
609
show indexes from t1;
523
610
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           
526
 
alter table t1;
 
611
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
612
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE           
 
613
alter table t1 disable keys;
527
614
show indexes from t1;
528
615
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           
 
616
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
617
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE   disabled        
531
618
alter table t1 enable keys;
532
 
Warnings:
533
 
Note    1031    Table storage engine for 't1' doesn't have this option
534
619
"If no copy on noop change, this won't touch the data file"
535
620
"The non-unique index will be disabled"
536
 
alter table t1 modify a int;
 
621
alter table t1 modify a int, disable keys;
537
622
show indexes from t1;
538
623
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           
 
624
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
625
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE   disabled        
541
626
alter table t1 enable keys;
542
 
Warnings:
543
 
Note    1031    Table storage engine for 't1' doesn't have this option
544
627
show indexes from t1;
545
628
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           
 
629
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
630
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE           
548
631
"Change the type implying data copy"
549
632
"The non-unique index will be disabled"
550
 
alter table t1 modify a bigint;
 
633
alter table t1 modify a bigint, disable keys;
551
634
show indexes from t1;
552
635
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           
 
636
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
637
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE   disabled        
555
638
"Change again the type, but leave the indexes as_is"
556
639
alter table t1 modify a int;
557
640
show indexes from t1;
558
641
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           
 
642
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
643
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE   disabled        
561
644
"Try the same. When data is no copied on similar tables, this is noop"
562
645
alter table t1 modify a int;
563
646
show indexes from t1;
564
647
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           
 
648
t1      0       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
649
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE   disabled        
567
650
drop table t1;
568
651
create database mysqltest;
569
652
create table t1 (c1 int);
585
668
SHOW CREATE TABLE t1;
586
669
Table   Create Table
587
670
t1      CREATE TABLE `t1` (
588
 
  `a` int,
 
671
  `a` int(11) DEFAULT NULL,
589
672
  KEY `i1` (`a`)
590
 
) ENGINE=InnoDB ROW_FORMAT=FIXED
 
673
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
591
674
DROP INDEX i1 ON t1;
592
675
SHOW CREATE TABLE t1;
593
676
Table   Create Table
594
677
t1      CREATE TABLE `t1` (
595
 
  `a` int
596
 
) ENGINE=InnoDB ROW_FORMAT=FIXED
 
678
  `a` int(11) DEFAULT NULL
 
679
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
597
680
DROP TABLE t1;
598
681
DROP TABLE IF EXISTS bug24219;
599
682
DROP TABLE IF EXISTS bug24219_2;
600
683
CREATE TABLE bug24219 (a INT, INDEX(a));
601
684
SHOW INDEX FROM bug24219;
602
685
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           
 
686
bug24219        1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
604
687
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
605
 
Warnings:
606
 
Note    1031    Table storage engine for 'bug24219' doesn't have this option
607
688
SHOW INDEX FROM bug24219_2;
608
689
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           
 
690
bug24219_2      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
610
691
DROP TABLE bug24219_2;
611
692
drop table if exists table_24562;
612
693
create table table_24562(
716
797
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
717
798
alter table table_24562 order by length(title);
718
799
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
 
800
alter table table_24562 order by (select 12 from dual);
 
801
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 '(select 12 from dual)' at line 1
719
802
alter table table_24562 order by no_such_col;
720
803
ERROR 42S22: Unknown column 'no_such_col' in 'order clause'
721
804
drop table table_24562;
722
 
create table t1 (mycol int not null);
 
805
create table t1 (mycol int(10) not null);
723
806
alter table t1 alter column mycol set default 0;
724
807
desc t1;
725
808
Field   Type    Null    Key     Default Extra
726
 
mycol   int     NO              NULL    
 
809
mycol   int(10) NO              0       
727
810
drop table t1;
728
 
create table t1(id int primary key auto_increment) engine=heap;
 
811
create table t1(id int(8) primary key auto_increment) engine=heap;
729
812
insert into t1 values (null);
730
813
insert into t1 values (null);
731
814
select * from t1;
749
832
50
750
833
51
751
834
drop table t1;
 
835
set @orig_sql_mode = @@sql_mode;
 
836
set sql_mode="no_zero_date";
 
837
create table t1(f1 int);
 
838
alter table t1 add column f2 datetime not null, add column f21 date not null;
 
839
insert into t1 values(1,'2000-01-01','2000-01-01');
 
840
alter table t1 add column f3 datetime not null;
 
841
ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'f3' at row 1
 
842
alter table t1 add column f3 date not null;
 
843
ERROR 22007: Incorrect date value: '0000-00-00' for column 'f3' at row 1
 
844
alter table t1 add column f4 datetime not null default '2002-02-02',
 
845
add column f41 date not null;
 
846
ERROR 22007: Incorrect date value: '0000-00-00' for column 'f41' at row 1
 
847
alter table t1 add column f4 datetime not null default '2002-02-02',
 
848
add column f41 date not null default '2002-02-02';
 
849
select * from t1;
 
850
f1      f2      f21     f4      f41
 
851
1       2000-01-01 00:00:00     2000-01-01      2002-02-02 00:00:00     2002-02-02
 
852
drop table t1;
 
853
set sql_mode= @orig_sql_mode;
752
854
create table t1 (v varchar(32));
753
855
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
754
856
select * from t1;
790
892
i       v
791
893
1       def
792
894
2       abc
 
895
5       lmn
793
896
4       3r4f
794
 
5       lmn
795
897
alter table t1 change i i bigint;
796
898
select * from t1;
797
899
i       v
798
900
1       def
799
901
2       abc
 
902
5       lmn
800
903
4       3r4f
801
 
5       lmn
802
904
alter table t1 add unique key (i, v);
803
905
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
804
906
i       v
805
907
4       3r4f
806
908
drop table t1;
807
 
create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
 
909
create table t1 (t varchar(255) default null, key t (t(80)))
 
910
engine=myisam default charset=latin1;
808
911
alter table t1 change t t text;
809
912
drop table t1;
 
913
CREATE TABLE t1 (a varchar(500));
 
914
ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b);
 
915
SHOW CREATE TABLE t1;
 
916
Table   Create Table
 
917
t1      CREATE TABLE `t1` (
 
918
  `a` varchar(500) DEFAULT NULL,
 
919
  `b` geometry NOT NULL,
 
920
  SPATIAL KEY `b` (`b`)
 
921
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
922
ALTER TABLE t1 ADD KEY(b(50));
 
923
SHOW CREATE TABLE t1;
 
924
Table   Create Table
 
925
t1      CREATE TABLE `t1` (
 
926
  `a` varchar(500) DEFAULT NULL,
 
927
  `b` geometry NOT NULL,
 
928
  SPATIAL KEY `b` (`b`),
 
929
  KEY `b_2` (`b`(50))
 
930
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
931
ALTER TABLE t1 ADD c POINT;
 
932
SHOW CREATE TABLE t1;
 
933
Table   Create Table
 
934
t1      CREATE TABLE `t1` (
 
935
  `a` varchar(500) DEFAULT NULL,
 
936
  `b` geometry NOT NULL,
 
937
  `c` point DEFAULT NULL,
 
938
  SPATIAL KEY `b` (`b`),
 
939
  KEY `b_2` (`b`(50))
 
940
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
941
CREATE TABLE t2 (a INT, KEY (a(20)));
 
942
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
 
943
ALTER TABLE t1 ADD d INT;
 
944
ALTER TABLE t1 ADD KEY (d(20));
 
945
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
 
946
ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30));
 
947
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
 
948
DROP TABLE t1;
810
949
CREATE TABLE t1 (s CHAR(8) BINARY);
811
950
INSERT INTO t1 VALUES ('test');
812
951
SELECT LENGTH(s) FROM t1;
817
956
LENGTH(s)
818
957
4
819
958
DROP TABLE t1;
820
 
CREATE TABLE t1 (s varbinary(8));
 
959
CREATE TABLE t1 (s BINARY(8));
821
960
INSERT INTO t1 VALUES ('test');
822
961
SELECT LENGTH(s) FROM t1;
823
962
LENGTH(s)
824
 
4
825
 
SELECT HEX(s) FROM t1;
826
 
HEX(s)
827
 
74657374
828
 
ALTER TABLE t1 MODIFY s varbinary(10);
829
 
SELECT HEX(s) FROM t1;
830
 
HEX(s)
831
 
74657374
 
963
8
 
964
SELECT HEX(s) FROM t1;
 
965
HEX(s)
 
966
7465737400000000
 
967
ALTER TABLE t1 MODIFY s BINARY(10);
 
968
SELECT HEX(s) FROM t1;
 
969
HEX(s)
 
970
74657374000000000000
832
971
SELECT LENGTH(s) FROM t1;
833
972
LENGTH(s)
834
 
4
 
973
10
835
974
DROP TABLE t1;
836
975
CREATE TABLE t1 (v VARCHAR(3), b INT);
837
976
INSERT INTO t1 VALUES ('abc', 5);
913
1052
SHOW CREATE TABLE `tt+1`;
914
1053
Table   Create Table
915
1054
tt+1    CREATE TEMPORARY TABLE `tt+1` (
916
 
  `c1` int
917
 
) ENGINE=InnoDB
 
1055
  `c1` int(11) DEFAULT NULL
 
1056
) ENGINE=MyISAM DEFAULT CHARSET=latin1
918
1057
SHOW CREATE TABLE `tt+2`;
919
1058
Table   Create Table
920
1059
tt+2    CREATE TEMPORARY TABLE `tt+2` (
921
 
  `c1` int
922
 
) ENGINE=InnoDB
 
1060
  `c1` int(11) DEFAULT NULL
 
1061
) ENGINE=MyISAM DEFAULT CHARSET=latin1
923
1062
DROP TABLE   `tt+1`, `tt+2`;
 
1063
CREATE TABLE `#sql1` (c1 INT);
 
1064
CREATE TABLE `@0023sql2` (c1 INT);
 
1065
SHOW TABLES;
 
1066
Tables_in_test
 
1067
#sql1
 
1068
@0023sql2
 
1069
RENAME TABLE `#sql1`     TO `@0023sql1`;
 
1070
RENAME TABLE `@0023sql2` TO `#sql2`;
 
1071
SHOW TABLES;
 
1072
Tables_in_test
 
1073
#sql2
 
1074
@0023sql1
 
1075
ALTER TABLE `@0023sql1`  RENAME `#sql-1`;
 
1076
ALTER TABLE `#sql2`      RENAME `@0023sql-2`;
 
1077
SHOW TABLES;
 
1078
Tables_in_test
 
1079
#sql-1
 
1080
@0023sql-2
 
1081
INSERT INTO `#sql-1`     VALUES (1);
 
1082
INSERT INTO `@0023sql-2` VALUES (2);
 
1083
DROP TABLE `#sql-1`, `@0023sql-2`;
924
1084
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
925
1085
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
926
1086
SHOW TABLES;
934
1094
SHOW CREATE TABLE `#sql2`;
935
1095
Table   Create Table
936
1096
#sql2   CREATE TEMPORARY TABLE `#sql2` (
937
 
  `c1` int
938
 
) ENGINE=InnoDB
 
1097
  `c1` int(11) DEFAULT NULL
 
1098
) ENGINE=MyISAM DEFAULT CHARSET=latin1
939
1099
SHOW CREATE TABLE `@0023sql1`;
940
1100
Table   Create Table
941
1101
@0023sql1       CREATE TEMPORARY TABLE `@0023sql1` (
942
 
  `c1` int
943
 
) ENGINE=InnoDB
 
1102
  `c1` int(11) DEFAULT NULL
 
1103
) ENGINE=MyISAM DEFAULT CHARSET=latin1
944
1104
DROP TABLE `#sql2`, `@0023sql1`;
945
1105
DROP TABLE IF EXISTS t1;
946
1106
DROP TABLE IF EXISTS t2;
947
1107
CREATE TABLE t1 (
948
 
int_field INTEGER NOT NULL,
 
1108
int_field INTEGER UNSIGNED NOT NULL,
949
1109
char_field CHAR(10),
950
1110
INDEX(`int_field`)
951
1111
);
952
1112
DESCRIBE t1;
953
1113
Field   Type    Null    Key     Default Extra
954
 
int_field       int     NO      MUL     NULL    
955
 
char_field      varchar(10)     YES             NULL    
 
1114
int_field       int(10) unsigned        NO      MUL     NULL    
 
1115
char_field      char(10)        YES             NULL    
956
1116
SHOW INDEXES FROM t1;
957
1117
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           
 
1118
t1      1       int_field       1       int_field       A       NULL    NULL    NULL            BTREE           
959
1119
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
960
1120
"Non-copy data change - new frm, but old data and index files"
961
 
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
 
1121
ALTER TABLE t1
 
1122
CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL,
 
1123
RENAME t2;
962
1124
SELECT * FROM t1 ORDER BY int_field;
963
1125
ERROR 42S02: Table 'test.t1' doesn't exist
964
1126
SELECT * FROM t2 ORDER BY unsigned_int_field;
970
1132
5       pet
971
1133
DESCRIBE t2;
972
1134
Field   Type    Null    Key     Default Extra
973
 
unsigned_int_field      int     NO      MUL     NULL    
974
 
char_field      varchar(10)     YES             NULL    
975
 
DESCRIBE t2;
976
 
Field   Type    Null    Key     Default Extra
977
 
unsigned_int_field      int     NO      MUL     NULL    
978
 
char_field      varchar(10)     YES             NULL    
979
 
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
980
 
DESCRIBE t2;
981
 
Field   Type    Null    Key     Default Extra
982
 
unsigned_int_field      bigint  NO      MUL     NULL    
983
 
char_field      varchar(10)     YES             NULL    
 
1135
unsigned_int_field      int(10) unsigned        NO      MUL     NULL    
 
1136
char_field      char(10)        YES             NULL    
 
1137
DESCRIBE t2;
 
1138
Field   Type    Null    Key     Default Extra
 
1139
unsigned_int_field      int(10) unsigned        NO      MUL     NULL    
 
1140
char_field      char(10)        YES             NULL    
 
1141
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
 
1142
DESCRIBE t2;
 
1143
Field   Type    Null    Key     Default Extra
 
1144
unsigned_int_field      bigint(20) unsigned     NO      MUL     NULL    
 
1145
char_field      char(10)        YES             NULL    
984
1146
DROP TABLE t2;
985
1147
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
986
1148
INSERT INTO t1 VALUES (1, 2, NULL);