mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	doesn't continue reading the last range. mysql-test/r/index_merge_innodb.result: Testcase for BUG#12720 mysql-test/t/index_merge_innodb.test: Testcase for BUG#12720
		
			
				
	
	
		
			207 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			207 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
#
 | 
						|
# Index merge tests
 | 
						|
#
 | 
						|
-- source include/have_innodb.inc
 | 
						|
 | 
						|
--disable_warnings
 | 
						|
drop table if exists t1,t2;
 | 
						|
--enable_warnings
 | 
						|
 | 
						|
create table t1
 | 
						|
(
 | 
						|
  key1 int not null, 
 | 
						|
  key2 int not null, 
 | 
						|
  
 | 
						|
  INDEX i1(key1),
 | 
						|
  INDEX i2(key2)
 | 
						|
) engine=innodb;
 | 
						|
 | 
						|
--disable_query_log
 | 
						|
let $1=200;
 | 
						|
while ($1)
 | 
						|
{
 | 
						|
  eval insert into t1 values (200-$1, $1);
 | 
						|
  dec $1;
 | 
						|
}
 | 
						|
--enable_query_log
 | 
						|
 | 
						|
# No primary key
 | 
						|
explain select * from t1 where key1 < 5 or key2 > 197;
 | 
						|
 | 
						|
select * from t1 where key1 < 5 or key2 > 197;
 | 
						|
 | 
						|
explain select * from t1 where key1 < 3 or key2 > 195;
 | 
						|
select * from t1 where key1 < 3 or key2 > 195;
 | 
						|
 | 
						|
# Primary key as case-sensitive string with \0s.
 | 
						|
# also make primary key be longer then max. index length of MyISAM.
 | 
						|
alter table t1 add str1 char (255) not null, 
 | 
						|
                add zeroval int not null default 0,
 | 
						|
                add str2 char (255) not null,
 | 
						|
                add str3 char (255) not null;
 | 
						|
 | 
						|
update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
 | 
						|
 | 
						|
alter table t1 add primary key (str1, zeroval, str2, str3);
 | 
						|
                
 | 
						|
explain select * from t1 where key1 < 5 or key2 > 197;
 | 
						|
 | 
						|
select * from t1 where key1 < 5 or key2 > 197;
 | 
						|
 | 
						|
explain select * from t1 where key1 < 3 or key2 > 195;
 | 
						|
select * from t1 where key1 < 3 or key2 > 195;
 | 
						|
 | 
						|
# Test for BUG#5401
 | 
						|
drop table t1;
 | 
						|
create table t1 (
 | 
						|
  pk    integer not null auto_increment primary key,
 | 
						|
  key1  integer,
 | 
						|
  key2  integer not null,
 | 
						|
  filler char  (200),
 | 
						|
  index (key1),
 | 
						|
  index (key2)
 | 
						|
) engine=innodb;
 | 
						|
show warnings;
 | 
						|
--disable_query_log
 | 
						|
let $1=30;
 | 
						|
while ($1)
 | 
						|
{
 | 
						|
  eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data');
 | 
						|
  dec $1;
 | 
						|
}
 | 
						|
--enable_query_log
 | 
						|
explain select pk from t1 where key1 = 1 and key2 = 1;
 | 
						|
select pk from t1 where key2 = 1 and key1 = 1;
 | 
						|
select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
 | 
						|
 | 
						|
# More tests for BUG#5401. 
 | 
						|
drop table t1;
 | 
						|
create table t1 (
 | 
						|
  pk int primary key auto_increment,
 | 
						|
  key1a  int,
 | 
						|
  key2a  int,
 | 
						|
  key1b  int,
 | 
						|
  key2b  int,
 | 
						|
  dummy1 int,
 | 
						|
  dummy2 int,
 | 
						|
  dummy3 int,
 | 
						|
  dummy4 int,
 | 
						|
  key3a  int,
 | 
						|
  key3b  int,
 | 
						|
  filler1 char (200),
 | 
						|
  index i1(key1a, key1b),
 | 
						|
  index i2(key2a, key2b),
 | 
						|
  index i3(key3a, key3b)
 | 
						|
) engine=innodb;
 | 
						|
 | 
						|
create table t2 (a int);
 | 
						|
insert into t2 values (0),(1),(2),(3),(4),(NULL);
 | 
						|
 | 
						|
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) 
 | 
						|
  select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D;
 | 
						|
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) 
 | 
						|
  select key1a, key1b, key2a, key2b, key3a, key3b from t1;
 | 
						|
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) 
 | 
						|
  select key1a, key1b, key2a, key2b, key3a, key3b from t1;
 | 
						|
analyze table t1;
 | 
						|
select count(*) from t1;
 | 
						|
 | 
						|
explain select count(*) from t1 where 
 | 
						|
  key1a = 2 and key1b is null and  key2a = 2 and key2b is null;
 | 
						|
 | 
						|
select count(*) from t1 where 
 | 
						|
  key1a = 2 and key1b is null and key2a = 2 and key2b is null;
 | 
						|
 | 
						|
explain select count(*) from t1 where 
 | 
						|
  key1a = 2 and key1b is null and key3a = 2 and key3b is null;
 | 
						|
 | 
						|
select count(*) from t1 where 
 | 
						|
  key1a = 2 and key1b is null and key3a = 2 and key3b is null;
 | 
						|
 | 
						|
drop table t1,t2;
 | 
						|
 | 
						|
# Test for BUG#8441
 | 
						|
create table t1 (
 | 
						|
  id1 int,
 | 
						|
  id2 date ,
 | 
						|
  index idx2 (id1,id2),
 | 
						|
  index idx1 (id2)  
 | 
						|
) engine = innodb;
 | 
						|
insert into t1 values(1,'20040101'), (2,'20040102');
 | 
						|
select * from t1  where id1 = 1  and id2= '20040101'; 
 | 
						|
drop table t1;
 | 
						|
 | 
						|
# Test for BUG#12720
 | 
						|
--disable_warnings
 | 
						|
drop view if exists v1;
 | 
						|
--enable_warnings
 | 
						|
CREATE TABLE t1 (
 | 
						|
  `oid` int(11) unsigned NOT NULL auto_increment,
 | 
						|
  `fk_bbk_niederlassung` int(11) unsigned NOT NULL,
 | 
						|
  `fk_wochentag` int(11) unsigned NOT NULL,
 | 
						|
  `uhrzeit_von` time NOT NULL COMMENT 'HH:MM',
 | 
						|
  `uhrzeit_bis` time NOT NULL COMMENT 'HH:MM',
 | 
						|
  `geloescht` tinyint(4) NOT NULL,
 | 
						|
  `version` int(5) NOT NULL,
 | 
						|
  PRIMARY KEY  (`oid`),
 | 
						|
  KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`),
 | 
						|
  KEY `fk_wochentag` (`fk_wochentag`),
 | 
						|
  KEY `ix_version` (`version`)
 | 
						|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 | 
						|
 | 
						|
insert  into t1 values 
 | 
						|
(1, 38, 1, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(2, 38, 2, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(3, 38, 3, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(4, 38, 4, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(5, 38, 5, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(6, 38, 5, '08:00:00', '13:00:00', 1, 2),
 | 
						|
(7, 38, 3, '08:00:00', '13:00:00', 1, 2),
 | 
						|
(8, 38, 1, '08:00:00', '13:00:00', 1, 2),
 | 
						|
(9, 38, 2, '08:00:00', '13:00:00', 1, 2),
 | 
						|
(10, 38, 4, '08:00:00', '13:00:00', 1, 2),
 | 
						|
(11, 38, 1, '08:00:00', '13:00:00', 0, 3),
 | 
						|
(12, 38, 2, '08:00:00', '13:00:00', 0, 3),
 | 
						|
(13, 38, 3, '08:00:00', '13:00:00', 0, 3),
 | 
						|
(14, 38, 4, '08:00:00', '13:00:00', 0, 3),
 | 
						|
(15, 38, 5, '08:00:00', '13:00:00', 0, 3),
 | 
						|
(16, 38, 4, '08:00:00', '13:00:00', 0, 4),
 | 
						|
(17, 38, 5, '08:00:00', '13:00:00', 0, 4),
 | 
						|
(18, 38, 1, '08:00:00', '13:00:00', 0, 4),
 | 
						|
(19, 38, 2, '08:00:00', '13:00:00', 0, 4),
 | 
						|
(20, 38, 3, '08:00:00', '13:00:00', 0, 4),
 | 
						|
(21, 7, 1, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(22, 7, 2, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(23, 7, 3, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(24, 7, 4, '08:00:00', '13:00:00', 0, 1),
 | 
						|
(25, 7, 5, '08:00:00', '13:00:00', 0, 1);
 | 
						|
 | 
						|
create view v1 as 
 | 
						|
select 
 | 
						|
  zeit1.oid AS oid, 
 | 
						|
  zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung,
 | 
						|
  zeit1.fk_wochentag AS fk_wochentag,
 | 
						|
  zeit1.uhrzeit_von AS uhrzeit_von, 
 | 
						|
  zeit1.uhrzeit_bis AS uhrzeit_bis, 
 | 
						|
  zeit1.geloescht AS geloescht,
 | 
						|
  zeit1.version AS version
 | 
						|
from 
 | 
						|
  t1 zeit1
 | 
						|
where 
 | 
						|
(zeit1.version = 
 | 
						|
  (select max(zeit2.version) AS `max(version)`
 | 
						|
   from t1 zeit2 
 | 
						|
   where 
 | 
						|
     ((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and 
 | 
						|
      (zeit1.fk_wochentag = zeit2.fk_wochentag) and 
 | 
						|
      (zeit1.uhrzeit_von = zeit2.uhrzeit_von) and 
 | 
						|
      (zeit1.uhrzeit_bis = zeit2.uhrzeit_bis)
 | 
						|
     )
 | 
						|
  )
 | 
						|
)
 | 
						|
and (zeit1.geloescht = 0);
 | 
						|
 | 
						|
select * from v1 where oid = 21;
 | 
						|
drop view v1;
 | 
						|
drop table t1;
 |