Commit c0b172f0 authored by unknown's avatar unknown
Browse files

Merge zippy.(none):/home/cmiller/work/mysql/merge/tmp_merge

into  zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1-new

(With hand-merged tests.)


sql/item_timefunc.cc:
  Auto merged
sql/item_timefunc.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
parents a7296d92 c97aa492
Loading
Loading
Loading
Loading
+112 −114
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ n after commit
commit;
insert into t1 values (5);
insert into t1 values (4);
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
ERROR 23000: Duplicate entry '4' for key 1
commit;
select n, "after commit" from t1;
n	after commit
@@ -243,7 +243,7 @@ n after commit
set autocommit=1;
insert into t1 values (6);
insert into t1 values (4);
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
ERROR 23000: Duplicate entry '4' for key 1
select n from t1;
n
4
@@ -318,7 +318,7 @@ drop table t1;
CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb;
insert into t1 values ('pippo', 12);
insert into t1 values ('pippo', 12);
ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY'
ERROR 23000: Duplicate entry 'pippo' for key 1
delete from t1;
delete from t1 where id = 'pippo';
select * from t1;
@@ -482,9 +482,9 @@ UNIQUE ggid (ggid)
insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy');
insert into t1 (ggid,passwd) values ('test2','this will fail');
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
ERROR 23000: Duplicate entry 'test2' for key 2
insert into t1 (ggid,id) values ('this will fail',1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
ERROR 23000: Duplicate entry '1' for key 1
select * from t1 where ggid='test1';
id	ggid	email	passwd
1	test1		xxx
@@ -497,7 +497,7 @@ id ggid email passwd
replace into t1 (ggid,id) values ('this will work',1);
replace into t1 (ggid,passwd) values ('test2','this will work');
update t1 set id=100,ggid='test2' where id=1;
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
ERROR 23000: Duplicate entry 'test2' for key 2
select * from t1;
id	ggid	email	passwd
1	this will work		
@@ -816,7 +816,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
ERROR 23000: Duplicate entry '1-1' for key 1
select id from t1;
id
0
@@ -834,7 +834,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ
LOCK TABLES t1 WRITE;
begin;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
ERROR 23000: Duplicate entry '1-1' for key 1
select id from t1;
id
0
@@ -856,7 +856,7 @@ create table t1 (a char(20), index (a(5))) engine=innodb;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(20) DEFAULT NULL,
  `a` char(20) default NULL,
  KEY `a` (`a`(5))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
@@ -1587,7 +1587,7 @@ create table t2 (id int(11) not null auto_increment, id2 int(11) not null, const
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) NOT NULL auto_increment,
  `id2` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id` (`id`,`id2`),
@@ -1598,7 +1598,7 @@ create table t2 (id int(11) not null auto_increment, id2 int(11) not null, const
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) NOT NULL auto_increment,
  `id2` int(11) NOT NULL,
  KEY `t1_id_fk` (`id`),
  CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
@@ -1607,7 +1607,7 @@ alter table t2 add index id_test (id), add index id_test2 (id,id2);
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) NOT NULL auto_increment,
  `id2` int(11) NOT NULL,
  KEY `id_test` (`id`),
  KEY `id_test2` (`id`,`id2`),
@@ -1615,13 +1615,13 @@ t2 CREATE TABLE `t2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2;
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;
ERROR HY000: Can't create table 'test.t2' (errno: 150)
ERROR HY000: Can't create table './test/t2' (errno: 150)
create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb;
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) DEFAULT NULL,
  `a` int(11) NOT NULL auto_increment,
  `b` int(11) default NULL,
  PRIMARY KEY  (`a`),
  UNIQUE KEY `b_2` (`b`),
  KEY `b` (`b`),
@@ -1632,14 +1632,37 @@ create table t2 (a int auto_increment primary key, b int, foreign key (b) refere
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) DEFAULT NULL,
  `a` int(11) NOT NULL auto_increment,
  `b` int(11) default NULL,
  PRIMARY KEY  (`a`),
  UNIQUE KEY `b` (`b`),
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t2, t1;
show status like "binlog_cache_use";
Variable_name	Value
Binlog_cache_use	155
show status like "binlog_cache_disk_use";
Variable_name	Value
Binlog_cache_disk_use	0
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
Variable_name	Value
Binlog_cache_use	156
show status like "binlog_cache_disk_use";
Variable_name	Value
Binlog_cache_disk_use	1
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
Variable_name	Value
Binlog_cache_use	157
show status like "binlog_cache_disk_use";
Variable_name	Value
Binlog_cache_disk_use	1
drop table t1;
create table t1 (c char(10), index (c,c)) engine=innodb;
ERROR 42S21: Duplicate column name 'c'
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
@@ -1751,6 +1774,21 @@ select count(*) from t1 where x = 18446744073709551601;
count(*)
1
drop table t1;
show status like "Innodb_buffer_pool_pages_total";
Variable_name	Value
Innodb_buffer_pool_pages_total	512
show status like "Innodb_page_size";
Variable_name	Value
Innodb_page_size	16384
show status like "Innodb_rows_deleted";
Variable_name	Value
Innodb_rows_deleted	2070
show status like "Innodb_rows_inserted";
Variable_name	Value
Innodb_rows_inserted	31727
show status like "Innodb_rows_updated";
Variable_name	Value
Innodb_rows_updated	29530
show status like "Innodb_row_lock_waits";
Variable_name	Value
Innodb_row_lock_waits	0
@@ -1783,7 +1821,7 @@ Variable_name Value
innodb_sync_spin_loops	20
show variables like "innodb_thread_concurrency";
Variable_name	Value
innodb_thread_concurrency	20
innodb_thread_concurrency	8
set global innodb_thread_concurrency=1001;
show variables like "innodb_thread_concurrency";
Variable_name	Value
@@ -1791,7 +1829,7 @@ innodb_thread_concurrency 1000
set global innodb_thread_concurrency=0;
show variables like "innodb_thread_concurrency";
Variable_name	Value
innodb_thread_concurrency	1
innodb_thread_concurrency	0
set global innodb_thread_concurrency=16;
show variables like "innodb_thread_concurrency";
Variable_name	Value
@@ -1843,40 +1881,40 @@ concat('*',v,'*',c,'*',t,'*')
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(10) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(10) default NULL,
  `c` char(10) default NULL,
  `t` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1
create table t2 like t1;
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `v` varchar(10) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(10) default NULL,
  `c` char(10) default NULL,
  `t` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1
create table t3 select * from t1;
show create table t3;
Table	Create Table
t3	CREATE TABLE `t3` (
  `v` varchar(10) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(10) default NULL,
  `c` char(10) default NULL,
  `t` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table t1 modify c varchar(10);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(10) DEFAULT NULL,
  `c` varchar(10) DEFAULT NULL,
  `v` varchar(10) default NULL,
  `c` varchar(10) default NULL,
  `t` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table t1 modify v char(10);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` char(10) DEFAULT NULL,
  `c` varchar(10) DEFAULT NULL,
  `v` char(10) default NULL,
  `c` varchar(10) default NULL,
  `t` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table t1 modify t varchar(10);
@@ -1885,9 +1923,9 @@ Note 1265 Data truncated for column 't' at row 2
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` char(10) DEFAULT NULL,
  `c` varchar(10) DEFAULT NULL,
  `t` varchar(10) DEFAULT NULL
  `v` char(10) default NULL,
  `c` varchar(10) default NULL,
  `t` varchar(10) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
@@ -1898,8 +1936,8 @@ create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(10) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(10) default NULL,
  `c` char(10) default NULL,
  `t` text,
  KEY `v` (`v`),
  KEY `c` (`c`),
@@ -1964,7 +2002,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a '
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
ERROR 23000: Duplicate entry '{ ' for key 1
alter table t1 add key(v);
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
qq
@@ -2117,8 +2155,8 @@ alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(300) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(300) default NULL,
  `c` char(10) default NULL,
  `t` text,
  KEY `c` (`c`),
  KEY `t` (`t`(10)),
@@ -2197,8 +2235,8 @@ alter table t1 drop key v, add key v (v(30));
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(300) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(300) default NULL,
  `c` char(10) default NULL,
  `t` text,
  KEY `c` (`c`),
  KEY `t` (`t`(10)),
@@ -2277,8 +2315,8 @@ alter table t1 modify v varchar(600), drop key v, add key v (v);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(600) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(600) default NULL,
  `c` char(10) default NULL,
  `t` text,
  KEY `c` (`c`),
  KEY `t` (`t`(10)),
@@ -2324,16 +2362,16 @@ drop table t1;
create table t1 (a char(10), unique (a));
insert into t1 values ('a   ');
insert into t1 values ('a ');
ERROR 23000: Duplicate entry 'a' for key 'a'
ERROR 23000: Duplicate entry 'a' for key 1
alter table t1 modify a varchar(10);
insert into t1 values ('a '),('a  '),('a   '),('a         ');
ERROR 23000: Duplicate entry 'a ' for key 'a'
ERROR 23000: Duplicate entry 'a ' for key 1
insert into t1 values ('a     ');
ERROR 23000: Duplicate entry 'a     ' for key 'a'
ERROR 23000: Duplicate entry 'a     ' for key 1
insert into t1 values ('a          ');
ERROR 23000: Duplicate entry 'a         ' for key 'a'
ERROR 23000: Duplicate entry 'a         ' for key 1
insert into t1 values ('a ');
ERROR 23000: Duplicate entry 'a ' for key 'a'
ERROR 23000: Duplicate entry 'a ' for key 1
update t1 set a='a  ' where a like 'a%';
select concat(a,'.') from t1;
concat(a,'.')
@@ -2355,8 +2393,8 @@ create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(10) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `v` varchar(10) default NULL,
  `c` char(10) default NULL,
  `t` text,
  KEY `v` (`v`(5)),
  KEY `c` (`c`(5)),
@@ -2367,15 +2405,15 @@ create table t1 (v char(10) character set utf8);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` char(10) CHARACTER SET utf8 DEFAULT NULL
  `v` char(10) character set utf8 default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(10), c char(10)) row_format=fixed;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` varchar(10) DEFAULT NULL,
  `c` char(10) DEFAULT NULL
  `v` varchar(10) default NULL,
  `c` char(10) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
insert into t1 values('a','a'),('a ','a ');
select concat('*',v,'*',c,'*') from t1;
@@ -2417,7 +2455,7 @@ Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `v` mediumtext CHARACTER SET utf8
  `v` mediumtext character set utf8
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
set storage_engine=MyISAM;
@@ -2456,7 +2494,7 @@ key (rowid), unique(val)) engine=innodb;
replace into t1 (val) values ('1'),('2');
replace into t1 (val) values ('1'),('2');
insert into t1 (val) values ('1'),('2');
ERROR 23000: Duplicate entry '1' for key 'val'
ERROR 23000: Duplicate entry '1' for key 2
select * from t1;
rowid	val
3	1
@@ -2466,7 +2504,7 @@ create table t1 (a int not null auto_increment primary key, val int) engine=Inno
insert into t1 (val) values (1);
update t1 set a=2 where a=1;
insert into t1 (val) values (1);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
ERROR 23000: Duplicate entry '2' for key 1
select * from t1;
a	val
2	1
@@ -2544,8 +2582,8 @@ character set = latin1 engine = innodb;
show create table t9;
Table	Create Table
t9	CREATE TABLE `t9` (
  `col1` varchar(512) DEFAULT NULL,
  `col2` varchar(512) DEFAULT NULL,
  `col1` varchar(512) default NULL,
  `col2` varchar(512) default NULL,
  KEY `col1` (`col1`,`col2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1, t2, t3, t4, t5, t6, t7, t8, t9;
@@ -2568,7 +2606,7 @@ Warning 1071 Specified key was too long; max key length is 767 bytes
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `col1` varchar(768) DEFAULT NULL,
  `col1` varchar(768) default NULL,
  KEY `col1` (`col1`(767))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1, t2, t3, t4;
@@ -2847,13 +2885,13 @@ commit;
set foreign_key_checks=0;
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
ERROR HY000: Can't create table 'test.t1' (errno: 150)
ERROR HY000: Can't create table './test/t1.frm' (errno: 150)
set foreign_key_checks=1;
drop table t2;
set foreign_key_checks=0;
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
ERROR HY000: Can't create table 'test.t2' (errno: 150)
ERROR HY000: Can't create table './test/t2.frm' (errno: 150)
set foreign_key_checks=1;
drop table t1;
set foreign_key_checks=0;
@@ -2924,13 +2962,13 @@ create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
insert into t1 values (0x41),(0x4120),(0x4100);
insert into t2 values (0x41),(0x4120),(0x4100);
ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
ERROR 23000: Duplicate entry 'A' for key 1
insert into t2 values (0x41),(0x4120);
insert into t3 values (0x41),(0x4120),(0x4100);
ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY'
ERROR 23000: Duplicate entry 'A ' for key 1
insert into t3 values (0x41),(0x4100);
insert into t4 values (0x41),(0x4120),(0x4100);
ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
ERROR 23000: Duplicate entry 'A' for key 1
insert into t4 values (0x41),(0x4100);
select hex(s1) from t1;
hex(s1)
@@ -3132,7 +3170,7 @@ ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `a` int(11) default NULL,
  KEY `t2_ibfk_0` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2,t1;
@@ -3194,52 +3232,12 @@ drop trigger t2t;
drop trigger t3t;
drop trigger t4t;
drop table t1, t2, t3, t4, t5;
CREATE TABLE t1 (
field1 varchar(8) NOT NULL DEFAULT '',
field2 varchar(8) NOT NULL DEFAULT '',
PRIMARY KEY  (field1, field2)
) ENGINE=InnoDB;
CREATE TABLE t2 (
field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
FOREIGN KEY (field1) REFERENCES t1 (field1)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('old', 'somevalu');
INSERT INTO t1 VALUES ('other', 'anyvalue');
INSERT INTO t2 VALUES ('old');
INSERT INTO t2 VALUES ('other');
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry
DROP TABLE t2;
DROP TABLE t1;
create table t1 (
c1 bigint not null,
c2 bigint not null,
primary key (c1),
unique  key (c2)
) engine=innodb;
create table t2 (
c1 bigint not null,
primary key (c1)
) engine=innodb;
alter table t1 add constraint c2_fk foreign key (c2)
references t2(c1) on delete cascade;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` bigint(20) NOT NULL,
  `c2` bigint(20) NOT NULL,
  PRIMARY KEY (`c1`),
  UNIQUE KEY `c2` (`c2`),
  CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table t1 drop foreign key c2_fk;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` bigint(20) NOT NULL,
  `c2` bigint(20) NOT NULL,
  PRIMARY KEY (`c1`),
  UNIQUE KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
create table t1(a date) engine=innodb;
create table t2(a date, key(a)) engine=innodb;
insert into t1 values('2005-10-01');
insert into t2 values('2005-10-01');
select * from t1, t2
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
a	a
2005-10-01	2005-10-01
drop table t1, t2;
+50 −49
Original line number Diff line number Diff line
@@ -1141,6 +1141,40 @@ show create table t2;
drop table t2, t1;


#
# Let us test binlog_cache_use and binlog_cache_disk_use status vars.
# Actually this test has nothing to do with innodb per se, it just requires
# transactional table. 
#
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";

create table t1 (a int) engine=innodb;

# Now we are going to create transaction which is long enough so its 
# transaction binlog will be flushed to disk...
let $1=2000;
disable_query_log;
begin;
while ($1)
{
 eval insert into t1 values( $1 );
 dec $1;
}
commit;
enable_query_log;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";

# Transaction which should not be flushed to disk and so should not
# increase binlog_cache_disk_use.
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
drop table t1;

#
# Bug #6126: Duplicate columns in keys gives misleading error message
#
@@ -1255,6 +1289,15 @@ select * from t1 where x > -16;
select count(*) from t1 where x = 18446744073709551601;
drop table t1;


# Test for testable InnoDB status variables. This test
# uses previous ones(pages_created, rows_deleted, ...).
show status like "Innodb_buffer_pool_pages_total";
show status like "Innodb_page_size";
show status like "Innodb_rows_deleted";
show status like "Innodb_rows_inserted";
show status like "Innodb_rows_updated";

# Test for row locks InnoDB status variables.
show status like "Innodb_row_lock_waits";
show status like "Innodb_row_lock_current_waits";
@@ -2086,55 +2129,13 @@ disconnect a;
disconnect b;

#
# Test that cascading updates leading to duplicate keys give the correct
# error message (bug #9680)
# Bug #14360: problem with intervals
#

CREATE TABLE t1 (
  field1 varchar(8) NOT NULL DEFAULT '',
  field2 varchar(8) NOT NULL DEFAULT '',
  PRIMARY KEY  (field1, field2)
) ENGINE=InnoDB;

CREATE TABLE t2 (
  field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
  FOREIGN KEY (field1) REFERENCES t1 (field1)
    ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

INSERT INTO t1 VALUES ('old', 'somevalu');
INSERT INTO t1 VALUES ('other', 'anyvalue');

INSERT INTO t2 VALUES ('old');
INSERT INTO t2 VALUES ('other');

--error ER_FOREIGN_DUPLICATE_KEY
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';

DROP TABLE t2;
DROP TABLE t1;

#
# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
#
create table t1 (
  c1 bigint not null,
  c2 bigint not null,
  primary key (c1),
  unique  key (c2)
) engine=innodb;
#
create table t2 (
  c1 bigint not null,
  primary key (c1)
) engine=innodb;
#
alter table t1 add constraint c2_fk foreign key (c2)
  references t2(c1) on delete cascade;
show create table t1;
#
alter table t1 drop foreign key c2_fk;
show create table t1;
#
create table t1(a date) engine=innodb;
create table t2(a date, key(a)) engine=innodb; 
insert into t1 values('2005-10-01');
insert into t2 values('2005-10-01');
select * from t1, t2
  where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
drop table t1, t2;
+35 −0
Original line number Diff line number Diff line
@@ -2002,6 +2002,41 @@ longlong Item_date_add_interval::val_int()
    ((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
}



bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const
{
  INTERVAL interval, other_interval;
  String val= value;   // Because of const

  if (this == item)
    return TRUE;

  if ((item->type() != FUNC_ITEM) ||
      (arg_count != ((Item_func*) item)->arg_count) ||
      (func_name() != ((Item_func*) item)->func_name()))
    return FALSE;

  Item_date_add_interval *other= (Item_date_add_interval*) item;

  if ((int_type != other->int_type) ||
      (!args[0]->eq(other->args[0], binary_cmp)) ||
      (get_interval_value(args[1], int_type, &val, &interval)))
    return FALSE;

  val= other->value;

  if ((get_interval_value(other->args[1], other->int_type, &val,
                         &other_interval)) ||
      ((date_sub_interval ^ interval.neg) ^
       (other->date_sub_interval ^ other_interval.neg)))
    return FALSE;

  // Assume comparing same types here due to earlier check
  return memcmp(&interval, &other_interval, sizeof(INTERVAL)) == 0;
}


static const char *interval_names[]=
{
  "year", "quarter", "month", "day", "hour",
+1 −0
Original line number Diff line number Diff line
@@ -647,6 +647,7 @@ class Item_date_add_interval :public Item_date_func
  double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
  longlong val_int();
  bool get_date(TIME *res, uint fuzzy_date);
  bool eq(const Item *item, bool binary_cmp) const;
  void print(String *str);
};