~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/auto_increment.test

  • Committer: Stewart Smith
  • Date: 2009-05-15 06:57:12 UTC
  • mto: (991.1.5 for-brian)
  • mto: This revision was merged to the branch mainline in revision 1022.
  • Revision ID: stewart@flamingspork.com-20090515065712-bmionylacjmexmmm
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.

Also fix DEFAULT keyword handling for auto-increment so that it defaults to
NULL and not 0 so that the following is valid and generates two auto-inc
values:

create table t1 (a int auto_increment primary key)
insert into t1 (a) values (default);
insert into t1 (a) values (default);

Important to note that 0 is no longer magic. So this gives you duplicate
primary key error:

insert into t1 (a) values(0);
insert into t1 (a) values(0);

as you've inserted the explicit value of 0 twice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
--enable_warnings
8
8
SET SQL_WARNINGS=1;
9
9
 
10
 
create TEMPORARY table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
 
10
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
11
11
insert into t1 values (1,1),(NULL,3),(NULL,4);
12
12
delete from t1 where a=4;
13
13
insert into t1 values (NULL,5),(NULL,6);
14
14
select * from t1;
15
15
delete from t1 where a=6;
16
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
17
 
show table status like "t1";
 
16
#show table status like "t1";
18
17
replace t1 values (3,1);
19
18
ALTER TABLE t1 add c int;
20
19
replace t1 values (3,3,3);
88
87
select * from t1;
89
88
drop table t1;
90
89
 
91
 
create temporary table t1 (a int not null auto_increment primary key) /*!40102 engine=MEMORY */;
 
90
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
92
91
insert into t1 values (NULL);
93
92
insert into t1 values (-1);
94
93
select last_insert_id();
136
135
update t1 set a=0 where b=5;
137
136
select * from t1 order by b;
138
137
delete from t1 where a=0;
139
 
--error ER_BAD_NULL_ERROR
 
138
--error 1048
140
139
update t1 set a=NULL where b=6;
141
140
update t1 set a=300 where b=7;
142
141
insert into t1(a,b)values(NULL,8);
151
150
update t1 set a=0 where b=12;
152
151
select * from t1 order by b;
153
152
delete from t1 where a=0;
154
 
--error ER_BAD_NULL_ERROR
 
153
--error 1048
155
154
update t1 set a=NULL where b=13;
156
155
update t1 set a=500 where b=14;
157
156
select * from t1 order by b;
169
168
 
170
169
create table t1 (a bigint);
171
170
insert into t1 values (1), (2), (3), (0), (0);
172
 
--error ER_DUP_ENTRY
 
171
--error 1062
173
172
alter table t1 modify a bigint not null auto_increment primary key; 
174
173
select * from t1;
175
174
drop table t1;
198
197
select * from t1;
199
198
#set sql_mode= '';
200
199
alter table t1 modify b varchar(255);
201
 
--error ER_DUP_ENTRY
 
200
--error 1062
202
201
insert into t1 values (0,4);
203
202
select * from t1;
204
203
drop table t1;