~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/alter_table.test

  • Committer: Stewart Smith
  • Date: 2008-07-25 03:48:54 UTC
  • mfrom: (207.1.1 drizzle)
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080725034854-p34pdb0lhpoc159d
merge mainline and update md5 and crc32 plugins to new interface

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 MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED 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
 
alter table t1 add column new_col int, order by payoutid,bandid;
 
28
alter table t1 add column new_col int;
29
29
select * from t1;
30
 
alter table t1 order by bandid,payoutid;
 
30
alter table t1;
31
31
select * from t1;
32
32
drop table t1;
33
33
 
117
117
                key (n2, n3, n4, n1),
118
118
                key (n3, n4, n1, n2),
119
119
                key (n4, n1, n2, n3) );
120
 
alter table t1 disable keys;
 
120
alter table t1;
121
121
show keys from t1;
122
122
#let $1=10000;
 
123
set autocommit=0;
 
124
begin;
123
125
let $1=10;
124
126
while ($1)
125
127
{
126
128
 eval insert into t1 values($1,RAND()*1000,RAND()*1000,RAND());
127
129
 dec $1;
128
130
}
 
131
commit;
 
132
set autocommit=1;
129
133
alter table t1 enable keys;
130
134
show keys from t1;
131
135
drop table t1;
144
148
 
145
149
create table t1 (a int, b int);
146
150
let $1=100;
 
151
set autocommit=0;
 
152
begin;
147
153
while ($1)
148
154
{
149
155
 eval insert into t1 values(1,$1), (2,$1), (3, $1);
150
156
 dec $1;
151
157
}
 
158
commit;
 
159
set autocommit=1;
152
160
alter table t1 add unique (a,b), add key (b);
153
161
show keys from t1;
154
162
analyze table t1;
203
211
DROP TABLE t2;
204
212
 
205
213
#
206
 
# Test disable keys with locking
 
214
# Test with locking
207
215
#
208
216
CREATE TABLE t1 (
209
217
  Host varchar(16) binary NOT NULL default '',
370
378
create table t1 (a int, key(a));
371
379
show indexes from t1;
372
380
--echo "this used not to disable the index"
373
 
alter table t1 modify a int, disable keys;
374
 
show indexes from t1;
375
 
 
376
 
alter table t1 enable keys;
377
 
show indexes from t1;
378
 
 
379
 
alter table t1 modify a bigint, disable keys;
380
 
show indexes from t1;
381
 
 
382
 
alter table t1 enable keys;
383
 
show indexes from t1;
384
 
 
385
 
alter table t1 add b char(10), disable keys;
386
 
show indexes from t1;
387
 
 
388
 
alter table t1 add c decimal(10,2), enable keys;
 
381
alter table t1 modify a int;
 
382
show indexes from t1;
 
383
 
 
384
alter table t1 enable keys;
 
385
show indexes from t1;
 
386
 
 
387
alter table t1 modify a bigint;
 
388
show indexes from t1;
 
389
 
 
390
alter table t1 enable keys;
 
391
show indexes from t1;
 
392
 
 
393
alter table t1 add b char(10);
 
394
show indexes from t1;
 
395
 
 
396
alter table t1 add c decimal(10,2);
389
397
show indexes from t1;
390
398
 
391
399
--echo "this however did"
392
 
alter table t1 disable keys;
 
400
alter table t1;
393
401
show indexes from t1;
394
402
 
395
403
desc t1;
403
411
--echo "Now will test with one unique index"
404
412
create table t1(a int, b char(10), unique(a));
405
413
show indexes from t1;
406
 
alter table t1 disable keys;
 
414
alter table t1;
407
415
show indexes from t1;
408
416
alter table t1 enable keys;
409
417
 
410
418
--echo "If no copy on noop change, this won't touch the data file"
411
419
--echo "Unique index, no change"
412
 
alter table t1 modify a int, disable keys;
 
420
alter table t1 modify a int;
413
421
show indexes from t1;
414
422
 
415
423
--echo "Change the type implying data copy"
416
424
--echo "Unique index, no change"
417
 
alter table t1 modify a bigint, disable keys;
 
425
alter table t1 modify a bigint;
418
426
show indexes from t1;
419
427
 
420
428
alter table t1 modify a bigint;
428
436
--echo "Now will test with one unique and one non-unique index"
429
437
create table t1(a int, b char(10), unique(a), key(b));
430
438
show indexes from t1;
431
 
alter table t1 disable keys;
 
439
alter table t1;
432
440
show indexes from t1;
433
441
alter table t1 enable keys;
434
442
 
435
443
 
436
444
--echo "If no copy on noop change, this won't touch the data file"
437
445
--echo "The non-unique index will be disabled"
438
 
alter table t1 modify a int, disable keys;
 
446
alter table t1 modify a int;
439
447
show indexes from t1;
440
448
alter table t1 enable keys;
441
449
show indexes from t1;
442
450
 
443
451
--echo "Change the type implying data copy"
444
452
--echo "The non-unique index will be disabled"
445
 
alter table t1 modify a bigint, disable keys;
 
453
alter table t1 modify a bigint;
446
454
show indexes from t1;
447
455
 
448
456
--echo "Change again the type, but leave the indexes as_is"
572
580
alter table table_24562 order by (section + 12);
573
581
--error ER_PARSE_ERROR
574
582
alter table table_24562 order by length(title);
575
 
--error ER_PARSE_ERROR
576
 
alter table table_24562 order by (select 12 from dual);
577
583
 
578
584
--error ER_BAD_FIELD_ERROR
579
585
alter table table_24562 order by no_such_col;
619
625
 
620
626
drop table t1;
621
627
 
622
 
#
623
 
# Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the
624
 
#            NO_ZERO_DATE mode.
625
 
#
626
 
create table t1(f1 int);
627
 
alter table t1 add column f2 datetime not null, add column f21 date not null;
628
 
insert into t1 values(1,'2000-01-01','2000-01-01');
629
 
--error 1292
630
 
alter table t1 add column f3 datetime not null;
631
 
--error 1292
632
 
alter table t1 add column f3 date not null;
633
 
--error 1292
634
 
alter table t1 add column f4 datetime not null default '2002-02-02',
635
 
  add column f41 date not null;
636
 
alter table t1 add column f4 datetime not null default '2002-02-02',
637
 
  add column f41 date not null default '2002-02-02';
638
 
select * from t1;
639
 
drop table t1;
640
 
set sql_mode= @orig_sql_mode;
 
628
##
 
629
## Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the
 
630
##            NO_ZERO_DATE mode.
 
631
##
 
632
#create table t1(f1 int);
 
633
#alter table t1 add column f2 datetime not null, add column f21 date not null;
 
634
#insert into t1 values(1,'2000-01-01','2000-01-01');
 
635
#--error 1292
 
636
#alter table t1 add column f3 datetime not null;
 
637
#--error 1292
 
638
#alter table t1 add column f3 date not null;
 
639
#--error 1292
 
640
#alter table t1 add column f4 datetime not null default '2002-02-02',
 
641
#  add column f41 date not null;
 
642
#alter table t1 add column f4 datetime not null default '2002-02-02',
 
643
#  add column f41 date not null default '2002-02-02';
 
644
#select * from t1;
 
645
#drop table t1;
641
646
 
642
647
#
643
648
# Some additional tests for new, faster alter table.  Note that most of the
677
682
drop table t1;
678
683
 
679
684
#
680
 
# Bug #26794: Adding an index with a prefix on a SPATIAL type breaks ALTER
681
 
# TABLE
682
 
#
683
 
CREATE TABLE t1 (a varchar(500));
684
 
 
685
 
ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b);
686
 
SHOW CREATE TABLE t1;
687
 
ALTER TABLE t1 ADD KEY(b(50));
688
 
SHOW CREATE TABLE t1;
689
 
 
690
 
ALTER TABLE t1 ADD c POINT;
691
 
SHOW CREATE TABLE t1;
692
 
 
693
 
--error ER_WRONG_SUB_KEY
694
 
CREATE TABLE t2 (a INT, KEY (a(20)));
695
 
 
696
 
ALTER TABLE t1 ADD d INT;
697
 
--error ER_WRONG_SUB_KEY
698
 
ALTER TABLE t1 ADD KEY (d(20));
699
 
 
700
 
# the 5.1 part of the test
701
 
--error ER_WRONG_SUB_KEY
702
 
ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30));
703
 
 
704
 
DROP TABLE t1;
705
 
 
706
 
#
707
685
# Bug#18038  MySQL server corrupts binary columns data
708
686
#
709
687
 
812
790
SHOW CREATE TABLE `tt+1`;
813
791
SHOW CREATE TABLE `tt+2`;
814
792
DROP TABLE   `tt+1`, `tt+2`;
815
 
#
816
 
# Check if special characters as in tmp_file_prefix work.
817
 
CREATE TABLE `#sql1` (c1 INT);
818
 
CREATE TABLE `@0023sql2` (c1 INT);
819
 
SHOW TABLES;
820
 
RENAME TABLE `#sql1`     TO `@0023sql1`;
821
 
RENAME TABLE `@0023sql2` TO `#sql2`;
822
 
SHOW TABLES;
823
 
ALTER TABLE `@0023sql1`  RENAME `#sql-1`;
824
 
ALTER TABLE `#sql2`      RENAME `@0023sql-2`;
825
 
SHOW TABLES;
826
 
INSERT INTO `#sql-1`     VALUES (1);
827
 
INSERT INTO `@0023sql-2` VALUES (2);
828
 
DROP TABLE `#sql-1`, `@0023sql-2`;
 
793
##
 
794
## Check if special characters as in tmp_file_prefix work.
 
795
#CREATE TABLE `#sql1` (c1 INT);
 
796
#CREATE TABLE `@0023sql2` (c1 INT);
 
797
#SHOW TABLES;
 
798
#RENAME TABLE `#sql1`     TO `@0023sql1`;
 
799
#RENAME TABLE `@0023sql2` TO `#sql2`;
 
800
#SHOW TABLES;
 
801
#ALTER TABLE `@0023sql1`  RENAME `#sql-1`;
 
802
#ALTER TABLE `#sql2`      RENAME `@0023sql-2`;
 
803
#SHOW TABLES;
 
804
#INSERT INTO `#sql-1`     VALUES (1);
 
805
#INSERT INTO `@0023sql-2` VALUES (2);
 
806
#DROP TABLE `#sql-1`, `@0023sql-2`;
829
807
#
830
808
# Same for temporary tables though these names do not become file names.
831
809
CREATE TEMPORARY TABLE `#sql1` (c1 INT);