167
# Test ALTER TABLE ENABLE/DISABLE keys when things are locked
171
Host varchar(16) binary NOT NULL default '',
172
User varchar(16) binary NOT NULL default '',
173
PRIMARY KEY (Host,User)
176
ALTER TABLE t1 DISABLE KEYS;
177
LOCK TABLES t1 WRITE;
178
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
180
ALTER TABLE t1 ENABLE KEYS;
155
186
# Test with two keys
158
CREATE TEMPORARY TABLE t1 (
159
Host varchar(16) NOT NULL default '',
160
User varchar(16) NOT NULL default '',
190
Host varchar(16) binary NOT NULL default '',
191
User varchar(16) binary NOT NULL default '',
161
192
PRIMARY KEY (Host,User),
165
196
ALTER TABLE t1 DISABLE KEYS;
198
LOCK TABLES t1 WRITE;
167
199
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
169
201
ALTER TABLE t1 ENABLE KEYS;
206
# Test RENAME with LOCK TABLES
207
LOCK TABLES t1 WRITE;
174
208
ALTER TABLE t1 RENAME t2;
175
210
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;
179
229
# BUG#4717 - check for valid table names
181
231
create table t1 (a int);
199
249
# The following is also part of bug #6236 (CREATE TABLE didn't properly count
200
250
# not null columns for primary keys)
202
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;
252
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;
203
253
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 1 # 6 # 7 # 8 # 9 # 10 #
254
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
205
255
show table status like 't1';
206
256
alter table t1 modify a int;
207
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
257
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
208
258
show table status like 't1';
210
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;
260
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;
211
261
insert into t1 (a) values(1);
212
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
262
--replace_column 3 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
213
263
show table status like 't1';
606
656
--echo End of 5.0 tests
659
# Extended test coverage for ALTER TABLE behaviour under LOCK TABLES
660
# It should be consistent across all platforms and for all engines
661
# (Before 5.1 this was not true as behavior was different between
662
# Unix/Windows and transactional/non-transactional tables).
663
# See also innodb_mysql.test
666
drop table if exists t1, t2, t3;
668
create table t1 (i int);
669
create table t3 (j int);
670
insert into t1 values ();
671
insert into t3 values ();
672
# Table which is altered under LOCK TABLES it should stay in list of locked
673
# tables and be available after alter takes place unless ALTER contains RENAME
674
# clause. We should see the new definition of table, of course.
675
lock table t1 write, t3 read;
676
# Example of so-called 'fast' ALTER TABLE
677
alter table t1 modify i int default 1;
678
insert into t1 values ();
680
# And now full-blown ALTER TABLE
681
alter table t1 change i c char(10) default "Two";
682
insert into t1 values ();
684
# If table is renamed then it should be removed from the list
685
# of locked tables. 'Fast' ALTER TABLE with RENAME clause:
686
alter table t1 modify c char(10) default "Three", rename to t2;
687
--error ER_TABLE_NOT_LOCKED
689
--error ER_TABLE_NOT_LOCKED
693
insert into t2 values ();
695
lock table t2 write, t3 read;
696
# Full ALTER TABLE with RENAME
697
alter table t2 change c vc varchar(100) default "Four", rename to t1;
698
--error ER_TABLE_NOT_LOCKED
700
--error ER_TABLE_NOT_LOCKED
704
insert into t1 values ();
609
710
# Bug#18775 - Temporary table from alter table visible to other threads
611
712
# Check if special characters work and duplicates are detected.