~clint-fewbar/ubuntu/natty/mysql-5.1/merge-5.1.49-2

« back to all changes in this revision

Viewing changes to mysql-test/suite/innodb_plugin/t/innodb.test

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-08-04 13:18:27 UTC
  • mfrom: (1.2.2 upstream) (2.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100804131827-4tjg88vr9dd49s3k
Tags: 5.1.49-1ubuntu1
* Merge from debian unstable:
  + debian/control:
     * Update maintainer according to spec.
     * Move section from "misc" to "database".
     * Added libmysqlclient16-dev an empty transitional package. 
     * Added mysql-client-core-5.1 package.
     * Suggest mailx for mysql-server-5.1
     * Add mysql-testsuite package so you can run the testsuite seperately.
  + debian/additions/my.cnf:
    * Remove language options. Error message files are located in a different directory in Mysql
      5.0. Setting the language option to use /usr/share/mysql/english breaks Mysql 5.0. Both 5.0
      and 5.1 use a different value that works. (LP: #316974)
  + Add apparmor profile:
    + debian/apparmor-profile: apparmor-profile
    + debian/rules, debian/mysql-server-5.1.files: install apparmor profile
    + debian/mysql-server-5.1.dirs: add etc/apparmor.d/fore-complain
    + debian/mysql-server-5.1.postrm: remove symlink in force-complain/ on purge.
    + debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    + debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    + debian/mysql-server-5.1.postinst: reload apparmor profiles
  * Convert the package from sysvinit to upstart:
    + debian/mysql-server-5.1.mysql.upstart: Add upstart script.
    + debian/mysql-server-5.1.mysql.init: Dropped, unused now with upstart.
    + debian/additions/mysqld_safe_syslog.cnf: Dropped, unused now with upstart.
    + debian/additons/my.cnf: Remove pid declaration and setup error logging to /var/log/mysql since
      we're not piping anything around logger anymore.
    + debian/rules, debian/mysql-server-5.1.logcheck.ignore.{paranoid,worstation},
      debian/mysql-server-5.1.logcheck.ignore.server: : Remove references to mysqld_safe
    + debian/patches/38_scripts_mysqld_safe.sh_signals.dpatch: Dropped
  * Added -fno-strict-aliasing to CFLAGS to get around mysql testsuite build failures.
  * Add Apport hook (LP: #354188):
    + debian/mysql-server-5.1.py: apport package hook
    + debian/rules: Make it installable
  * debian/mysql-server-5.1.mysql-server.logrotate: Check to see if mysql is running before
    running logrotate. (LP: #513135)
  * Make the testsuite installable. (LP: #530752)
    + debian/mysql-server-5.1.files, debian/rules: install apport package hook
  * debian/mysql-server-5.1.preinst: Set mysql user's home directory
    to /nonexistent to protect against having the /var/lib/mysql
    user-writeable. If an attacker can trick mysqld into creating
    dot files in the home directory, he could do .rhost-like attacks
    on the system. (LP: #293258)
  * debian/control: mysql-client-5.1 should depend on mysql-core-client-5.1.
    (LP: #590952) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#######################################################################
 
2
#                                                                     #
 
3
# Please, DO NOT TOUCH this file as well as the innodb.result file.   #
 
4
# These files are to be modified ONLY BY INNOBASE guys.               #
 
5
#                                                                     #
 
6
# Use innodb_mysql.[test|result] files instead.                       #
 
7
#                                                                     #
 
8
# If nevertheless you need to make some changes here, please, forward #
 
9
# your commit message                                                 #
 
10
# To: innodb_dev_ww@oracle.com                                        #
 
11
# Cc: dev-innodb@mysql.com                                            #
 
12
# (otherwise your changes may be erased).                             #
 
13
#                                                                     #
 
14
#######################################################################
 
15
 
 
16
-- source include/have_innodb_plugin.inc
 
17
 
 
18
let $MYSQLD_DATADIR= `select @@datadir`;
 
19
 
 
20
# Save the original values of some variables in order to be able to
 
21
# estimate how much they have changed during the tests. Previously this
 
22
# test assumed that e.g. rows_deleted is 0 here and after deleting 23
 
23
# rows it expected that rows_deleted will be 23. Now we do not make
 
24
# assumptions about the values of the variables at the beginning, e.g.
 
25
# rows_deleted should be 23 + "rows_deleted before the test". This allows
 
26
# the test to be run multiple times without restarting the mysqld server.
 
27
# See Bug#43309 Test main.innodb can't be run twice
 
28
-- disable_query_log
 
29
SET @innodb_thread_concurrency_orig = @@innodb_thread_concurrency;
 
30
 
 
31
SET @innodb_rows_deleted_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted');
 
32
SET @innodb_rows_inserted_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted');
 
33
SET @innodb_rows_updated_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated');
 
34
SET @innodb_row_lock_waits_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits');
 
35
SET @innodb_row_lock_current_waits_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits');
 
36
SET @innodb_row_lock_time_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time');
 
37
SET @innodb_row_lock_time_max_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max');
 
38
SET @innodb_row_lock_time_avg_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg');
 
39
-- enable_query_log
 
40
 
 
41
--disable_warnings
 
42
drop table if exists t1,t2,t3,t4;
 
43
drop database if exists mysqltest;
 
44
--enable_warnings
 
45
 
 
46
#
 
47
# Small basic test with ignore
 
48
#
 
49
 
 
50
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
 
51
 
 
52
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
 
53
select id, code, name from t1 order by id;
 
54
 
 
55
update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
 
56
select id, code, name from t1 order by id;
 
57
update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
 
58
select id, code, name from t1 order by id;
 
59
 
 
60
drop table t1;
 
61
 
 
62
#
 
63
# A bit bigger test
 
64
# The 'replace_column' statements are needed because the cardinality calculated
 
65
# by innodb is not always the same between runs
 
66
#
 
67
 
 
68
CREATE TABLE t1 (
 
69
  id int(11) NOT NULL auto_increment,
 
70
  parent_id int(11) DEFAULT '0' NOT NULL,
 
71
  level tinyint(4) DEFAULT '0' NOT NULL,
 
72
  PRIMARY KEY (id),
 
73
  KEY parent_id (parent_id),
 
74
  KEY level (level)
 
75
) engine=innodb;
 
76
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
 
77
update t1 set parent_id=parent_id+100;
 
78
select * from t1 where parent_id=102;
 
79
update t1 set id=id+1000;
 
80
-- error ER_DUP_ENTRY,1022
 
81
update t1 set id=1024 where id=1009; 
 
82
select * from t1;
 
83
update ignore t1 set id=id+1; # This will change all rows
 
84
select * from t1;
 
85
update ignore t1 set id=1023 where id=1010;
 
86
select * from t1 where parent_id=102;
 
87
--replace_column 9 #
 
88
explain select level from t1 where level=1;
 
89
--replace_column 9 #
 
90
explain select level,id from t1 where level=1;
 
91
--replace_column 9 #
 
92
explain select level,id,parent_id from t1 where level=1;
 
93
select level,id from t1 where level=1;
 
94
select level,id,parent_id from t1 where level=1;
 
95
optimize table t1;
 
96
--replace_column 7 #
 
97
show keys from t1;
 
98
drop table t1;
 
99
 
 
100
#
 
101
# Test replace
 
102
#
 
103
 
 
104
CREATE TABLE t1 (
 
105
  gesuchnr int(11) DEFAULT '0' NOT NULL,
 
106
  benutzer_id int(11) DEFAULT '0' NOT NULL,
 
107
  PRIMARY KEY (gesuchnr,benutzer_id)
 
108
) engine=innodb;
 
109
 
 
110
replace into t1 (gesuchnr,benutzer_id) values (2,1);
 
111
replace into t1 (gesuchnr,benutzer_id) values (1,1);
 
112
replace into t1 (gesuchnr,benutzer_id) values (1,1);
 
113
select * from t1;
 
114
drop table t1;
 
115
 
 
116
#
 
117
# test delete using hidden_primary_key
 
118
#
 
119
 
 
120
create table t1 (a int) engine=innodb;
 
121
insert into t1 values (1), (2);
 
122
optimize table t1;
 
123
delete from t1 where a = 1;
 
124
select * from t1;
 
125
check table t1;
 
126
drop table t1;
 
127
 
 
128
create table t1 (a int,b varchar(20)) engine=innodb;
 
129
insert into t1 values (1,""), (2,"testing");
 
130
delete from t1 where a = 1;
 
131
select * from t1;
 
132
create index skr on t1 (a);
 
133
insert into t1 values (3,""), (4,"testing");
 
134
analyze table t1;
 
135
--replace_column 7 #
 
136
show keys from t1;
 
137
drop table t1;
 
138
 
 
139
 
 
140
# Test of reading on secondary key with may be null
 
141
 
 
142
create table t1 (a int,b varchar(20),key(a)) engine=innodb;
 
143
insert into t1 values (1,""), (2,"testing");
 
144
select * from t1 where a = 1;
 
145
drop table t1;
 
146
 
 
147
#
 
148
# Test rollback
 
149
#
 
150
 
 
151
create table t1 (n int not null primary key) engine=innodb;
 
152
set autocommit=0;
 
153
insert into t1 values (4);
 
154
rollback;
 
155
select n, "after rollback" from t1;
 
156
insert into t1 values (4);
 
157
commit;
 
158
select n, "after commit" from t1;
 
159
commit;
 
160
insert into t1 values (5);
 
161
-- error ER_DUP_ENTRY
 
162
insert into t1 values (4);
 
163
commit;
 
164
select n, "after commit" from t1;
 
165
set autocommit=1;
 
166
insert into t1 values (6);
 
167
-- error ER_DUP_ENTRY
 
168
insert into t1 values (4);
 
169
select n from t1;
 
170
set autocommit=0;
 
171
#
 
172
# savepoints
 
173
#
 
174
begin;
 
175
savepoint `my_savepoint`;
 
176
insert into t1 values (7);
 
177
savepoint `savept2`;
 
178
insert into t1 values (3);
 
179
select n from t1;
 
180
savepoint savept3;
 
181
rollback to savepoint savept2;
 
182
--error 1305
 
183
rollback to savepoint savept3;
 
184
rollback to savepoint savept2;
 
185
release savepoint `my_savepoint`;
 
186
select n from t1;
 
187
-- error 1305
 
188
rollback to savepoint `my_savepoint`;
 
189
--error 1305
 
190
rollback to savepoint savept2;
 
191
insert into t1 values (8);
 
192
savepoint sv;
 
193
commit;
 
194
savepoint sv;
 
195
set autocommit=1;
 
196
# nop
 
197
rollback;
 
198
drop table t1;
 
199
 
 
200
#
 
201
# Test for commit and FLUSH TABLES WITH READ LOCK
 
202
#
 
203
 
 
204
create table t1 (n int not null primary key) engine=innodb;
 
205
start transaction;
 
206
insert into t1 values (4);
 
207
flush tables with read lock;
 
208
#
 
209
# Current code can't handle a read lock in middle of transaction
 
210
#--error 1223;
 
211
commit;
 
212
unlock tables;
 
213
commit;
 
214
select * from t1;
 
215
drop table t1;
 
216
 
 
217
#
 
218
# Testing transactions
 
219
#
 
220
 
 
221
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb;
 
222
begin;
 
223
insert into t1 values(1,'hamdouni');
 
224
select id as afterbegin_id,nom as afterbegin_nom from t1;
 
225
rollback;
 
226
select id as afterrollback_id,nom as afterrollback_nom from t1;
 
227
set autocommit=0;
 
228
insert into t1 values(2,'mysql');
 
229
select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
 
230
rollback;
 
231
select id as afterrollback_id,nom as afterrollback_nom from t1;
 
232
set autocommit=1;
 
233
drop table t1;
 
234
 
 
235
#
 
236
# Simple not autocommit test
 
237
 
238
 
 
239
CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
 
240
insert into t1 values ('pippo', 12);
 
241
-- error ER_DUP_ENTRY
 
242
insert into t1 values ('pippo', 12); # Gives error
 
243
delete from t1;
 
244
delete from t1 where id = 'pippo';
 
245
select * from t1;
 
246
 
 
247
insert into t1 values ('pippo', 12);
 
248
set autocommit=0;
 
249
delete from t1;
 
250
rollback;
 
251
select * from t1;
 
252
delete from t1;
 
253
commit;
 
254
select * from t1;
 
255
drop table t1;
 
256
 
 
257
#
 
258
# Test of active transactions
 
259
#
 
260
 
 
261
create table t1 (a integer) engine=innodb;
 
262
start transaction;
 
263
rename table t1 to t2;
 
264
create table t1 (b integer) engine=innodb;
 
265
insert into t1 values (1);
 
266
rollback;
 
267
drop table t1;
 
268
rename table t2 to t1;
 
269
drop table t1;
 
270
set autocommit=1;
 
271
 
 
272
#
 
273
# The following simple tests failed at some point
 
274
#
 
275
 
 
276
CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb;
 
277
INSERT INTO t1 VALUES (1, 'Jochen');
 
278
select * from t1;
 
279
drop table t1;
 
280
 
 
281
CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb;
 
282
set autocommit=0;
 
283
INSERT INTO t1  SET _userid='marc@anyware.co.uk';
 
284
COMMIT;
 
285
SELECT * FROM t1;
 
286
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
 
287
drop table t1;
 
288
set autocommit=1;
 
289
 
 
290
#
 
291
# Test when reading on part of unique key
 
292
#
 
293
CREATE TABLE t1 (
 
294
  user_id int(10) DEFAULT '0' NOT NULL,
 
295
  name varchar(100),
 
296
  phone varchar(100),
 
297
  ref_email varchar(100) DEFAULT '' NOT NULL,
 
298
  detail varchar(200),
 
299
  PRIMARY KEY (user_id,ref_email)
 
300
)engine=innodb;
 
301
 
 
302
INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
 
303
select * from t1 where user_id=10292;
 
304
INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
 
305
select * from t1 where user_id=10292;
 
306
select * from t1 where user_id>=10292;
 
307
select * from t1 where user_id>10292;
 
308
select * from t1 where user_id<10292;
 
309
drop table t1;
 
310
 
 
311
#
 
312
# Test that keys are created in right order
 
313
#
 
314
 
 
315
CREATE TABLE t1 (a int not null, b int not null,c int not null,
 
316
key(a),primary key(a,b), unique(c),key(a),unique(b));
 
317
--replace_column 7 #
 
318
show index from t1;
 
319
drop table t1;
 
320
 
 
321
#
 
322
# Test of ALTER TABLE and innodb tables
 
323
#
 
324
 
 
325
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
 
326
alter table t1 engine=innodb;
 
327
insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
 
328
select * from t1;
 
329
update t1 set col2='7' where col1='4';
 
330
select * from t1;
 
331
alter table t1 add co3 int not null;
 
332
select * from t1;
 
333
update t1 set col2='9' where col1='2';
 
334
select * from t1;
 
335
drop table t1;
 
336
 
 
337
#
 
338
# INSERT INTO innodb tables
 
339
#
 
340
 
 
341
create table t1 (a int not null , b int, primary key (a)) engine = innodb;
 
342
create table t2 (a int not null , b int, primary key (a)) engine = myisam;
 
343
insert into t1 VALUES (1,3) , (2,3), (3,3);
 
344
select * from t1;
 
345
insert into t2 select * from t1;
 
346
select * from t2;
 
347
delete from t1 where b = 3;
 
348
select * from t1;
 
349
insert into t1 select * from t2;
 
350
select * from t1;
 
351
select * from t2;
 
352
drop table t1,t2;
 
353
 
 
354
#
 
355
# ORDER BY on not primary key
 
356
#
 
357
 
 
358
CREATE TABLE t1 (
 
359
  user_name varchar(12),
 
360
  password text,
 
361
  subscribed char(1),
 
362
  user_id int(11) DEFAULT '0' NOT NULL,
 
363
  quota bigint(20),
 
364
  weight double,
 
365
  access_date date,
 
366
  access_time time,
 
367
  approved datetime,
 
368
  dummy_primary_key int(11) NOT NULL auto_increment,
 
369
  PRIMARY KEY (dummy_primary_key)
 
370
) ENGINE=innodb;
 
371
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
 
372
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
 
373
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
 
374
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
 
375
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
 
376
select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
 
377
drop table t1;
 
378
 
 
379
#
 
380
# Testing of tables without primary keys
 
381
#
 
382
 
 
383
CREATE TABLE t1 (
 
384
  id int(11) NOT NULL auto_increment,
 
385
  parent_id int(11) DEFAULT '0' NOT NULL,
 
386
  level tinyint(4) DEFAULT '0' NOT NULL,
 
387
  KEY (id),
 
388
  KEY parent_id (parent_id),
 
389
  KEY level (level)
 
390
) engine=innodb;
 
391
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
 
392
INSERT INTO t1 values (179,5,2);
 
393
update t1 set parent_id=parent_id+100;
 
394
select * from t1 where parent_id=102;
 
395
update t1 set id=id+1000;
 
396
update t1 set id=1024 where id=1009; 
 
397
select * from t1;
 
398
update ignore t1 set id=id+1; # This will change all rows
 
399
select * from t1;
 
400
update ignore t1 set id=1023 where id=1010;
 
401
select * from t1 where parent_id=102;
 
402
--replace_column 9 #
 
403
explain select level from t1 where level=1;
 
404
select level,id from t1 where level=1;
 
405
select level,id,parent_id from t1 where level=1;
 
406
select level,id from t1 where level=1 order by id;
 
407
delete from t1 where level=1;
 
408
select * from t1;
 
409
drop table t1;
 
410
 
 
411
#
 
412
# Test of index only reads
 
413
#
 
414
CREATE TABLE t1 (
 
415
   sca_code char(6) NOT NULL,
 
416
   cat_code char(6) NOT NULL,
 
417
   sca_desc varchar(50),
 
418
   lan_code char(2) NOT NULL,
 
419
   sca_pic varchar(100),
 
420
   sca_sdesc varchar(50),
 
421
   sca_sch_desc varchar(16),
 
422
   PRIMARY KEY (sca_code, cat_code, lan_code),
 
423
   INDEX sca_pic (sca_pic)
 
424
) engine = innodb ;
 
425
 
 
426
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
 
427
select count(*) from t1 where sca_code = 'PD';
 
428
select count(*) from t1 where sca_code <= 'PD';
 
429
select count(*) from t1 where sca_pic is null;
 
430
# this should be fixed by MySQL (see Bug #51451)
 
431
# now that http://bugs.mysql.com/49838 is fixed the following ALTER does
 
432
# copy the table instead of failing
 
433
# --error ER_WRONG_NAME_FOR_INDEX
 
434
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
 
435
alter table t1 drop index sca_pic;
 
436
alter table t1 add index sca_pic (cat_code, sca_pic);
 
437
select count(*) from t1 where sca_code='PD' and sca_pic is null;
 
438
select count(*) from t1 where cat_code='E';
 
439
 
 
440
# this should be fixed by MySQL (see Bug #51451)
 
441
--error ER_WRONG_NAME_FOR_INDEX
 
442
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
 
443
alter table t1 drop index sca_pic;
 
444
alter table t1 add index (sca_pic, cat_code);
 
445
select count(*) from t1 where sca_code='PD' and sca_pic is null;
 
446
select count(*) from t1 where sca_pic >= 'n';
 
447
select sca_pic from t1 where sca_pic is null;
 
448
update t1 set sca_pic="test" where sca_pic is null;
 
449
delete from t1 where sca_code='pd';
 
450
drop table t1;
 
451
 
 
452
#
 
453
# Test of opening table twice and timestamps
 
454
#
 
455
set @a:=now();
 
456
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
 
457
insert into t1 (a) values(1),(2),(3);
 
458
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
 
459
select a from t1 natural join t1 as t2 where b >= @a order by a;
 
460
update t1 set a=5 where a=1;
 
461
select a from t1;
 
462
drop table t1;
 
463
 
 
464
#
 
465
# Test with variable length primary key
 
466
#
 
467
create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
 
468
insert into t1 values("hello",1),("world",2);
 
469
select * from t1 order by b desc;
 
470
optimize table t1;
 
471
--replace_column 7 #
 
472
show keys from t1;
 
473
drop table t1;
 
474
 
 
475
#
 
476
# Test of create index with NULL columns
 
477
#
 
478
create table t1 (i int, j int ) ENGINE=innodb;
 
479
insert into t1 values (1,2);
 
480
select * from t1 where i=1 and j=2;
 
481
create index ax1 on t1 (i,j);
 
482
select * from t1 where i=1 and j=2;
 
483
drop table t1;
 
484
 
 
485
#
 
486
# Test min-max optimization
 
487
#
 
488
 
 
489
CREATE TABLE t1 (
 
490
  a int3 unsigned NOT NULL,
 
491
  b int1 unsigned NOT NULL,
 
492
  UNIQUE (a, b)
 
493
) ENGINE = innodb;
 
494
 
 
495
INSERT INTO t1 VALUES (1, 1);
 
496
SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
 
497
drop table t1;
 
498
 
 
499
#
 
500
# Test INSERT DELAYED
 
501
#
 
502
 
 
503
CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;
 
504
# Can't test this in 3.23
 
505
# INSERT DELAYED INTO t1 VALUES (1);
 
506
INSERT INTO t1 VALUES (1);
 
507
SELECT * FROM t1;
 
508
DROP TABLE t1;
 
509
 
 
510
 
 
511
#
 
512
# Crash when using many tables (Test case by Jeremy D Zawodny)
 
513
#
 
514
 
 
515
create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;
 
516
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
 
517
--replace_column 9 #
 
518
explain select * from t1 where a > 0 and a < 50;
 
519
drop table t1;
 
520
 
 
521
#
 
522
# Test lock tables
 
523
#
 
524
 
 
525
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
 
526
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 
527
LOCK TABLES t1 WRITE;
 
528
--error ER_DUP_ENTRY
 
529
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 
530
select id from t1;
 
531
select id from t1;
 
532
UNLOCK TABLES;
 
533
DROP TABLE t1;
 
534
 
 
535
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
 
536
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 
537
LOCK TABLES t1 WRITE;
 
538
begin;
 
539
--error ER_DUP_ENTRY
 
540
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 
541
select id from t1;
 
542
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
 
543
commit;
 
544
select id,id3 from t1;
 
545
UNLOCK TABLES;
 
546
DROP TABLE t1;
 
547
 
 
548
#
 
549
# Test prefix key
 
550
#
 
551
create table t1 (a char(20), unique (a(5))) engine=innodb;
 
552
drop table t1;
 
553
create table t1 (a char(20), index (a(5))) engine=innodb;
 
554
show create table t1;
 
555
drop table t1;
 
556
 
 
557
#
 
558
# Test using temporary table and auto_increment
 
559
#
 
560
 
 
561
create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;
 
562
insert into t1 values (NULL),(NULL),(NULL);
 
563
delete from t1 where a=3;
 
564
insert into t1 values (NULL);
 
565
select * from t1;
 
566
alter table t1 add b int;
 
567
select * from t1;
 
568
drop table t1;
 
569
 
 
570
#Slashdot bug
 
571
create table t1
 
572
 (
 
573
  id int auto_increment primary key,
 
574
  name varchar(32) not null,
 
575
  value text not null,
 
576
  uid int not null,
 
577
  unique key(name,uid)
 
578
 ) engine=innodb;
 
579
insert into t1 values (1,'one','one value',101),
 
580
 (2,'two','two value',102),(3,'three','three value',103);
 
581
set insert_id=5;
 
582
replace into t1 (value,name,uid) values ('other value','two',102);
 
583
delete from t1 where uid=102;
 
584
set insert_id=5;
 
585
replace into t1 (value,name,uid) values ('other value','two',102);
 
586
set insert_id=6;
 
587
replace into t1 (value,name,uid) values ('other value','two',102);
 
588
select * from t1;
 
589
drop table t1;
 
590
 
 
591
#
 
592
# Test DROP DATABASE
 
593
#
 
594
 
 
595
create database mysqltest;
 
596
create table mysqltest.t1 (a int not null) engine= innodb;
 
597
insert into mysqltest.t1 values(1);
 
598
create table mysqltest.t2 (a int not null) engine= myisam;
 
599
insert into mysqltest.t2 values(1);
 
600
create table mysqltest.t3 (a int not null) engine= heap;
 
601
insert into mysqltest.t3 values(1);
 
602
commit;
 
603
drop database mysqltest;
 
604
# Don't check error message
 
605
--error 1049
 
606
show tables from mysqltest;
 
607
 
 
608
#
 
609
# Test truncate table with and without auto_commit
 
610
#
 
611
 
 
612
set autocommit=0;
 
613
create table t1 (a int not null) engine= innodb;
 
614
insert into t1 values(1),(2);
 
615
truncate table t1;
 
616
commit;
 
617
truncate table t1;
 
618
truncate table t1;
 
619
select * from t1;
 
620
insert into t1 values(1),(2);
 
621
delete from t1;
 
622
select * from t1;
 
623
commit;
 
624
drop table t1;
 
625
set autocommit=1;
 
626
 
 
627
create table t1 (a int not null) engine= innodb;
 
628
insert into t1 values(1),(2);
 
629
truncate table t1;
 
630
insert into t1 values(1),(2);
 
631
select * from t1;
 
632
truncate table t1;
 
633
insert into t1 values(1),(2);
 
634
delete from t1;
 
635
select * from t1;
 
636
drop table t1;
 
637
 
 
638
#
 
639
# Test of how ORDER BY works when doing it on the whole table
 
640
#
 
641
 
 
642
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;
 
643
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
 
644
--replace_column 9 #
 
645
explain select * from t1 order by a;
 
646
--replace_column 9 #
 
647
explain select * from t1 order by b;
 
648
--replace_column 9 #
 
649
explain select * from t1 order by c;
 
650
--replace_column 9 #
 
651
explain select a from t1 order by a;
 
652
--replace_column 9 #
 
653
explain select b from t1 order by b;
 
654
--replace_column 9 #
 
655
explain select a,b from t1 order by b;
 
656
--replace_column 9 #
 
657
explain select a,b from t1;
 
658
--replace_column 9 #
 
659
explain select a,b,c from t1;
 
660
drop table t1;
 
661
 
 
662
#
 
663
# Check describe
 
664
#
 
665
 
 
666
create table t1 (t int not null default 1, key (t)) engine=innodb;
 
667
desc t1;
 
668
drop table t1;
 
669
 
 
670
#
 
671
# Test of multi-table-delete
 
672
#
 
673
 
 
674
CREATE TABLE t1 (
 
675
  number bigint(20) NOT NULL default '0',
 
676
  cname char(15) NOT NULL default '',
 
677
  carrier_id smallint(6) NOT NULL default '0',
 
678
  privacy tinyint(4) NOT NULL default '0',
 
679
  last_mod_date timestamp NOT NULL,
 
680
  last_mod_id smallint(6) NOT NULL default '0',
 
681
  last_app_date timestamp NOT NULL,
 
682
  last_app_id smallint(6) default '-1',
 
683
  version smallint(6) NOT NULL default '0',
 
684
  assigned_scps int(11) default '0',
 
685
  status tinyint(4) default '0'
 
686
) ENGINE=InnoDB;
 
687
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
 
688
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
 
689
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
 
690
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
 
691
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
 
692
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
 
693
CREATE TABLE t2 (
 
694
  number bigint(20) NOT NULL default '0',
 
695
  cname char(15) NOT NULL default '',
 
696
  carrier_id smallint(6) NOT NULL default '0',
 
697
  privacy tinyint(4) NOT NULL default '0',
 
698
  last_mod_date timestamp NOT NULL,
 
699
  last_mod_id smallint(6) NOT NULL default '0',
 
700
  last_app_date timestamp NOT NULL,
 
701
  last_app_id smallint(6) default '-1',
 
702
  version smallint(6) NOT NULL default '0',
 
703
  assigned_scps int(11) default '0',
 
704
  status tinyint(4) default '0'
 
705
) ENGINE=InnoDB;
 
706
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
 
707
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
 
708
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
 
709
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
 
710
select * from t1;
 
711
select * from t2;
 
712
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
 
713
select * from t1;
 
714
select * from t2; 
 
715
select * from t2;
 
716
drop table t1,t2;
 
717
 
 
718
#
 
719
# A simple test with some isolation levels
 
720
# TODO: Make this into a test using replication to really test how
 
721
# this works.
 
722
#
 
723
 
 
724
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
 
725
 
 
726
BEGIN;
 
727
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
728
SELECT @@tx_isolation,@@global.tx_isolation;
 
729
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
 
730
select id, code, name from t1 order by id;
 
731
COMMIT;
 
732
 
 
733
BEGIN;
 
734
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
 
735
insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
 
736
select id, code, name from t1 order by id;
 
737
COMMIT;
 
738
 
 
739
SET binlog_format='MIXED';
 
740
BEGIN;
 
741
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
 
742
insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
 
743
select id, code, name from t1 order by id;
 
744
COMMIT;
 
745
DROP TABLE t1;
 
746
 
 
747
#
 
748
# Test of multi-table-update
 
749
#
 
750
create table t1 (n int(10), d int(10)) engine=innodb;
 
751
create table t2 (n int(10), d int(10)) engine=innodb;
 
752
insert into t1 values(1,1),(1,2);
 
753
insert into t2 values(1,10),(2,20);
 
754
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
 
755
select * from t1;
 
756
select * from t2;
 
757
drop table t1,t2;
 
758
 
 
759
#
 
760
# Bug #29136    erred multi-delete on trans table does not rollback 
 
761
#
 
762
 
 
763
# prepare
 
764
--disable_warnings
 
765
drop table if exists t1, t2;
 
766
--enable_warnings
 
767
CREATE TABLE t1 (a int, PRIMARY KEY (a));
 
768
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
 
769
create trigger trg_del_t2 after  delete on t2 for each row
 
770
       insert into t1 values (1);
 
771
insert into t1 values (1);
 
772
insert into t2 values (1),(2);
 
773
 
 
774
 
 
775
# exec cases A, B - see multi_update.test
 
776
 
 
777
# A. send_error() w/o send_eof() branch
 
778
 
 
779
--error ER_DUP_ENTRY
 
780
delete t2 from t2;
 
781
 
 
782
# check
 
783
 
 
784
select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
 
785
 
 
786
# cleanup bug#29136
 
787
 
 
788
drop table t1, t2;
 
789
 
 
790
 
 
791
#
 
792
# Bug #29136    erred multi-delete on trans table does not rollback 
 
793
#
 
794
 
 
795
# prepare
 
796
--disable_warnings
 
797
drop table if exists t1, t2;
 
798
--enable_warnings
 
799
CREATE TABLE t1 (a int, PRIMARY KEY (a));
 
800
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
 
801
create trigger trg_del_t2 after  delete on t2 for each row
 
802
       insert into t1 values (1);
 
803
insert into t1 values (1);
 
804
insert into t2 values (1),(2);
 
805
 
 
806
 
 
807
# exec cases A, B - see multi_update.test
 
808
 
 
809
# A. send_error() w/o send_eof() branch
 
810
 
 
811
--error ER_DUP_ENTRY
 
812
delete t2 from t2;
 
813
 
 
814
# check
 
815
 
 
816
select count(*) from t2 /* must be 2 as restored after rollback caused by the error */;
 
817
 
 
818
# cleanup bug#29136
 
819
 
 
820
drop table t1, t2;
 
821
 
 
822
 
 
823
#
 
824
# Testing of IFNULL
 
825
#
 
826
create table t1 (a int, b int) engine=innodb;
 
827
insert into t1 values(20,null);
 
828
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
 
829
t2.b=t3.a;
 
830
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
 
831
t2.b=t3.a order by 1;
 
832
insert into t1 values(10,null);
 
833
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
 
834
t2.b=t3.a order by 1;
 
835
drop table t1;
 
836
 
 
837
#
 
838
# Test of read_through not existing const_table
 
839
#
 
840
 
 
841
create table t1 (a varchar(10) not null) engine=myisam;
 
842
create table t2 (b varchar(10) not null unique) engine=innodb;
 
843
select t1.a from t1,t2 where t1.a=t2.b;
 
844
drop table t1,t2;
 
845
create table t1 (a int not null, b int, primary key (a)) engine = innodb;
 
846
create table t2 (a int not null, b int, primary key (a)) engine = innodb;
 
847
insert into t1 values (10, 20);
 
848
insert into t2 values (10, 20);
 
849
update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
 
850
drop table t1,t2;
 
851
 
 
852
#
 
853
# Test of multi-table-delete with foreign key constraints
 
854
#
 
855
 
 
856
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
 
857
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
 
858
insert into t1 set id=1;
 
859
insert into t2 set id=1, t1_id=1;
 
860
delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
 
861
select * from t1;
 
862
select * from t2;
 
863
drop table t2,t1;
 
864
CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
 
865
CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
 
866
INSERT INTO t1 VALUES(1);
 
867
INSERT INTO t2 VALUES(1, 1);
 
868
SELECT * from t1;
 
869
UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
 
870
SELECT * from t1;
 
871
UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
 
872
SELECT * from t1;
 
873
DROP TABLE t1,t2;
 
874
 
 
875
#
 
876
# Test of range_optimizer
 
877
#
 
878
 
 
879
set autocommit=0;
 
880
 
 
881
CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
 
882
 
 
883
CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
 
884
 
 
885
CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB;
 
886
 
 
887
INSERT INTO t3 VALUES("my-test-1", "my-test-2");
 
888
COMMIT;
 
889
 
 
890
INSERT INTO t1 VALUES("this-key", "will disappear");
 
891
INSERT INTO t2 VALUES("this-key", "will also disappear");
 
892
DELETE FROM t3 WHERE id1="my-test-1";
 
893
 
 
894
SELECT * FROM t1;
 
895
SELECT * FROM t2;
 
896
SELECT * FROM t3;
 
897
ROLLBACK;
 
898
 
 
899
SELECT * FROM t1;
 
900
SELECT * FROM t2;
 
901
SELECT * FROM t3;
 
902
SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE;
 
903
COMMIT;
 
904
set autocommit=1;
 
905
DROP TABLE t1,t2,t3;
 
906
 
 
907
#
 
908
# Check update with conflicting key
 
909
#
 
910
 
 
911
CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb;
 
912
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
 
913
# We need the a < 1000 test here to quard against the halloween problems
 
914
UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
 
915
SELECT * from t1;
 
916
drop table t1;
 
917
 
 
918
CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
 
919
CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
 
920
SET AUTOCOMMIT=0;
 
921
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
 
922
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
 
923
ROLLBACK;
 
924
SELECT * FROM t1;
 
925
drop table  t1,t2;
 
926
create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
 
927
insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
 
928
select distinct  parent,child   from t1   order by parent;
 
929
drop table t1;
 
930
 
 
931
#
 
932
# Test that MySQL priorities clustered indexes
 
933
#
 
934
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
 
935
create table t2 (a int not null auto_increment primary key, b int);
 
936
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
 
937
insert into t2 (a) select b from t1;
 
938
insert into t1 (b) select b from t2;
 
939
insert into t2 (a) select b from t1;
 
940
insert into t1 (a) select b from t2;
 
941
insert into t2 (a) select b from t1;
 
942
insert into t1 (a) select b from t2;
 
943
insert into t2 (a) select b from t1;
 
944
insert into t1 (a) select b from t2;
 
945
insert into t2 (a) select b from t1;
 
946
insert into t1 (a) select b from t2;
 
947
select count(*) from t1;
 
948
--replace_column 9 #
 
949
explain select * from t1 where c between 1 and 2500;
 
950
update t1 set c=a;
 
951
--replace_column 9 #
 
952
explain select * from t1 where c between 1 and 2500;
 
953
drop table t1,t2;
 
954
 
 
955
#
 
956
# Test of UPDATE ... ORDER BY
 
957
#
 
958
 
 
959
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb;
 
960
 
 
961
insert into t1 (id) values (null),(null),(null),(null),(null);
 
962
update t1 set fk=69 where fk is null order by id limit 1;
 
963
SELECT * from t1;
 
964
drop table t1;
 
965
 
 
966
create table t1 (a int not null, b int not null, key (a));
 
967
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
 
968
SET @tmp=0;
 
969
update t1 set b=(@tmp:=@tmp+1) order by a;
 
970
update t1 set b=99 where a=1 order by b asc limit 1;
 
971
update t1 set b=100 where a=1 order by b desc limit 2;
 
972
update t1 set a=a+10+b where a=1 order by b;
 
973
select * from t1 order by a,b;
 
974
drop table t1;
 
975
 
 
976
#
 
977
# Test of multi-table-updates (bug #1980).
 
978
#
 
979
 
 
980
create table t1 ( c char(8) not null ) engine=innodb;
 
981
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
 
982
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
 
983
 
 
984
alter table t1 add b char(8) not null;
 
985
alter table t1 add a char(8) not null;
 
986
alter table t1 add primary key (a,b,c);
 
987
update t1 set a=c, b=c;
 
988
 
 
989
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
 
990
insert into t2 select * from t1;
 
991
 
 
992
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
 
993
drop table t1,t2;
 
994
 
 
995
#
 
996
# test autoincrement with TRUNCATE
 
997
#
 
998
 
 
999
SET AUTOCOMMIT=1;
 
1000
create table t1 (a integer auto_increment primary key) engine=innodb;
 
1001
insert into t1 (a) values (NULL),(NULL);
 
1002
truncate table t1;
 
1003
insert into t1 (a) values (NULL),(NULL);
 
1004
SELECT * from t1;
 
1005
drop table t1;
 
1006
 
 
1007
#
 
1008
# Test dictionary handling with spaceand quoting
 
1009
#
 
1010
 
 
1011
CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB;
 
1012
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`)  ON DELETE CASCADE ) ENGINE=INNODB;
 
1013
#show create table t2;
 
1014
drop table t2,t1;
 
1015
 
 
1016
#
 
1017
# Test of multi updated and foreign keys
 
1018
#
 
1019
 
 
1020
create table `t1` (`id` int( 11 ) not null  ,primary key ( `id` )) engine = innodb;
 
1021
insert into `t1`values ( 1 ) ;
 
1022
create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
 
1023
insert into `t2`values ( 1 ) ;
 
1024
create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
 
1025
insert into `t3`values ( 1 ) ;
 
1026
--error 1451
 
1027
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 
1028
--error 1451
 
1029
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 
1030
--error 1054
 
1031
update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 
1032
drop table t3,t2,t1;
 
1033
 
 
1034
#
 
1035
# test for recursion depth limit
 
1036
#
 
1037
create table t1(
 
1038
        id int primary key,
 
1039
        pid int,
 
1040
        index(pid),
 
1041
        foreign key(pid) references t1(id) on delete cascade) engine=innodb;
 
1042
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
 
1043
        (8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
 
1044
-- error 1451
 
1045
delete from t1 where id=0;
 
1046
delete from t1 where id=15;
 
1047
delete from t1 where id=0;
 
1048
 
 
1049
drop table t1;
 
1050
 
 
1051
#
 
1052
# Test timestamps
 
1053
#
 
1054
 
 
1055
CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB;
 
1056
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
 
1057
(stamp))ENGINE=InnoDB;
 
1058
insert into t1 values (1),(2),(3);
 
1059
# Note that timestamp 3 is wrong
 
1060
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
 
1061
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
 
1062
'20020204120000' GROUP BY col1;
 
1063
drop table t1,t2;
 
1064
 
 
1065
#
 
1066
# Test by Francois MASUREL
 
1067
#
 
1068
 
 
1069
CREATE TABLE t1 (
 
1070
  `id` int(10) unsigned NOT NULL auto_increment,
 
1071
  `id_object` int(10) unsigned default '0',
 
1072
  `id_version` int(10) unsigned NOT NULL default '1',
 
1073
  `label` varchar(100) NOT NULL default '',
 
1074
  `description` text,
 
1075
  PRIMARY KEY  (`id`),
 
1076
  KEY `id_object` (`id_object`),
 
1077
  KEY `id_version` (`id_version`)
 
1078
) ENGINE=InnoDB;
 
1079
 
 
1080
INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
 
1081
 
 
1082
CREATE TABLE t2 (
 
1083
  `id` int(10) unsigned NOT NULL auto_increment,
 
1084
  `id_version` int(10) unsigned NOT NULL default '1',
 
1085
  PRIMARY KEY  (`id`),
 
1086
  KEY `id_version` (`id_version`)
 
1087
) ENGINE=InnoDB;
 
1088
 
 
1089
INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
 
1090
 
 
1091
SELECT t2.id, t1.`label` FROM t2 INNER JOIN
 
1092
(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl 
 
1093
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
 
1094
drop table t1,t2;
 
1095
 
 
1096
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
 
1097
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
 
1098
create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
 
1099
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
 
1100
insert t2 select * from t1;
 
1101
insert t3 select * from t1;
 
1102
checksum table t1, t2, t3, t4 quick;
 
1103
checksum table t1, t2, t3, t4;
 
1104
checksum table t1, t2, t3, t4 extended;
 
1105
#show table status;
 
1106
drop table t1,t2,t3;
 
1107
 
 
1108
#
 
1109
# Test problem with refering to different fields in same table in UNION
 
1110
# (Bug #2552)
 
1111
#
 
1112
create table t1 (id int,  name char(10) not null,  name2 char(10) not null) engine=innodb;
 
1113
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
 
1114
select trim(name2) from t1  union all  select trim(name) from t1 union all select trim(id) from t1;
 
1115
drop table t1;
 
1116
 
 
1117
#
 
1118
# Bug2160
 
1119
#
 
1120
create table t1 (a int) engine=innodb;
 
1121
create table t2 like t1;
 
1122
drop table t1,t2;
 
1123
 
 
1124
#
 
1125
# Test of automaticly created foreign keys
 
1126
#
 
1127
 
 
1128
create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb;
 
1129
create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb;
 
1130
show create table t1;
 
1131
show create table t2;
 
1132
create index id on t2 (id);
 
1133
show create table t2;
 
1134
create index id2 on t2 (id);
 
1135
show create table t2;
 
1136
drop index id2 on t2;
 
1137
--error ER_DROP_INDEX_FK
 
1138
drop index id on t2;
 
1139
show create table t2;
 
1140
drop table t2;
 
1141
 
 
1142
create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
 
1143
show create table t2;
 
1144
create unique index id on t2 (id,id2);
 
1145
show create table t2;
 
1146
drop table t2;
 
1147
 
 
1148
# Check foreign key columns created in different order than key columns
 
1149
create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
 
1150
show create table t2;
 
1151
drop table t2;
 
1152
 
 
1153
create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
 
1154
show create table t2;
 
1155
drop table t2;
 
1156
 
 
1157
create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
 
1158
show create table t2;
 
1159
drop table t2;
 
1160
 
 
1161
create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
 
1162
show create table t2;
 
1163
drop table t2;
 
1164
 
 
1165
create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
 
1166
show create table t2;
 
1167
alter table t2 add index id_test (id), add index id_test2 (id,id2);
 
1168
show create table t2;
 
1169
drop table t2;
 
1170
 
 
1171
# Test error handling
 
1172
 
 
1173
# Embedded server doesn't chdir to data directory
 
1174
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1175
--error ER_WRONG_FK_DEF
 
1176
create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
 
1177
 
 
1178
# bug#3749
 
1179
 
 
1180
create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
 
1181
show create table t2;
 
1182
drop table t2;
 
1183
create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
 
1184
show create table t2;
 
1185
drop table t2, t1;
 
1186
 
 
1187
 
 
1188
#
 
1189
# Bug #6126: Duplicate columns in keys gives misleading error message
 
1190
#
 
1191
--error 1060
 
1192
create table t1 (c char(10), index (c,c)) engine=innodb;
 
1193
--error 1060
 
1194
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
 
1195
--error 1060
 
1196
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
 
1197
--error 1060
 
1198
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
 
1199
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
 
1200
--error 1060
 
1201
alter table t1 add key (c1,c1);
 
1202
--error 1060
 
1203
alter table t1 add key (c2,c1,c1);
 
1204
--error 1060
 
1205
alter table t1 add key (c1,c2,c1);
 
1206
--error 1060
 
1207
alter table t1 add key (c1,c1,c2);
 
1208
drop table t1;
 
1209
 
 
1210
#
 
1211
# Bug #4082: integer truncation
 
1212
#
 
1213
 
 
1214
create table t1(a int(1) , b int(1)) engine=innodb;
 
1215
insert into t1 values ('1111', '3333');
 
1216
select distinct concat(a, b) from t1;
 
1217
drop table t1;
 
1218
 
 
1219
#
 
1220
# BUG#7709 test case - Boolean fulltext query against unsupported 
 
1221
#                      engines does not fail
 
1222
#
 
1223
 
 
1224
CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
 
1225
--error 1214
 
1226
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
 
1227
DROP TABLE t1;
 
1228
 
 
1229
#
 
1230
# check null values #1
 
1231
#
 
1232
 
 
1233
--disable_warnings
 
1234
CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY  (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
1235
INSERT INTO t1 VALUES (1),(2),(3);
 
1236
CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY  (b_id), KEY  (b_a), 
 
1237
                CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
1238
--enable_warnings
 
1239
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
 
1240
SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
 
1241
DROP TABLE t2;
 
1242
DROP TABLE t1;
 
1243
 
 
1244
#
 
1245
# Bug#11816 - Truncate table doesn't work with temporary innodb tables
 
1246
# This is not an innodb bug, but we test it using innodb.
 
1247
#
 
1248
create temporary table t1 (a int) engine=innodb;
 
1249
insert into t1 values (4711);
 
1250
truncate t1;
 
1251
insert into t1 values (42);
 
1252
select * from t1;
 
1253
drop table t1;
 
1254
# Show that it works with permanent tables too.
 
1255
create table t1 (a int) engine=innodb;
 
1256
insert into t1 values (4711);
 
1257
truncate t1;
 
1258
insert into t1 values (42);
 
1259
select * from t1;
 
1260
drop table t1;
 
1261
 
 
1262
#
 
1263
# Bug #13025  Server crash during filesort      
 
1264
#
 
1265
 
 
1266
create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb;
 
1267
insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
 
1268
select * from t1 order by a,b,c,d;
 
1269
explain select * from t1 order by a,b,c,d;
 
1270
drop table t1;
 
1271
 
 
1272
#
 
1273
# BUG#11039,#13218 Wrong key length in min()
 
1274
#
 
1275
 
 
1276
create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
 
1277
insert into t1 values ('8', '6'), ('4', '7');
 
1278
select min(a) from t1;
 
1279
select min(b) from t1 where a='8';
 
1280
drop table t1;
 
1281
 
 
1282
# End of 4.1 tests
 
1283
 
 
1284
#
 
1285
# range optimizer problem
 
1286
#
 
1287
 
 
1288
create table t1 (x bigint unsigned not null primary key) engine=innodb;
 
1289
insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
 
1290
select * from t1;
 
1291
select count(*) from t1 where x>0;
 
1292
select count(*) from t1 where x=0;
 
1293
select count(*) from t1 where x<0;
 
1294
select count(*) from t1 where x < -16;
 
1295
select count(*) from t1 where x = -16;
 
1296
explain select count(*) from t1 where x > -16;
 
1297
select count(*) from t1 where x > -16;
 
1298
select * from t1 where x > -16;
 
1299
select count(*) from t1 where x = 18446744073709551601;
 
1300
drop table t1;
 
1301
 
 
1302
 
 
1303
# Test for testable InnoDB status variables. This test
 
1304
# uses previous ones(pages_created, rows_deleted, ...).
 
1305
--replace_result 8192 8191
 
1306
SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
 
1307
SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
 
1308
SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';
 
1309
SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted';
 
1310
SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated';
 
1311
 
 
1312
# Test for row locks InnoDB status variables.
 
1313
SELECT variable_value - @innodb_row_lock_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits';
 
1314
SELECT variable_value - @innodb_row_lock_current_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits';
 
1315
SELECT variable_value - @innodb_row_lock_time_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time';
 
1316
SELECT variable_value - @innodb_row_lock_time_max_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max';
 
1317
SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg';
 
1318
 
 
1319
# Test for innodb_sync_spin_loops variable
 
1320
SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops;
 
1321
show variables like "innodb_sync_spin_loops";
 
1322
set global innodb_sync_spin_loops=1000;
 
1323
show variables like "innodb_sync_spin_loops";
 
1324
set global innodb_sync_spin_loops=0;
 
1325
show variables like "innodb_sync_spin_loops";
 
1326
set global innodb_sync_spin_loops=20;
 
1327
show variables like "innodb_sync_spin_loops";
 
1328
set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig;
 
1329
 
 
1330
# Test for innodb_thread_concurrency variable
 
1331
show variables like "innodb_thread_concurrency";
 
1332
set global innodb_thread_concurrency=1001;
 
1333
show variables like "innodb_thread_concurrency";
 
1334
set global innodb_thread_concurrency=0;
 
1335
show variables like "innodb_thread_concurrency";
 
1336
set global innodb_thread_concurrency=16;
 
1337
show variables like "innodb_thread_concurrency";
 
1338
 
 
1339
# Test for innodb_concurrency_tickets variable
 
1340
show variables like "innodb_concurrency_tickets";
 
1341
set global innodb_concurrency_tickets=1000;
 
1342
show variables like "innodb_concurrency_tickets";
 
1343
set global innodb_concurrency_tickets=0;
 
1344
show variables like "innodb_concurrency_tickets";
 
1345
set global innodb_concurrency_tickets=500;
 
1346
show variables like "innodb_concurrency_tickets";
 
1347
 
 
1348
# Test for innodb_thread_sleep_delay variable
 
1349
show variables like "innodb_thread_sleep_delay";
 
1350
set global innodb_thread_sleep_delay=100000;
 
1351
show variables like "innodb_thread_sleep_delay";
 
1352
set global innodb_thread_sleep_delay=0;
 
1353
show variables like "innodb_thread_sleep_delay";
 
1354
set global innodb_thread_sleep_delay=10000;
 
1355
show variables like "innodb_thread_sleep_delay";
 
1356
 
 
1357
#
 
1358
# Test varchar
 
1359
#
 
1360
 
 
1361
let $default=`select @@storage_engine`;
 
1362
set storage_engine=INNODB;
 
1363
# this should be fixed by MySQL (see Bug #51451)
 
1364
set session old_alter_table=1;
 
1365
source include/varchar.inc;
 
1366
set session old_alter_table=0;
 
1367
 
 
1368
#
 
1369
# Some errors/warnings on create
 
1370
#
 
1371
 
 
1372
# Embedded server doesn't chdir to data directory
 
1373
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1374
create table t1 (v varchar(65530), key(v));
 
1375
drop table t1;
 
1376
create table t1 (v varchar(65536));
 
1377
show create table t1;
 
1378
drop table t1;
 
1379
create table t1 (v varchar(65530) character set utf8);
 
1380
show create table t1;
 
1381
drop table t1;
 
1382
 
 
1383
eval set storage_engine=$default;
 
1384
 
 
1385
# InnoDB specific varchar tests
 
1386
create table t1 (v varchar(16384)) engine=innodb;
 
1387
drop table t1;
 
1388
 
 
1389
#
 
1390
# BUG#11039 Wrong key length in min()
 
1391
#
 
1392
 
 
1393
create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
 
1394
insert into t1 values ('8', '6'), ('4', '7');
 
1395
select min(a) from t1;
 
1396
select min(b) from t1 where a='8';
 
1397
drop table t1;
 
1398
 
 
1399
#
 
1400
# Bug #11080 & #11005  Multi-row REPLACE fails on a duplicate key error
 
1401
#
 
1402
 
 
1403
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
 
1404
insert into t1 (b) values (1);
 
1405
replace into t1 (b) values (2), (1), (3);
 
1406
select * from t1;
 
1407
truncate table t1;
 
1408
insert into t1 (b) values (1);
 
1409
replace into t1 (b) values (2);
 
1410
replace into t1 (b) values (1);
 
1411
replace into t1 (b) values (3);
 
1412
select * from t1;
 
1413
drop table t1;
 
1414
 
 
1415
create table t1 (rowid int not null auto_increment, val int not null,primary
 
1416
key (rowid), unique(val)) engine=innodb;
 
1417
replace into t1 (val) values ('1'),('2');
 
1418
replace into t1 (val) values ('1'),('2');
 
1419
--error ER_DUP_ENTRY
 
1420
insert into t1 (val) values ('1'),('2');
 
1421
select * from t1;
 
1422
drop table t1;
 
1423
 
 
1424
#
 
1425
# Test that update does not change internal auto-increment value
 
1426
#
 
1427
 
 
1428
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
 
1429
insert into t1 (val) values (1);
 
1430
update t1 set a=2 where a=1;
 
1431
# We should get the following error because InnoDB does not update the counter
 
1432
--error ER_DUP_ENTRY
 
1433
insert into t1 (val) values (1);
 
1434
select * from t1;
 
1435
drop table t1;
 
1436
#
 
1437
# Bug #10465
 
1438
#
 
1439
 
 
1440
--disable_warnings
 
1441
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
 
1442
--enable_warnings
 
1443
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
 
1444
SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
 
1445
SELECT GRADE  FROM t1 WHERE GRADE= 151;
 
1446
DROP TABLE t1;
 
1447
 
 
1448
#
 
1449
# Bug #12340 multitable delete deletes only one record
 
1450
#
 
1451
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
 
1452
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
 
1453
insert into t2 values ('aa','cc');
 
1454
insert into t1 values ('aa','bb'),('aa','cc');
 
1455
delete t1 from t1,t2 where f1=f3 and f4='cc';
 
1456
select * from t1;
 
1457
drop table t1,t2;
 
1458
 
 
1459
#
 
1460
# Test that the slow TRUNCATE implementation resets autoincrement columns
 
1461
# (bug #11946)
 
1462
#
 
1463
 
 
1464
CREATE TABLE t1 (
 
1465
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
 
1466
) ENGINE=InnoDB;
 
1467
 
 
1468
CREATE TABLE t2 (
 
1469
id INTEGER NOT NULL,
 
1470
FOREIGN KEY (id) REFERENCES t1 (id)
 
1471
) ENGINE=InnoDB;
 
1472
 
 
1473
INSERT INTO t1 (id) VALUES (NULL);
 
1474
SELECT * FROM t1;
 
1475
TRUNCATE t1;
 
1476
INSERT INTO t1 (id) VALUES (NULL);
 
1477
SELECT * FROM t1;
 
1478
 
 
1479
# continued from above; test that doing a slow TRUNCATE on a table with 0
 
1480
# rows resets autoincrement columns
 
1481
DELETE FROM t1;
 
1482
TRUNCATE t1;
 
1483
INSERT INTO t1 (id) VALUES (NULL);
 
1484
SELECT * FROM t1;
 
1485
DROP TABLE t2, t1;
 
1486
 
 
1487
# Test that foreign keys in temporary tables are not accepted (bug #12084)
 
1488
CREATE TABLE t1
 
1489
(
 
1490
 id INT PRIMARY KEY
 
1491
) ENGINE=InnoDB;
 
1492
 
 
1493
--error 1005,1005
 
1494
CREATE TEMPORARY TABLE t2
 
1495
(
 
1496
 id INT NOT NULL PRIMARY KEY,
 
1497
 b INT,
 
1498
 FOREIGN KEY (b) REFERENCES test.t1(id)
 
1499
) ENGINE=InnoDB;
 
1500
DROP TABLE t1;
 
1501
 
 
1502
#
 
1503
# Test that index column max sizes are honored (bug #13315)
 
1504
#
 
1505
 
 
1506
# prefix index
 
1507
create table t1 (col1 varchar(2000), index (col1(767)))
 
1508
 character set = latin1 engine = innodb;
 
1509
 
 
1510
# normal indexes
 
1511
create table t2 (col1 char(255), index (col1))
 
1512
 character set = latin1 engine = innodb;
 
1513
create table t3 (col1 binary(255), index (col1))
 
1514
 character set = latin1 engine = innodb;
 
1515
create table t4 (col1 varchar(767), index (col1))
 
1516
 character set = latin1 engine = innodb;
 
1517
create table t5 (col1 varchar(767) primary key)
 
1518
 character set = latin1 engine = innodb;
 
1519
create table t6 (col1 varbinary(767) primary key)
 
1520
 character set = latin1 engine = innodb;
 
1521
create table t7 (col1 text, index(col1(767)))
 
1522
 character set = latin1 engine = innodb;
 
1523
create table t8 (col1 blob, index(col1(767)))
 
1524
 character set = latin1 engine = innodb;
 
1525
 
 
1526
# multi-column indexes are allowed to be longer
 
1527
create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
 
1528
 character set = latin1 engine = innodb;
 
1529
 
 
1530
show create table t9;
 
1531
 
 
1532
drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
 
1533
 
 
1534
# these should have their index length trimmed
 
1535
create table t1 (col1 varchar(768), index(col1))
 
1536
 character set = latin1 engine = innodb;
 
1537
create table t2 (col1 varbinary(768), index(col1))
 
1538
 character set = latin1 engine = innodb;
 
1539
create table t3 (col1 text, index(col1(768)))
 
1540
 character set = latin1 engine = innodb;
 
1541
create table t4 (col1 blob, index(col1(768)))
 
1542
 character set = latin1 engine = innodb;
 
1543
 
 
1544
show create table t1;
 
1545
 
 
1546
drop table t1, t2, t3, t4;
 
1547
 
 
1548
# these should be refused
 
1549
--error 1071
 
1550
create table t1 (col1 varchar(768) primary key)
 
1551
 character set = latin1 engine = innodb;
 
1552
--error 1071
 
1553
create table t2 (col1 varbinary(768) primary key)
 
1554
 character set = latin1 engine = innodb;
 
1555
--error 1071
 
1556
create table t3 (col1 text, primary key(col1(768)))
 
1557
 character set = latin1 engine = innodb;
 
1558
--error 1071
 
1559
create table t4 (col1 blob, primary key(col1(768)))
 
1560
 character set = latin1 engine = innodb;
 
1561
 
 
1562
#
 
1563
# Test improved foreign key error messages (bug #3443)
 
1564
#
 
1565
 
 
1566
CREATE TABLE t1
 
1567
(
 
1568
 id INT PRIMARY KEY
 
1569
) ENGINE=InnoDB;
 
1570
 
 
1571
CREATE TABLE t2
 
1572
(
 
1573
 v INT,
 
1574
 CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
 
1575
) ENGINE=InnoDB;
 
1576
 
 
1577
--error 1452
 
1578
INSERT INTO t2 VALUES(2);
 
1579
 
 
1580
INSERT INTO t1 VALUES(1);
 
1581
INSERT INTO t2 VALUES(1);
 
1582
 
 
1583
--error 1451
 
1584
DELETE FROM t1 WHERE id = 1;
 
1585
 
 
1586
--error 1217
 
1587
DROP TABLE t1;
 
1588
 
 
1589
SET FOREIGN_KEY_CHECKS=0;
 
1590
DROP TABLE t1;
 
1591
SET FOREIGN_KEY_CHECKS=1;
 
1592
 
 
1593
--error 1452
 
1594
INSERT INTO t2 VALUES(3);
 
1595
 
 
1596
DROP TABLE t2;
 
1597
#
 
1598
# Test that checksum table uses a consistent read Bug #12669
 
1599
#
 
1600
connect (a,localhost,root,,);
 
1601
connect (b,localhost,root,,);
 
1602
connection a;
 
1603
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
 
1604
insert into t1 values (1),(2);
 
1605
set autocommit=0;
 
1606
checksum table t1;
 
1607
connection b;
 
1608
insert into t1 values(3);
 
1609
connection a;
 
1610
#
 
1611
# Here checksum should not see insert
 
1612
#
 
1613
checksum table t1;
 
1614
connection a;
 
1615
commit;
 
1616
checksum table t1;
 
1617
commit;
 
1618
drop table t1;
 
1619
#
 
1620
# autocommit = 1
 
1621
#
 
1622
connection a;
 
1623
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
 
1624
insert into t1 values (1),(2);
 
1625
set autocommit=1;
 
1626
checksum table t1;
 
1627
connection b;
 
1628
set autocommit=1;
 
1629
insert into t1 values(3);
 
1630
connection a;
 
1631
#
 
1632
# Here checksum sees insert
 
1633
#
 
1634
checksum table t1;
 
1635
drop table t1;
 
1636
 
 
1637
connection default;
 
1638
disconnect a;
 
1639
disconnect b;
 
1640
 
 
1641
# tests for bugs #9802 and #13778
 
1642
 
 
1643
# test that FKs between invalid types are not accepted
 
1644
 
 
1645
set foreign_key_checks=0;
 
1646
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
 
1647
# Embedded server doesn't chdir to data directory
 
1648
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1649
-- error 1005
 
1650
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
 
1651
set foreign_key_checks=1;
 
1652
drop table t2;
 
1653
 
 
1654
# test that FKs between different charsets are not accepted in CREATE even
 
1655
# when f_k_c is 0
 
1656
 
 
1657
set foreign_key_checks=0;
 
1658
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
 
1659
# Embedded server doesn't chdir to data directory
 
1660
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
1661
-- error 1005
 
1662
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
 
1663
set foreign_key_checks=1;
 
1664
drop table t1;
 
1665
 
 
1666
# test that invalid datatype conversions with ALTER are not allowed
 
1667
 
 
1668
set foreign_key_checks=0;
 
1669
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
 
1670
create table t1(a varchar(10) primary key) engine = innodb;
 
1671
-- error 1025,1025
 
1672
alter table t1 modify column a int;
 
1673
set foreign_key_checks=1;
 
1674
drop table t2,t1;
 
1675
 
 
1676
# test that charset conversions with ALTER are allowed when f_k_c is 0
 
1677
 
 
1678
set foreign_key_checks=0;
 
1679
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
 
1680
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
 
1681
alter table t1 convert to character set utf8;
 
1682
set foreign_key_checks=1;
 
1683
drop table t2,t1;
 
1684
 
 
1685
# test that RENAME does not allow invalid charsets when f_k_c is 0
 
1686
 
 
1687
set foreign_key_checks=0;
 
1688
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
 
1689
create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
 
1690
# Embedded server doesn't chdir to data directory
 
1691
--replace_result $MYSQLD_DATADIR ./ master-data/ ''
 
1692
-- error 1025
 
1693
rename table t3 to t1;
 
1694
set foreign_key_checks=1;
 
1695
drop table t2,t3;
 
1696
 
 
1697
# test that foreign key errors are reported correctly (Bug #15550)
 
1698
 
 
1699
create table t1(a int primary key) row_format=redundant engine=innodb;
 
1700
create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
 
1701
create table t3(a int primary key) row_format=compact engine=innodb;
 
1702
create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
 
1703
 
 
1704
insert into t1 values(1);
 
1705
insert into t3 values(1);
 
1706
-- error 1452
 
1707
insert into t2 values(2);
 
1708
-- error 1452
 
1709
insert into t4 values(2);
 
1710
insert into t2 values(1);
 
1711
insert into t4 values(1);
 
1712
-- error 1451
 
1713
update t1 set a=2;
 
1714
-- error 1452
 
1715
update t2 set a=2;
 
1716
-- error 1451
 
1717
update t3 set a=2;
 
1718
-- error 1452
 
1719
update t4 set a=2;
 
1720
-- error 1451
 
1721
truncate t1;
 
1722
-- error 1451
 
1723
truncate t3;
 
1724
truncate t2;
 
1725
truncate t4;
 
1726
truncate t1;
 
1727
truncate t3;
 
1728
 
 
1729
drop table t4,t3,t2,t1;
 
1730
 
 
1731
 
 
1732
#
 
1733
# Test that we can create a large (>1K) key
 
1734
#
 
1735
create table t1 (a varchar(255) character set utf8,
 
1736
                 b varchar(255) character set utf8,
 
1737
                 c varchar(255) character set utf8,
 
1738
                 d varchar(255) character set utf8,
 
1739
                 key (a,b,c,d)) engine=innodb;
 
1740
drop table t1;
 
1741
--error ER_TOO_LONG_KEY
 
1742
create table t1 (a varchar(255) character set utf8,
 
1743
                 b varchar(255) character set utf8,
 
1744
                 c varchar(255) character set utf8,
 
1745
                 d varchar(255) character set utf8,
 
1746
                 e varchar(255) character set utf8,
 
1747
                 key (a,b,c,d,e)) engine=innodb;
 
1748
 
 
1749
 
 
1750
# test the padding of BINARY types and collations (Bug #14189)
 
1751
 
 
1752
create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
 
1753
create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
 
1754
create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
 
1755
create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
 
1756
 
 
1757
insert into t1 values (0x41),(0x4120),(0x4100);
 
1758
-- error ER_DUP_ENTRY
 
1759
insert into t2 values (0x41),(0x4120),(0x4100);
 
1760
insert into t2 values (0x41),(0x4120);
 
1761
-- error ER_DUP_ENTRY
 
1762
insert into t3 values (0x41),(0x4120),(0x4100);
 
1763
insert into t3 values (0x41),(0x4100);
 
1764
-- error ER_DUP_ENTRY
 
1765
insert into t4 values (0x41),(0x4120),(0x4100);
 
1766
insert into t4 values (0x41),(0x4100);
 
1767
select hex(s1) from t1;
 
1768
select hex(s1) from t2;
 
1769
select hex(s1) from t3;
 
1770
select hex(s1) from t4;
 
1771
drop table t1,t2,t3,t4;
 
1772
 
 
1773
create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
 
1774
create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
 
1775
 
 
1776
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
 
1777
-- error 1452
 
1778
insert into t2 values(0x42);
 
1779
insert into t2 values(0x41);
 
1780
select hex(s1) from t2;
 
1781
update t1 set s1=0x123456 where a=2;
 
1782
select hex(s1) from t2;
 
1783
-- error 1451
 
1784
update t1 set s1=0x12 where a=1;
 
1785
-- error 1451
 
1786
update t1 set s1=0x12345678 where a=1;
 
1787
-- error 1451
 
1788
update t1 set s1=0x123457 where a=1;
 
1789
update t1 set s1=0x1220 where a=1;
 
1790
select hex(s1) from t2;
 
1791
update t1 set s1=0x1200 where a=1;
 
1792
select hex(s1) from t2;
 
1793
update t1 set s1=0x4200 where a=1;
 
1794
select hex(s1) from t2;
 
1795
-- error 1451
 
1796
delete from t1 where a=1;
 
1797
delete from t1 where a=2;
 
1798
update t2 set s1=0x4120;
 
1799
-- error 1451
 
1800
delete from t1;
 
1801
delete from t1 where a!=3;
 
1802
select a,hex(s1) from t1;
 
1803
select hex(s1) from t2;
 
1804
 
 
1805
drop table t2,t1;
 
1806
 
 
1807
create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
 
1808
create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
 
1809
 
 
1810
insert into t1 values(1,0x4100),(2,0x41);
 
1811
insert into t2 values(0x41);
 
1812
select hex(s1) from t2;
 
1813
update t1 set s1=0x1234 where a=1;
 
1814
select hex(s1) from t2;
 
1815
update t1 set s1=0x12 where a=2;
 
1816
select hex(s1) from t2;
 
1817
delete from t1 where a=1;
 
1818
-- error 1451
 
1819
delete from t1 where a=2;
 
1820
select a,hex(s1) from t1;
 
1821
select hex(s1) from t2;
 
1822
 
 
1823
drop table t2,t1;
 
1824
# Ensure that <tablename>_ibfk_0 is not mistreated as a
 
1825
# generated foreign key identifier.  (Bug #16387)
 
1826
 
 
1827
CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
 
1828
CREATE TABLE t2(a INT) ENGINE=InnoDB;
 
1829
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
 
1830
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
 
1831
ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
 
1832
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
 
1833
SHOW CREATE TABLE t2;
 
1834
DROP TABLE t2,t1;
 
1835
 
 
1836
#
 
1837
# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
 
1838
#
 
1839
 
 
1840
connect (a,localhost,root,,);
 
1841
connect (b,localhost,root,,);
 
1842
connection a;
 
1843
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
1844
insert into t1(a) values (1),(2),(3);
 
1845
commit;
 
1846
connection b;
 
1847
set autocommit = 0;
 
1848
update t1 set b = 5 where a = 2;
 
1849
connection a;
 
1850
delimiter |;
 
1851
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
 
1852
delimiter ;|
 
1853
set autocommit = 0;
 
1854
connection a;
 
1855
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
 
1856
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
 
1857
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
 
1858
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
 
1859
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
 
1860
connection b;
 
1861
commit;
 
1862
connection a;
 
1863
commit;
 
1864
drop trigger t1t;
 
1865
drop table t1;
 
1866
disconnect a;
 
1867
disconnect b;
 
1868
#
 
1869
# Another trigger test
 
1870
#
 
1871
connect (a,localhost,root,,);
 
1872
connect (b,localhost,root,,);
 
1873
connection a;
 
1874
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
1875
create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
1876
create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
1877
create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
1878
create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
 
1879
insert into t1(a) values (1),(2),(3);
 
1880
insert into t2(a) values (1),(2),(3);
 
1881
insert into t3(a) values (1),(2),(3);
 
1882
insert into t4(a) values (1),(2),(3);
 
1883
insert into t3(a) values (5),(7),(8);
 
1884
insert into t4(a) values (5),(7),(8);
 
1885
insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
 
1886
 
 
1887
delimiter |;
 
1888
create trigger t1t before insert on t1 for each row begin 
 
1889
    INSERT INTO t2 SET a = NEW.a;
 
1890
end |
 
1891
 
 
1892
create trigger t2t before insert on t2 for each row begin
 
1893
    DELETE FROM t3 WHERE a = NEW.a;
 
1894
end |
 
1895
 
 
1896
create trigger t3t before delete on t3 for each row begin  
 
1897
    UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
 
1898
end |
 
1899
 
 
1900
create trigger t4t before update on t4 for each row begin
 
1901
    UPDATE t5 SET b = b + 1 where a = NEW.a;
 
1902
end |
 
1903
delimiter ;|
 
1904
commit;
 
1905
set autocommit = 0;
 
1906
update t1 set b = b + 5 where a = 1;
 
1907
update t2 set b = b + 5 where a = 1;
 
1908
update t3 set b = b + 5 where a = 1;
 
1909
update t4 set b = b + 5 where a = 1;
 
1910
insert into t5(a) values(20);
 
1911
connection b;
 
1912
set autocommit = 0;
 
1913
insert into t1(a) values(7);
 
1914
insert into t2(a) values(8);
 
1915
delete from t2 where a = 3;
 
1916
update t4 set b = b + 1 where a = 3;
 
1917
commit;
 
1918
drop trigger t1t;
 
1919
drop trigger t2t;
 
1920
drop trigger t3t;
 
1921
drop trigger t4t;
 
1922
drop table t1, t2, t3, t4, t5;
 
1923
connection default;
 
1924
disconnect a;
 
1925
disconnect b;
 
1926
 
 
1927
#
 
1928
# Test that cascading updates leading to duplicate keys give the correct
 
1929
# error message (bug #9680)
 
1930
#
 
1931
 
 
1932
CREATE TABLE t1 (
 
1933
  field1 varchar(8) NOT NULL DEFAULT '',
 
1934
  field2 varchar(8) NOT NULL DEFAULT '',
 
1935
  PRIMARY KEY  (field1, field2)
 
1936
) ENGINE=InnoDB;
 
1937
 
 
1938
CREATE TABLE t2 (
 
1939
  field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
 
1940
  FOREIGN KEY (field1) REFERENCES t1 (field1)
 
1941
    ON DELETE CASCADE ON UPDATE CASCADE
 
1942
) ENGINE=InnoDB;
 
1943
 
 
1944
INSERT INTO t1 VALUES ('old', 'somevalu');
 
1945
INSERT INTO t1 VALUES ('other', 'anyvalue');
 
1946
 
 
1947
INSERT INTO t2 VALUES ('old');
 
1948
INSERT INTO t2 VALUES ('other');
 
1949
 
 
1950
--error ER_FOREIGN_DUPLICATE_KEY
 
1951
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
 
1952
 
 
1953
DROP TABLE t2;
 
1954
DROP TABLE t1;
 
1955
 
 
1956
#
 
1957
# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
 
1958
#
 
1959
create table t1 (
 
1960
  c1 bigint not null,
 
1961
  c2 bigint not null,
 
1962
  primary key (c1),
 
1963
  unique  key (c2)
 
1964
) engine=innodb;
 
1965
#
 
1966
create table t2 (
 
1967
  c1 bigint not null,
 
1968
  primary key (c1)
 
1969
) engine=innodb;
 
1970
#
 
1971
alter table t1 add constraint c2_fk foreign key (c2)
 
1972
  references t2(c1) on delete cascade;
 
1973
show create table t1;
 
1974
#
 
1975
alter table t1 drop foreign key c2_fk;
 
1976
show create table t1;
 
1977
#
 
1978
drop table t1, t2;
 
1979
 
 
1980
#
 
1981
# Bug #14360: problem with intervals
 
1982
#
 
1983
 
 
1984
create table t1(a date) engine=innodb;
 
1985
create table t2(a date, key(a)) engine=innodb;
 
1986
insert into t1 values('2005-10-01');
 
1987
insert into t2 values('2005-10-01');
 
1988
select * from t1, t2
 
1989
  where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
 
1990
drop table t1, t2;
 
1991
 
 
1992
create table t1 (id int not null, f_id int not null, f int not null,
 
1993
primary key(f_id, id)) engine=innodb;
 
1994
create table t2 (id int not null,s_id int not null,s varchar(200),
 
1995
primary key(id)) engine=innodb;
 
1996
INSERT INTO t1 VALUES (8, 1, 3);
 
1997
INSERT INTO t1 VALUES (1, 2, 1);
 
1998
INSERT INTO t2 VALUES (1, 0, '');
 
1999
INSERT INTO t2 VALUES (8, 1, '');
 
2000
commit;
 
2001
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
 
2002
WHERE mm.id IS NULL;
 
2003
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
 
2004
where mm.id is null lock in share mode;
 
2005
drop table t1,t2;
 
2006
 
 
2007
#
 
2008
# Test case where X-locks on unused rows should be released in a
 
2009
# update (because READ COMMITTED isolation level)
 
2010
#
 
2011
 
 
2012
connect (a,localhost,root,,);
 
2013
connect (b,localhost,root,,);
 
2014
connection a;
 
2015
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
2016
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
 
2017
commit;
 
2018
SET binlog_format='MIXED';
 
2019
set autocommit = 0; 
 
2020
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2021
update t1 set b = 5 where b = 1;
 
2022
connection b;
 
2023
SET binlog_format='MIXED';
 
2024
set autocommit = 0;
 
2025
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2026
#
 
2027
# X-lock to record (7,3) should be released in a update 
 
2028
#
 
2029
select * from t1 where a = 7 and b = 3 for update;
 
2030
connection a;
 
2031
commit;
 
2032
connection b;
 
2033
commit;
 
2034
drop table t1;
 
2035
connection default;
 
2036
disconnect a;
 
2037
disconnect b;
 
2038
 
 
2039
#
 
2040
# Test case where no locks should be released (because we are not
 
2041
# using READ COMMITTED isolation level)
 
2042
#
 
2043
 
 
2044
connect (a,localhost,root,,);
 
2045
connect (b,localhost,root,,);
 
2046
connection a;
 
2047
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
2048
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
 
2049
commit;
 
2050
set autocommit = 0; 
 
2051
select * from t1 lock in share mode;
 
2052
update t1 set b = 5 where b = 1;
 
2053
connection b;
 
2054
set autocommit = 0;
 
2055
#
 
2056
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
 
2057
#
 
2058
--error 1205
 
2059
select * from t1 where a = 2 and b = 2 for update;
 
2060
#
 
2061
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
 
2062
#
 
2063
--error 1205
 
2064
connection a;
 
2065
commit;
 
2066
connection b;
 
2067
commit;
 
2068
connection default;
 
2069
disconnect a;
 
2070
disconnect b;
 
2071
drop table t1;
 
2072
 
 
2073
#
 
2074
# Consistent read should be used in following selects
 
2075
#
 
2076
# 1) INSERT INTO ... SELECT
 
2077
# 2) UPDATE ... = ( SELECT ...)
 
2078
# 3) CREATE ... SELECT
 
2079
 
 
2080
connect (a,localhost,root,,);
 
2081
connect (b,localhost,root,,);
 
2082
connection a;
 
2083
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
2084
insert into t1 values (1,2),(5,3),(4,2);
 
2085
create table t2(d int not null, e int, primary key(d)) engine=innodb;
 
2086
insert into t2 values (8,6),(12,1),(3,1);
 
2087
commit;
 
2088
set autocommit = 0;
 
2089
select * from t2 for update;
 
2090
connection b;
 
2091
SET binlog_format='MIXED';
 
2092
set autocommit = 0;
 
2093
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2094
insert into t1 select * from t2;
 
2095
update t1 set b = (select e from t2 where a = d);
 
2096
create table t3(d int not null, e int, primary key(d)) engine=innodb
 
2097
select * from t2;
 
2098
commit;
 
2099
connection a;
 
2100
commit;
 
2101
connection default;
 
2102
disconnect a;
 
2103
disconnect b;
 
2104
drop table t1, t2, t3;
 
2105
 
 
2106
#
 
2107
# Consistent read should not be used if 
 
2108
#
 
2109
# (a) isolation level is serializable OR
 
2110
# (b) select ... lock in share mode OR
 
2111
# (c) select ... for update
 
2112
#
 
2113
# in following queries:
 
2114
#
 
2115
# 1) INSERT INTO ... SELECT
 
2116
# 2) UPDATE ... = ( SELECT ...)
 
2117
# 3) CREATE ... SELECT
 
2118
 
 
2119
connect (a,localhost,root,,);
 
2120
connect (b,localhost,root,,);
 
2121
connect (c,localhost,root,,);
 
2122
connect (d,localhost,root,,);
 
2123
connect (e,localhost,root,,);
 
2124
connect (f,localhost,root,,);
 
2125
connect (g,localhost,root,,);
 
2126
connect (h,localhost,root,,);
 
2127
connect (i,localhost,root,,);
 
2128
connect (j,localhost,root,,);
 
2129
connection a;
 
2130
create table t1(a int not null, b int, primary key(a)) engine=innodb;
 
2131
insert into t1 values (1,2),(5,3),(4,2);
 
2132
create table t2(a int not null, b int, primary key(a)) engine=innodb;
 
2133
insert into t2 values (8,6),(12,1),(3,1);
 
2134
create table t3(d int not null, b int, primary key(d)) engine=innodb;
 
2135
insert into t3 values (8,6),(12,1),(3,1);
 
2136
create table t5(a int not null, b int, primary key(a)) engine=innodb;
 
2137
insert into t5 values (1,2),(5,3),(4,2);
 
2138
create table t6(d int not null, e int, primary key(d)) engine=innodb;
 
2139
insert into t6 values (8,6),(12,1),(3,1);
 
2140
create table t8(a int not null, b int, primary key(a)) engine=innodb;
 
2141
insert into t8 values (1,2),(5,3),(4,2);
 
2142
create table t9(d int not null, e int, primary key(d)) engine=innodb;
 
2143
insert into t9 values (8,6),(12,1),(3,1);
 
2144
commit;
 
2145
set autocommit = 0;
 
2146
select * from t2 for update;
 
2147
connection b;
 
2148
SET binlog_format='MIXED';
 
2149
set autocommit = 0;
 
2150
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
2151
--send
 
2152
insert into t1 select * from t2;
 
2153
connection c;
 
2154
SET binlog_format='MIXED';
 
2155
set autocommit = 0;
 
2156
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
2157
--send
 
2158
update t3 set b = (select b from t2 where a = d);
 
2159
connection d;
 
2160
SET binlog_format='MIXED';
 
2161
set autocommit = 0;
 
2162
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 
2163
--send
 
2164
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
 
2165
connection e;
 
2166
SET binlog_format='MIXED';
 
2167
set autocommit = 0;
 
2168
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2169
--send
 
2170
insert into t5 (select * from t2 lock in share mode);
 
2171
connection f;
 
2172
SET binlog_format='MIXED';
 
2173
set autocommit = 0;
 
2174
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2175
--send
 
2176
update t6 set e = (select b from t2 where a = d lock in share mode);
 
2177
connection g;
 
2178
SET binlog_format='MIXED';
 
2179
set autocommit = 0;
 
2180
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2181
--send
 
2182
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
 
2183
connection h;
 
2184
SET binlog_format='MIXED';
 
2185
set autocommit = 0;
 
2186
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2187
--send
 
2188
insert into t8 (select * from t2 for update);
 
2189
connection i;
 
2190
SET binlog_format='MIXED';
 
2191
set autocommit = 0;
 
2192
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2193
--send
 
2194
update t9 set e = (select b from t2 where a = d for update);
 
2195
connection j;
 
2196
SET binlog_format='MIXED';
 
2197
set autocommit = 0;
 
2198
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
2199
--send
 
2200
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
 
2201
 
 
2202
connection b;
 
2203
--error 1205
 
2204
reap;
 
2205
 
 
2206
connection c;
 
2207
--error 1205
 
2208
reap;
 
2209
 
 
2210
connection d;
 
2211
--error 1205
 
2212
reap;
 
2213
 
 
2214
connection e;
 
2215
--error 1205
 
2216
reap;
 
2217
 
 
2218
connection f;
 
2219
--error 1205
 
2220
reap;
 
2221
 
 
2222
connection g;
 
2223
--error 1205
 
2224
reap;
 
2225
 
 
2226
connection h;
 
2227
--error 1205
 
2228
reap;
 
2229
 
 
2230
connection i;
 
2231
--error 1205
 
2232
reap;
 
2233
 
 
2234
connection j;
 
2235
--error 1205
 
2236
reap;
 
2237
 
 
2238
connection a;
 
2239
commit;
 
2240
 
 
2241
connection default;
 
2242
disconnect a;
 
2243
disconnect b;
 
2244
disconnect c;
 
2245
disconnect d;
 
2246
disconnect e;
 
2247
disconnect f;
 
2248
disconnect g;
 
2249
disconnect h;
 
2250
disconnect i;
 
2251
disconnect j;
 
2252
drop table t1, t2, t3, t5, t6, t8, t9;
 
2253
 
 
2254
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
 
2255
--error ER_WRONG_COLUMN_NAME
 
2256
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
 
2257
 
 
2258
#
 
2259
# Bug #17152: Wrong result with BINARY comparison on aliased column
 
2260
#
 
2261
 
 
2262
CREATE TABLE t1 (
 
2263
   a BIGINT(20) NOT NULL,
 
2264
    PRIMARY KEY  (a)
 
2265
 ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
 
2266
 
 
2267
CREATE TABLE t2 (
 
2268
  a BIGINT(20) NOT NULL,
 
2269
  b VARCHAR(128) NOT NULL,
 
2270
  c TEXT NOT NULL,
 
2271
  PRIMARY KEY  (a,b),
 
2272
  KEY idx_t2_b_c (b,c(200)),
 
2273
  CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) 
 
2274
   ON DELETE CASCADE
 
2275
 ) ENGINE=INNODB DEFAULT CHARSET=UTF8;
 
2276
 
 
2277
INSERT INTO t1 VALUES (1);
 
2278
INSERT INTO t2 VALUES (1, 'bar', 'vbar');
 
2279
INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
 
2280
INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
 
2281
INSERT INTO t2 VALUES (1, 'customer_over', '1');
 
2282
 
 
2283
SELECT * FROM t2 WHERE b = 'customer_over';
 
2284
SELECT * FROM t2 WHERE BINARY b = 'customer_over';
 
2285
SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
 
2286
/* Bang: Empty result set, above was expected: */
 
2287
SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
 
2288
SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
 
2289
 
 
2290
drop table t2, t1;
 
2291
 
 
2292
#
 
2293
# Test optimize on table with open transaction
 
2294
#
 
2295
 
 
2296
CREATE TABLE t1 ( a int ) ENGINE=innodb;
 
2297
BEGIN;
 
2298
INSERT INTO t1 VALUES (1);
 
2299
OPTIMIZE TABLE t1;
 
2300
DROP TABLE t1;
 
2301
 
 
2302
#
 
2303
# Bug #24741 (existing cascade clauses disappear when adding foreign keys)
 
2304
#
 
2305
 
 
2306
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
 
2307
 
 
2308
CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
 
2309
  CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
 
2310
  ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
 
2311
 
 
2312
ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
 
2313
DELETE CASCADE ON UPDATE CASCADE;
 
2314
 
 
2315
SHOW CREATE TABLE t2;
 
2316
DROP TABLE t2, t1;
 
2317
 
 
2318
#
 
2319
# Bug #25927: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns
 
2320
# for which there is a foreign key constraint ON ... SET NULL.
 
2321
#
 
2322
 
 
2323
CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
 
2324
CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
 
2325
INSERT INTO t1 VALUES (1);
 
2326
INSERT INTO t2 VALUES (1);
 
2327
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
 
2328
# mysqltest first does replace_regex, then replace_result
 
2329
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
 
2330
# Embedded server doesn't chdir to data directory
 
2331
--replace_result $MYSQLD_DATADIR ./ master-data/ ''
 
2332
--error 1025
 
2333
ALTER TABLE t2 MODIFY a INT NOT NULL;
 
2334
DELETE FROM t1;
 
2335
DROP TABLE t2,t1;
 
2336
 
 
2337
#
 
2338
# Bug #26835: table corruption after delete+insert
 
2339
#
 
2340
 
 
2341
CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
 
2342
ENGINE=InnoDB;
 
2343
INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
 
2344
DELETE FROM t1;
 
2345
INSERT INTO t1 VALUES ('DDD');
 
2346
SELECT * FROM t1;
 
2347
DROP TABLE t1;
 
2348
 
 
2349
#
 
2350
# Bug #23313 (AUTO_INCREMENT=# not reported back for InnoDB tables)
 
2351
# Bug #21404 (AUTO_INCREMENT value reset when Adding FKEY (or ALTER?))
 
2352
#
 
2353
 
 
2354
CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
 
2355
AUTO_INCREMENT=42;
 
2356
 
 
2357
INSERT INTO t1 VALUES (0),(347),(0);
 
2358
SELECT * FROM t1;
 
2359
 
 
2360
SHOW CREATE TABLE t1;
 
2361
 
 
2362
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
 
2363
INSERT INTO t2 VALUES(42),(347),(348);
 
2364
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
 
2365
SHOW CREATE TABLE t1;
 
2366
 
 
2367
DROP TABLE t1,t2;
 
2368
 
 
2369
#
 
2370
# Bug #21101 (Prints wrong error message if max row size is too large)
 
2371
#
 
2372
set innodb_strict_mode=on;
 
2373
--error 1118
 
2374
CREATE TABLE t1 (
 
2375
        c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
 
2376
        c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
 
2377
        c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
 
2378
        c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
 
2379
        c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
 
2380
        c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
 
2381
        c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
 
2382
        c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
 
2383
        ) ENGINE = InnoDB;
 
2384
 
 
2385
#
 
2386
# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
 
2387
#
 
2388
DROP TABLE IF EXISTS t1;
 
2389
CREATE TABLE t1(
 
2390
        id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
 
2391
        ) ENGINE=InnoDB;
 
2392
INSERT INTO t1 VALUES(-10);
 
2393
SELECT * FROM t1;
 
2394
#
 
2395
# NOTE: The server really needs to be restarted at this point
 
2396
# for the test to be useful.  
 
2397
#
 
2398
# Without the fix InnoDB would trip over an assertion here.
 
2399
INSERT INTO t1 VALUES(NULL);
 
2400
# The next value should be 1 and not -9 or a -ve number
 
2401
SELECT * FROM t1;
 
2402
DROP TABLE t1;
 
2403
 
 
2404
 
2405
# Bug #21409 Incorrect result returned when in READ-COMMITTED with
 
2406
# query_cache ON
 
2407
#
 
2408
CONNECT (c1,localhost,root,,);
 
2409
CONNECT (c2,localhost,root,,);
 
2410
CONNECTION c1;
 
2411
SET binlog_format='MIXED';
 
2412
SET TX_ISOLATION='read-committed';
 
2413
SET AUTOCOMMIT=0;
 
2414
DROP TABLE IF EXISTS t1, t2;
 
2415
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
 
2416
CREATE TABLE t2 LIKE t1;
 
2417
SELECT * FROM t2;
 
2418
CONNECTION c2;
 
2419
SET binlog_format='MIXED';
 
2420
SET TX_ISOLATION='read-committed';
 
2421
SET AUTOCOMMIT=0;
 
2422
INSERT INTO t1 VALUES (1);
 
2423
COMMIT;
 
2424
CONNECTION c1;
 
2425
SELECT * FROM t1 WHERE a=1;
 
2426
DISCONNECT c1;
 
2427
DISCONNECT c2;
 
2428
CONNECT (c1,localhost,root,,);
 
2429
CONNECT (c2,localhost,root,,);
 
2430
CONNECTION c1;
 
2431
SET binlog_format='MIXED';
 
2432
SET TX_ISOLATION='read-committed';
 
2433
SET AUTOCOMMIT=0;
 
2434
SELECT * FROM t2;
 
2435
CONNECTION c2;
 
2436
SET binlog_format='MIXED';
 
2437
SET TX_ISOLATION='read-committed';
 
2438
SET AUTOCOMMIT=0;
 
2439
INSERT INTO t1 VALUES (2);
 
2440
COMMIT;
 
2441
CONNECTION c1;
 
2442
# The result set below should be the same for both selects
 
2443
SELECT * FROM t1 WHERE a=2;
 
2444
SELECT * FROM t1 WHERE a=2;
 
2445
DROP TABLE t1;
 
2446
DROP TABLE t2;
 
2447
DISCONNECT c1;
 
2448
DISCONNECT c2;
 
2449
CONNECTION default;
 
2450
 
 
2451
#
 
2452
# Bug #29157 UPDATE, changed rows incorrect
 
2453
#
 
2454
create table t1 (i int, j int) engine=innodb;
 
2455
insert into t1 (i, j) values (1, 1), (2, 2);
 
2456
--enable_info
 
2457
update t1 set j = 2;
 
2458
--disable_info
 
2459
drop table t1;
 
2460
 
 
2461
#
 
2462
# Bug #32440 InnoDB free space info does not appear in SHOW TABLE STATUS or
 
2463
# I_S
 
2464
#
 
2465
create table t1 (id int) comment='this is a comment' engine=innodb;
 
2466
select table_comment, data_free > 0 as data_free_is_set
 
2467
  from information_schema.tables
 
2468
  where table_schema='test' and table_name = 't1';
 
2469
drop table t1;
 
2470
 
 
2471
#
 
2472
# Bug 34920 test
 
2473
#
 
2474
CONNECTION default;
 
2475
CREATE TABLE t1 (
 
2476
        c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 
2477
        c2 VARCHAR(128) NOT NULL,
 
2478
        PRIMARY KEY(c1)
 
2479
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
 
2480
 
 
2481
CREATE TABLE t2 (
 
2482
        c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 
2483
        c2 INT(10) UNSIGNED DEFAULT NULL,
 
2484
        PRIMARY KEY(c1)
 
2485
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
 
2486
 
 
2487
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
 
2488
ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
 
2489
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
 
2490
DROP TABLE t2;
 
2491
DROP TABLE t1;
 
2492
# End 34920 test
 
2493
#
 
2494
# Bug #29507 TRUNCATE shows to many rows effected
 
2495
#
 
2496
CONNECTION default;
 
2497
CREATE TABLE t1 (c1 int default NULL,
 
2498
                 c2 int default NULL
 
2499
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
2500
 
 
2501
--enable_info
 
2502
TRUNCATE TABLE t1;
 
2503
 
 
2504
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
 
2505
TRUNCATE TABLE t1;
 
2506
 
 
2507
--disable_info
 
2508
DROP TABLE t1;
 
2509
#
 
2510
# Bug#35537 Innodb doesn't increment handler_update and handler_delete.
 
2511
#
 
2512
-- disable_query_log
 
2513
-- disable_result_log
 
2514
 
 
2515
CONNECT (c1,localhost,root,,);
 
2516
 
 
2517
DROP TABLE IF EXISTS bug35537;
 
2518
CREATE TABLE bug35537 (
 
2519
  c1 int
 
2520
) ENGINE=InnoDB;
 
2521
 
 
2522
INSERT INTO bug35537 VALUES (1);
 
2523
 
 
2524
-- enable_result_log
 
2525
 
 
2526
SHOW SESSION STATUS LIKE 'Handler_update%';
 
2527
SHOW SESSION STATUS LIKE 'Handler_delete%';
 
2528
 
 
2529
UPDATE bug35537 SET c1 = 2 WHERE c1 = 1;
 
2530
DELETE FROM bug35537 WHERE c1 = 2;
 
2531
 
 
2532
SHOW SESSION STATUS LIKE 'Handler_update%';
 
2533
SHOW SESSION STATUS LIKE 'Handler_delete%';
 
2534
 
 
2535
DROP TABLE bug35537;
 
2536
 
 
2537
DISCONNECT c1;
 
2538
CONNECTION default;
 
2539
 
 
2540
SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig;
 
2541
 
 
2542
-- enable_query_log
 
2543
 
 
2544
#######################################################################
 
2545
#                                                                     #
 
2546
# Please, DO NOT TOUCH this file as well as the innodb.result file.   #
 
2547
# These files are to be modified ONLY BY INNOBASE guys.               #
 
2548
#                                                                     #
 
2549
# Use innodb_mysql.[test|result] files instead.                       #
 
2550
#                                                                     #
 
2551
# If nevertheless you need to make some changes here, please, forward #
 
2552
# your commit message                                                 #
 
2553
# To: innodb_dev_ww@oracle.com                                        #
 
2554
# Cc: dev-innodb@mysql.com                                            #
 
2555
# (otherwise your changes may be erased).                             #
 
2556
#                                                                     #
 
2557
#######################################################################