26
create table t1 (bandID INT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
26
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
27
27
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
28
28
alter table t1 add column new_col int;
34
34
# Check that pack_keys and dynamic length rows are not forced.
37
GROUP_ID int unsigned DEFAULT '0' NOT NULL,
38
LANG_ID smallint unsigned DEFAULT '0' NOT NULL,
37
GROUP_ID int DEFAULT '0' NOT NULL,
38
LANG_ID int DEFAULT '0' NOT NULL,
39
39
NAME varchar(80) DEFAULT '' NOT NULL,
40
40
PRIMARY KEY (GROUP_ID,LANG_ID),
59
id int unsigned NOT NULL default '0',
60
category_id tinyint unsigned NOT NULL default '0',
61
type_id tinyint unsigned NOT NULL default '0',
59
id int NOT NULL default '0',
60
category_id int NOT NULL default '0',
61
type_id int NOT NULL default '0',
62
62
body text NOT NULL,
63
user_id int unsigned NOT NULL default '0',
63
user_id int NOT NULL default '0',
64
64
status enum('new','old') NOT NULL default 'new',
72
# The following combination found a hang-bug in MyISAM
75
CREATE TABLE t1 (AnamneseId int unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
76
insert into t1 values (null,"hello");
78
ALTER TABLE t1 ADD Column new_col int not null;
84
72
# Drop and add an auto_increment column
87
create table t1 (i int unsigned not null auto_increment primary key);
75
create table t1 (i int not null auto_increment primary key);
88
76
insert into t1 values (null),(null),(null),(null);
89
alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
77
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
196
165
ALTER TABLE t1 DISABLE KEYS;
197
166
SHOW INDEX FROM t1;
198
LOCK TABLES t1 WRITE;
199
167
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
200
168
SHOW INDEX FROM t1;
201
169
ALTER TABLE t1 ENABLE KEYS;
202
170
SHOW INDEX FROM t1;
206
# Test RENAME with LOCK TABLES
207
LOCK TABLES t1 WRITE;
208
174
ALTER TABLE t1 RENAME t2;
210
175
select * from t2;
217
Host varchar(16) binary NOT NULL default '',
218
User varchar(16) binary NOT NULL default '',
219
PRIMARY KEY (Host,User),
223
LOCK TABLES t1 WRITE;
224
ALTER TABLE t1 DISABLE KEYS;
229
179
# BUG#4717 - check for valid table names
231
181
create table t1 (a int);
250
200
# not null columns for primary keys)
252
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;
253
insert into t1 (a) values(1);
254
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
203
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
204
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
255
205
show table status like 't1';
256
206
alter table t1 modify a int;
257
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
207
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
258
208
show table status like 't1';
260
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;
261
211
insert into t1 (a) values(1);
262
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
212
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
263
213
show table status like 't1';
267
# Test that data get converted when character set is changed
268
# Test that data doesn't get converted when src or dst is BINARY/BLOB
271
create table t1 (a char(10) character set koi8r);
272
insert into t1 values ('����');
273
select a,hex(a) from t1;
274
alter table t1 change a a char(10) character set cp1251;
275
select a,hex(a) from t1;
276
alter table t1 change a a varbinary(4);
277
select a,hex(a) from t1;
278
alter table t1 change a a char(10) character set cp1251;
279
select a,hex(a) from t1;
280
alter table t1 change a a char(10) character set koi8r;
281
select a,hex(a) from t1;
282
alter table t1 change a a varchar(10) character set cp1251;
283
select a,hex(a) from t1;
284
alter table t1 change a a char(10) character set koi8r;
285
select a,hex(a) from t1;
286
alter table t1 change a a text character set cp1251;
287
select a,hex(a) from t1;
288
alter table t1 change a a char(10) character set koi8r;
289
select a,hex(a) from t1;
293
# Test ALTER TABLE .. CHARACTER SET ..
295
show create table t1;
296
alter table t1 DEFAULT CHARACTER SET latin1;
297
show create table t1;
298
alter table t1 CONVERT TO CHARACTER SET latin1;
299
show create table t1;
300
alter table t1 DEFAULT CHARACTER SET cp1251;
301
show create table t1;
307
# Test that table CHARACTER SET does not affect blobs
309
create table t1 (myblob longblob,mytext longtext)
310
default charset latin1 collate latin1_general_cs;
311
show create table t1;
312
alter table t1 character set latin2;
313
show create table t1;
317
217
# Bug 2361 (Don't drop UNIQUE with DROP PRIMARY KEY)
320
220
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
321
221
ALTER TABLE t1 DROP PRIMARY KEY;
222
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
322
223
SHOW CREATE TABLE t1;
323
224
--error ER_CANT_DROP_FIELD_OR_KEY
324
225
ALTER TABLE t1 DROP PRIMARY KEY;
343
244
DROP TABLE T12207;
346
# Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns
348
# The column's character set was changed but the actual data was not
349
# modified. In other words, the values were reinterpreted
350
# as UTF8 instead of being converted.
351
create table t1 (a text) character set koi8r;
352
insert into t1 values (_koi8r'����');
353
select hex(a) from t1;
354
alter table t1 convert to character set cp1251;
355
select hex(a) from t1;
359
247
# Test for bug #7884 "Able to add invalid unique index on TIMESTAMP prefix"
360
248
# MySQL should not think that packed field with non-zero decimals is
361
249
# geometry field and allow to create prefix index which is
717
606
--echo End of 5.0 tests
720
# Extended test coverage for ALTER TABLE behaviour under LOCK TABLES
721
# It should be consistent across all platforms and for all engines
722
# (Before 5.1 this was not true as behavior was different between
723
# Unix/Windows and transactional/non-transactional tables).
724
# See also innodb_mysql.test
727
drop table if exists t1, t2, t3;
729
create table t1 (i int);
730
create table t3 (j int);
731
insert into t1 values ();
732
insert into t3 values ();
733
# Table which is altered under LOCK TABLES it should stay in list of locked
734
# tables and be available after alter takes place unless ALTER contains RENAME
735
# clause. We should see the new definition of table, of course.
736
lock table t1 write, t3 read;
737
# Example of so-called 'fast' ALTER TABLE
738
alter table t1 modify i int default 1;
739
insert into t1 values ();
741
# And now full-blown ALTER TABLE
742
alter table t1 change i c char(10) default "Two";
743
insert into t1 values ();
745
# If table is renamed then it should be removed from the list
746
# of locked tables. 'Fast' ALTER TABLE with RENAME clause:
747
alter table t1 modify c char(10) default "Three", rename to t2;
748
--error ER_TABLE_NOT_LOCKED
750
--error ER_TABLE_NOT_LOCKED
754
insert into t2 values ();
756
lock table t2 write, t3 read;
757
# Full ALTER TABLE with RENAME
758
alter table t2 change c vc varchar(100) default "Four", rename to t1;
759
--error ER_TABLE_NOT_LOCKED
761
--error ER_TABLE_NOT_LOCKED
765
insert into t1 values ();
771
609
# Bug#18775 - Temporary table from alter table visible to other threads
773
611
# Check if special characters work and duplicates are detected.
841
684
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
842
685
--echo "Non-copy data change - new frm, but old data and index files"
844
CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL,
686
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
847
688
--error ER_NO_SUCH_TABLE
848
689
SELECT * FROM t1 ORDER BY int_field;
849
690
SELECT * FROM t2 ORDER BY unsigned_int_field;
852
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
693
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;