~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/auto_increment.test

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

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();
115
114
 
116
115
drop table t1;
117
116
 
 
117
#SQL_MODE was removed from Drizzle.
118
118
create table t1(a int auto_increment,b int null,primary key(a));
 
119
#SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
119
120
insert into t1(a,b)values(NULL,1);
120
121
insert into t1(a,b)values(200,2);
121
122
insert into t1(a,b)values(0,3);
136
137
update t1 set a=0 where b=5;
137
138
select * from t1 order by b;
138
139
delete from t1 where a=0;
139
 
--error ER_BAD_NULL_ERROR
 
140
--error 1048
140
141
update t1 set a=NULL where b=6;
141
142
update t1 set a=300 where b=7;
 
143
#SQL_MODE var is not supported.
 
144
#SET SQL_MODE='';
142
145
insert into t1(a,b)values(NULL,8);
143
146
insert into t1(a,b)values(400,9);
144
147
insert into t1(a,b)values(0,10);
151
154
update t1 set a=0 where b=12;
152
155
select * from t1 order by b;
153
156
delete from t1 where a=0;
154
 
--error ER_BAD_NULL_ERROR
 
157
--error 1048
155
158
update t1 set a=NULL where b=13;
156
159
update t1 set a=500 where b=14;
157
160
select * from t1 order by b;
169
172
 
170
173
create table t1 (a bigint);
171
174
insert into t1 values (1), (2), (3), (0), (0);
172
 
--error ER_DUP_ENTRY
173
175
alter table t1 modify a bigint not null auto_increment primary key; 
174
176
select * from t1;
175
177
drop table t1;
176
178
 
177
179
# We still should be able to preserve zero in NO_AUTO_VALUE_ON_ZERO mode
178
 
create table t1 (a bigint);
179
 
insert into t1 values (0), (1), (2), (3);
 
180
#create table t1 (a bigint);
 
181
#insert into t1 values (0), (1), (2), (3);
 
182
 
 
183
#sql_mode not supported
 
184
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
180
185
 
181
186
# Bug314567 -  ALTER TABLE causes auto_increment resequencing,
182
187
# resulting in duplicate entry since sql_mode=NO_AUTO_VALUE_ON_ZERO
183
188
#is not supported.
184
 
# NO_AUTO_VALUE_ON_ZERO is now default for Drizzle
185
189
 
186
 
alter table t1 modify a bigint not null auto_increment primary key; 
 
190
#alter table t1 modify a bigint not null auto_increment primary key; 
187
191
#set sql_mode= '';
188
 
select * from t1;
189
 
drop table t1;
 
192
#select * from t1;
 
193
#drop table t1;
190
194
 
191
195
# It also sensible to preserve zeroes if we are converting auto_increment
192
196
# column to auto_increment column (or not touching it at all, which is more
194
198
create table t1 (a int auto_increment primary key , b int null);
195
199
#sql_mode is not supported.
196
200
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
197
 
insert into t1 values (0,1),(1,2),(2,3);
198
 
select * from t1;
 
201
#insert into t1 values (0,1),(1,2),(2,3);
 
202
#select * from t1;
199
203
#set sql_mode= '';
200
204
alter table t1 modify b varchar(255);
201
 
--error ER_DUP_ENTRY
202
205
insert into t1 values (0,4);
203
206
select * from t1;
204
207
drop table t1;
297
300
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
298
301
INSERT INTO t1 VALUES(0, 0);
299
302
INSERT INTO t1 VALUES(1, 1);
 
303
--error ER_DUP_ENTRY
300
304
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
301
 
--error ER_DUP_ENTRY
302
 
INSERT INTO t1 VALUES(0,0);
303
305
DROP TABLE t1;
304
306
 
305
307
# Test of REPLACE when it does INSERT+DELETE and not UPDATE: