~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/auto_increment.test

  • Committer: Brian Aker
  • Date: 2009-01-18 01:49:40 UTC
  • Revision ID: brian@gir-3.local-20090118014940-co9651fk7hla6gqg
Removed unused session param from list_open_tables()

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();
95
94
insert into t1 values (NULL);
96
95
select * from t1;
97
96
drop table t1;
 
97
#
 
98
# last_insert_id() madness
 
99
# Bug 314554 - Autoincrement succeeds where it should have failed
 
100
#at line 109
 
101
#create table t1 (i int not null auto_increment primary key);
 
102
#insert into t1 set i = 254;
 
103
#insert into t1 set i = null;
 
104
#select last_insert_id();
 
105
#explain extended select last_insert_id();
 
106
#--error ER_DUP_ENTRY
 
107
#insert into t1 set i = 254;
 
108
#select last_insert_id();
 
109
#--error ER_DUP_ENTRY
 
110
#insert into t1 set i = null;
 
111
#select last_insert_id();
 
112
#drop table t1;
98
113
 
99
114
create table t1 (i int not null auto_increment, key (i));
100
115
insert into t1 set i = 254;
115
130
 
116
131
drop table t1;
117
132
 
 
133
#SQL_MODE was removed from Drizzle.
118
134
create table t1(a int auto_increment,b int null,primary key(a));
 
135
#SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
119
136
insert into t1(a,b)values(NULL,1);
120
137
insert into t1(a,b)values(200,2);
121
138
insert into t1(a,b)values(0,3);
136
153
update t1 set a=0 where b=5;
137
154
select * from t1 order by b;
138
155
delete from t1 where a=0;
139
 
--error ER_BAD_NULL_ERROR
 
156
--error 1048
140
157
update t1 set a=NULL where b=6;
141
158
update t1 set a=300 where b=7;
 
159
#SQL_MODE var is not supported.
 
160
#SET SQL_MODE='';
142
161
insert into t1(a,b)values(NULL,8);
143
162
insert into t1(a,b)values(400,9);
144
163
insert into t1(a,b)values(0,10);
151
170
update t1 set a=0 where b=12;
152
171
select * from t1 order by b;
153
172
delete from t1 where a=0;
154
 
--error ER_BAD_NULL_ERROR
 
173
--error 1048
155
174
update t1 set a=NULL where b=13;
156
175
update t1 set a=500 where b=14;
157
176
select * from t1 order by b;
169
188
 
170
189
create table t1 (a bigint);
171
190
insert into t1 values (1), (2), (3), (0), (0);
172
 
--error ER_DUP_ENTRY
173
191
alter table t1 modify a bigint not null auto_increment primary key; 
174
192
select * from t1;
175
193
drop table t1;
176
194
 
177
195
# 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);
 
196
#create table t1 (a bigint);
 
197
#insert into t1 values (0), (1), (2), (3);
 
198
 
 
199
#sql_mode not supported
 
200
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
180
201
 
181
202
# Bug314567 -  ALTER TABLE causes auto_increment resequencing,
182
203
# resulting in duplicate entry since sql_mode=NO_AUTO_VALUE_ON_ZERO
183
204
#is not supported.
184
 
# NO_AUTO_VALUE_ON_ZERO is now default for Drizzle
185
205
 
186
 
alter table t1 modify a bigint not null auto_increment primary key; 
 
206
#alter table t1 modify a bigint not null auto_increment primary key; 
187
207
#set sql_mode= '';
188
 
select * from t1;
189
 
drop table t1;
 
208
#select * from t1;
 
209
#drop table t1;
190
210
 
191
211
# It also sensible to preserve zeroes if we are converting auto_increment
192
212
# column to auto_increment column (or not touching it at all, which is more
194
214
create table t1 (a int auto_increment primary key , b int null);
195
215
#sql_mode is not supported.
196
216
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
197
 
insert into t1 values (0,1),(1,2),(2,3);
198
 
select * from t1;
 
217
#insert into t1 values (0,1),(1,2),(2,3);
 
218
#select * from t1;
199
219
#set sql_mode= '';
200
220
alter table t1 modify b varchar(255);
201
 
--error ER_DUP_ENTRY
202
221
insert into t1 values (0,4);
203
222
select * from t1;
204
223
drop table t1;
297
316
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
298
317
INSERT INTO t1 VALUES(0, 0);
299
318
INSERT INTO t1 VALUES(1, 1);
 
319
--error ER_DUP_ENTRY
300
320
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
301
 
--error ER_DUP_ENTRY
302
 
INSERT INTO t1 VALUES(0,0);
303
321
DROP TABLE t1;
304
322
 
305
323
# Test of REPLACE when it does INSERT+DELETE and not UPDATE: