~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/alter_table.test

  • Committer: Eric Lambert
  • Date: 2009-06-11 21:19:36 UTC
  • mto: (1061.1.1 merge-all)
  • mto: This revision was merged to the branch mainline in revision 1062.
  • Revision ID: eric.d.lambert@gmail.com-20090611211936-g2gij43xakupz1dw
-removed rm_dir_w_symlink method call with rmdir since dir should not be a sym link in the first place.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
15
15
col6 int not null, to_be_deleted int);
16
16
insert into t1 values (2,4,3,5,"PENDING",1,7);
17
 
SELECT * FROM t1;
18
 
 
19
 
--error 1714
20
17
alter table t1
21
18
add column col4_5 varchar(20) not null after col4,
22
19
add column col7 varchar(30) not null after col5,
23
 
add column col8 datetime not null default '1000-01-01 00:00:00', drop column to_be_deleted,
24
 
change column col2 fourth varchar(30) not null after col3,
25
 
modify column col6 int not null first;
26
 
 
27
 
alter table t1
28
 
add column col4_5 varchar(20) DEFAULT "added" not null after col4,
29
 
add column col7 varchar(30) DEFAULT "added" not null after col5,
30
 
add column col8 datetime not null default '1000-01-01 00:00:00',
31
 
drop column to_be_deleted,
32
 
change column col2 fourth varchar(30) not null after col3,
33
 
modify column col6 int not null first;
34
 
 
 
20
add column col8 datetime not null, drop column to_be_deleted,
 
21
change column col2 fourth varchar(30) not null after col3,
 
22
modify column col6 int not null first;
35
23
select * from t1;
36
24
drop table t1;
37
25
 
51
39
NAME varchar(80) DEFAULT '' NOT NULL,
52
40
PRIMARY KEY (GROUP_ID,LANG_ID),
53
41
KEY NAME (NAME));
54
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
42
#show table status like "t1";
55
43
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
56
44
--replace_column 8 #
57
 
show COLUMNS FROM t1;
 
45
SHOW FULL COLUMNS FROM t1;
58
46
DROP TABLE t1;
59
47
 
60
48
#
67
55
select * from t1;
68
56
drop table t1;
69
57
 
70
 
CREATE TEMPORARY TABLE t1 (
 
58
CREATE TABLE t1 (
71
59
  id int NOT NULL default '0',
72
60
  category_id int NOT NULL default '0',
73
61
  type_id int NOT NULL default '0',
167
155
# Test with two keys
168
156
#
169
157
 
170
 
CREATE TEMPORARY TABLE t1 (
171
 
  Host varchar(16) NOT NULL default '',
172
 
  User varchar(16) NOT NULL default '',
 
158
CREATE TABLE t1 (
 
159
  Host varchar(16) binary NOT NULL default '',
 
160
  User varchar(16) binary NOT NULL default '',
173
161
  PRIMARY KEY  (Host,User),
174
162
  KEY  (Host)
175
163
) ENGINE=MyISAM;
176
164
 
177
165
ALTER TABLE t1 DISABLE KEYS;
178
 
#SHOW INDEX FROM t1;
 
166
SHOW INDEX FROM t1;
179
167
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
180
 
#SHOW INDEX FROM t1;
 
168
SHOW INDEX FROM t1;
181
169
ALTER TABLE t1 ENABLE KEYS;
182
 
#SHOW INDEX FROM t1;
 
170
SHOW INDEX FROM t1;
183
171
CHECK TABLES t1;
184
172
 
185
173
# Test RENAME
201
189
# BUG#6236 - ALTER TABLE MODIFY should set implicit NOT NULL on PK columns
202
190
#
203
191
drop table if exists t1;
204
 
create TEMPORARY table t1 ( a varchar(10) not null primary key ) engine=myisam;
 
192
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
205
193
flush tables;
206
194
alter table t1 modify a varchar(10);
207
195
flush tables;
211
199
# The following is also part of bug #6236 (CREATE TABLE didn't properly count
212
200
# not null columns for primary keys)
213
201
 
214
 
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;
 
202
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;
215
203
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
216
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
204
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
217
205
show table status like 't1';
218
206
alter table t1 modify a int;
219
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
207
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
220
208
show table status like 't1';
221
209
drop table t1;
222
 
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;
 
210
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;
223
211
insert into t1 (a) values(1);
224
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
212
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
225
213
show table status like 't1';
226
214
drop table t1;
227
215
 
249
237
# BUG 12207 alter table ... discard table space on MyISAM table causes ERROR 2013 (HY000)
250
238
#
251
239
# Some platforms (Mac OS X, Windows) will send the error message using small letters.
252
 
CREATE TEMPORARY TABLE T12207(a int) ENGINE=MYISAM;
 
240
CREATE TABLE T12207(a int) ENGINE=MYISAM;
253
241
--replace_result t12207 T12207
254
242
--error ER_ILLEGAL_HA
255
243
ALTER TABLE T12207 DISCARD TABLESPACE;
395
383
drop table t1;
396
384
 
397
385
#
398
 
# BUG#23404 - ROW_FORMAT=COMPACT option is lost is an index is added to the
 
386
# BUG#23404 - ROW_FORMAT=FIXED option is lost is an index is added to the
399
387
# table
400
388
#
401
 
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
 
389
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
402
390
CREATE INDEX i1 ON t1(a);
403
391
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
404
392
SHOW CREATE TABLE t1;
503
491
# Bug#25262 Auto Increment lost when changing Engine type
504
492
#
505
493
 
506
 
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
 
494
create table t1(id int primary key auto_increment) engine=heap;
507
495
 
508
496
insert into t1 values (null);
509
497
insert into t1 values (null);
520
508
insert into t1 values (null);
521
509
select * from t1;
522
510
 
523
 
# Alter to MEMORY again
524
 
alter table t1 engine = MEMORY;
 
511
# Alter to heap again
 
512
alter table t1 engine = heap;
525
513
insert into t1 values (null);
526
514
select * from t1;
527
515
 
534
522
#create table t1(f1 int);
535
523
#alter table t1 add column f2 datetime not null, add column f21 date not null;
536
524
#insert into t1 values(1,'2000-01-01','2000-01-01');
537
 
#--error ER_TRUNCATED_WRONG_VALUE
 
525
#--error 1292
538
526
#alter table t1 add column f3 datetime not null;
539
 
#--error ER_TRUNCATED_WRONG_VALUE
 
527
#--error 1292
540
528
#alter table t1 add column f3 date not null;
541
 
#--error ER_TRUNCATED_WRONG_VALUE
 
529
#--error 1292
542
530
#alter table t1 add column f4 datetime not null default '2002-02-02',
543
531
#  add column f41 date not null;
544
532
#alter table t1 add column f4 datetime not null default '2002-02-02',
578
566
# without # prefix is not allowed for TEXT columns, while index
579
567
# is defined with prefix.
580
568
581
 
create TEMPORARY table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
 
569
create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
582
570
alter table t1 change t t text;
583
571
drop table t1;
584
572
 
586
574
# Bug#18038  MySQL server corrupts binary columns data
587
575
#
588
576
 
589
 
CREATE TABLE t1 (s CHAR(8));
 
577
CREATE TABLE t1 (s CHAR(8) BINARY);
590
578
INSERT INTO t1 VALUES ('test');
591
579
SELECT LENGTH(s) FROM t1;
592
 
ALTER TABLE t1 MODIFY s CHAR(10);
 
580
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
593
581
SELECT LENGTH(s) FROM t1;
594
582
DROP TABLE t1;
595
583