~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/alter_table.test

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
select * from t1;
24
24
drop table t1;
25
25
 
26
 
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
 
26
create table t1 (bandID INT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED 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;
29
29
select * from t1;
34
34
# Check that pack_keys and dynamic length rows are not forced. 
35
35
 
36
36
CREATE TABLE t1 (
37
 
GROUP_ID int DEFAULT '0' NOT NULL,
38
 
LANG_ID int DEFAULT '0' NOT NULL,
 
37
GROUP_ID int unsigned DEFAULT '0' NOT NULL,
 
38
LANG_ID smallint unsigned DEFAULT '0' NOT NULL,
39
39
NAME varchar(80) DEFAULT '' NOT NULL,
40
40
PRIMARY KEY (GROUP_ID,LANG_ID),
41
41
KEY NAME (NAME));
56
56
drop table t1;
57
57
 
58
58
CREATE TABLE t1 (
59
 
  id int NOT NULL default '0',
60
 
  category_id int NOT NULL default '0',
61
 
  type_id int NOT NULL default '0',
 
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',
62
62
  body text NOT NULL,
63
 
  user_id int NOT NULL default '0',
 
63
  user_id int unsigned NOT NULL default '0',
64
64
  status enum('new','old') NOT NULL default 'new',
65
65
  PRIMARY KEY (id)
66
66
) ENGINE=MyISAM;
72
72
# The following combination found a hang-bug in MyISAM
73
73
#
74
74
 
75
 
CREATE TABLE t1 (AnamneseId int NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
 
75
CREATE TABLE t1 (AnamneseId int unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
76
76
insert into t1 values (null,"hello");
77
77
LOCK TABLES t1 WRITE;
78
78
ALTER TABLE t1 ADD Column new_col int not null;
84
84
# Drop and add an auto_increment column
85
85
#
86
86
 
87
 
create table t1 (i int not null auto_increment primary key);
 
87
create table t1 (i int unsigned not null auto_increment primary key);
88
88
insert into t1 values (null),(null),(null),(null);
89
 
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
 
89
alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
90
90
select * from t1;
91
91
drop table t1;
92
92
 
138
138
# Alter table and rename
139
139
#
140
140
 
141
 
create table t1 (i int not null auto_increment primary key);
 
141
create table t1 (i int unsigned not null auto_increment primary key);
142
142
alter table t1 rename t2;
143
143
alter table t2 rename t1, add c char(10) comment "no comment";
144
144
show columns from t1;
264
264
drop table t1;
265
265
 
266
266
#
 
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
 
269
#
 
270
set names koi8r;
 
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;
 
290
delete from t1;
 
291
 
 
292
#
 
293
# Test ALTER TABLE .. CHARACTER SET ..
 
294
#
 
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;
 
302
 
 
303
drop table t1;
 
304
 
 
305
#
 
306
# Bug#2821
 
307
# Test that table CHARACTER SET does not affect blobs
 
308
#
 
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;
 
314
drop table t1;
 
315
 
 
316
#
267
317
# Bug 2361 (Don't drop UNIQUE with DROP PRIMARY KEY)
268
318
#
269
319
 
293
343
DROP TABLE T12207;
294
344
 
295
345
#
 
346
# Bug #6479  ALTER TABLE ... changing charset fails for TEXT columns
 
347
#
 
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;
 
356
drop table t1;
 
357
 
 
358
#
296
359
# Test for bug #7884 "Able to add invalid unique index on TIMESTAMP prefix"
297
360
# MySQL should not think that packed field with non-zero decimals is
298
361
# geometry field and allow to create prefix index which is
613
676
# without # prefix is not allowed for TEXT columns, while index
614
677
# is defined with prefix.
615
678
616
 
create table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
 
679
create table t1 (t varchar(255) default null, key t (t(80)))
 
680
engine=myisam default charset=latin1;
617
681
alter table t1 change t t text;
618
682
drop table t1;
619
683
 
765
829
DROP TABLE IF EXISTS t2;
766
830
--enable_warnings
767
831
CREATE TABLE t1 (
768
 
  int_field INTEGER NOT NULL,
 
832
  int_field INTEGER UNSIGNED NOT NULL,
769
833
  char_field CHAR(10),
770
834
  INDEX(`int_field`)
771
835
);
776
840
 
777
841
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet"); 
778
842
--echo "Non-copy data change - new frm, but old data and index files"
779
 
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
 
843
ALTER TABLE t1
 
844
  CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL,
 
845
  RENAME t2;
780
846
 
781
847
--error ER_NO_SUCH_TABLE
782
848
SELECT * FROM t1 ORDER BY int_field;
783
849
SELECT * FROM t2 ORDER BY unsigned_int_field;
784
850
DESCRIBE t2;
785
851
DESCRIBE t2;
786
 
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
 
852
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
787
853
DESCRIBE t2;
788
854
 
789
855
DROP TABLE t2;