mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
4d0ef0cc85
Bug#28878: InnoDB tables with UTF8 character set and indexes cause wrong result for DML When making key reference buffers over CHAR fields whitespace (0x20) must be used to fill in the remaining space in the field's buffer. This is what Field_string::store() does. Fixed Field_string::get_key_image() to do the same. mysql-test/r/innodb_mysql.result: Bug#28878: test case mysql-test/t/innodb_mysql.test: Bug#28878: test case sql/field.cc: Bug#28878: Fill with space instead of binary zeros.
251 lines
7 KiB
Text
251 lines
7 KiB
Text
-- source include/have_innodb.inc
|
|
|
|
--disable_warnings
|
|
drop table if exists t1,t2;
|
|
--enable_warnings
|
|
|
|
# BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer
|
|
# (repeatable only w/innodb).
|
|
create table t1 (
|
|
c_id int(11) not null default '0',
|
|
org_id int(11) default null,
|
|
unique key contacts$c_id (c_id),
|
|
key contacts$org_id (org_id)
|
|
) engine=innodb;
|
|
insert into t1 values
|
|
(2,null),(120,null),(141,null),(218,7), (128,1),
|
|
(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
|
|
(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
|
|
|
|
create table t2 (
|
|
slai_id int(11) not null default '0',
|
|
owner_tbl int(11) default null,
|
|
owner_id int(11) default null,
|
|
sla_id int(11) default null,
|
|
inc_web int(11) default null,
|
|
inc_email int(11) default null,
|
|
inc_chat int(11) default null,
|
|
inc_csr int(11) default null,
|
|
inc_total int(11) default null,
|
|
time_billed int(11) default null,
|
|
activedate timestamp null default null,
|
|
expiredate timestamp null default null,
|
|
state int(11) default null,
|
|
sla_set int(11) default null,
|
|
unique key t2$slai_id (slai_id),
|
|
key t2$owner_id (owner_id),
|
|
key t2$sla_id (sla_id)
|
|
) engine=innodb;
|
|
insert into t2(slai_id, owner_tbl, owner_id, sla_id) values
|
|
(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7),
|
|
(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12);
|
|
|
|
flush tables;
|
|
select si.slai_id
|
|
from t1 c join t2 si on
|
|
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
|
|
( si.owner_tbl = 2 and si.owner_id = c.c_id))
|
|
where
|
|
c.c_id = 218 and expiredate is null;
|
|
|
|
select * from t1 where org_id is null;
|
|
select si.slai_id
|
|
from t1 c join t2 si on
|
|
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
|
|
( si.owner_tbl = 2 and si.owner_id = c.c_id))
|
|
where
|
|
c.c_id = 218 and expiredate is null;
|
|
|
|
drop table t1, t2;
|
|
|
|
#
|
|
# Bug#17212: results not sorted correctly by ORDER BY when using index
|
|
# (repeatable only w/innodb because of index props)
|
|
#
|
|
CREATE TABLE t1 (a int, b int, KEY b (b)) Engine=InnoDB;
|
|
CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)) Engine=InnoDB;
|
|
CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
|
|
UNIQUE KEY b (b,c), KEY a (a,b,c)) Engine=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1, 1);
|
|
INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
|
|
INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
|
|
|
|
INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
|
|
INSERT INTO t2 SELECT a + 1, b FROM t2;
|
|
DELETE FROM t2 WHERE a = 1 AND b < 2;
|
|
|
|
INSERT INTO t3 VALUES (1,1,1),(2,1,2);
|
|
INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
|
|
INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
|
|
|
|
# demonstrate a problem when a must-use-sort table flag
|
|
# (sort_by_table=1) is being neglected.
|
|
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
|
|
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
|
|
ORDER BY t1.b LIMIT 2;
|
|
|
|
# demonstrate the problem described in the bug report
|
|
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
|
|
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
|
|
ORDER BY t1.b LIMIT 5;
|
|
DROP TABLE t1, t2, t3;
|
|
|
|
|
|
# BUG#21077 (The testcase is not deterministic so correct execution doesn't
|
|
# prove anything) For proof one should track if sequence of ha_innodb::* func
|
|
# calls is correct.
|
|
CREATE TABLE `t1` (`id1` INT) ;
|
|
INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
|
|
|
|
CREATE TABLE `t2` (
|
|
`id1` INT,
|
|
`id2` INT NOT NULL,
|
|
`id3` INT,
|
|
`id4` INT NOT NULL,
|
|
UNIQUE (`id2`,`id4`),
|
|
KEY (`id1`)
|
|
) ENGINE=InnoDB;
|
|
|
|
INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
|
|
(1,1,1,0),
|
|
(1,1,2,1),
|
|
(5,1,2,2),
|
|
(6,1,2,3),
|
|
(1,2,2,2),
|
|
(1,2,1,1);
|
|
|
|
SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
|
|
DROP TABLE t1, t2;
|
|
|
|
|
|
#
|
|
# BUG#18819: DELETE IGNORE hangs on foreign key parent delete
|
|
#
|
|
# The bug itself does not relate to InnoDB, but we have to use foreign
|
|
# keys to reproduce it.
|
|
#
|
|
--disable_warnings
|
|
DROP TABLE IF EXISTS t2, t1;
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB;
|
|
CREATE TABLE t2 (
|
|
i INT NOT NULL,
|
|
FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION
|
|
) ENGINE= InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1);
|
|
INSERT INTO t2 VALUES (1);
|
|
|
|
DELETE IGNORE FROM t1 WHERE i = 1;
|
|
|
|
SELECT * FROM t1, t2;
|
|
|
|
DROP TABLE t2, t1;
|
|
|
|
|
|
#
|
|
# Bug #22728 - Handler_rollback value is growing
|
|
#
|
|
flush status;
|
|
create table t1 (c1 int) engine=innodb;
|
|
connect (con1,localhost,root,,);
|
|
connect (con2,localhost,root,,);
|
|
connection con2;
|
|
handler t1 open;
|
|
handler t1 read first;
|
|
disconnect con2;
|
|
connection con1;
|
|
show /*!50002 GLOBAL */ status like 'Handler_rollback';
|
|
connection default;
|
|
drop table t1;
|
|
disconnect con1;
|
|
|
|
#
|
|
# Bug #13191: INSERT...ON DUPLICATE KEY UPDATE of UTF-8 string fields
|
|
# used in partial unique indices.
|
|
#
|
|
|
|
CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
SELECT * FROM t1;
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
SELECT * FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
SELECT * FROM t1;
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
SELECT * FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
SELECT * FROM t1;
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
SELECT * FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
# Bug #28272: EXPLAIN for SELECT from an empty InnoDB table
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
a1 decimal(10,0) DEFAULT NULL,
|
|
a2 blob,
|
|
a3 time DEFAULT NULL,
|
|
a4 blob,
|
|
a5 char(175) DEFAULT NULL,
|
|
a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
a7 tinyblob,
|
|
INDEX idx (a6,a7(239),a5)
|
|
) ENGINE=InnoDB;
|
|
|
|
EXPLAIN SELECT a4 FROM t1 WHERE
|
|
a6=NULL AND
|
|
a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
|
|
|
EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE
|
|
t.a6=t.a6 AND t1.a6=NULL AND
|
|
t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
# Bug #28878: InnoDB tables with UTF8 character set and indexes cause wrong result for DML
|
|
#
|
|
|
|
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
|
|
INSERT INTO t1 VALUES ('uk'),('bg');
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
DELETE FROM t1 WHERE a = 'uk';
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
UPDATE t1 SET a = 'us' WHERE a = 'uk';
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
|
|
INSERT INTO t2 VALUES ('uk'),('bg');
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
DELETE FROM t2 WHERE a = 'uk';
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
INSERT INTO t2 VALUES ('uk');
|
|
UPDATE t2 SET a = 'us' WHERE a = 'uk';
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
|
|
INSERT INTO t3 VALUES ('uk'),('bg');
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
DELETE FROM t3 WHERE a = 'uk';
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
INSERT INTO t3 VALUES ('uk');
|
|
UPDATE t3 SET a = 'us' WHERE a = 'uk';
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
DROP TABLE t1,t2,t3;
|
|
|
|
--echo End of 4.1 tests
|