Commit 4b44b849 authored by unknown's avatar unknown

Fixed problem with range optimization over overlapping ranges (#2448)


mysql-test/r/ctype_tis620.result:
  Cleanup test
mysql-test/r/range.result:
  Test problem with range optimization over overlapping ranges (#2448)
mysql-test/t/ctype_tis620.test:
  Cleanup test
mysql-test/t/range.test:
  Test problem with range optimization over overlapping ranges (#2448)
sql/mysqld.cc:
  Remove debug statement
strings/ctype-tis620.c:
  est problem with range optimization over overlapping ranges (#2448)
parent 7ba7ce6e
DROP TABLE IF EXISTS t620;
CREATE TABLE t620 (
drop table if exists t1;
CREATE TABLE t1 (
recid int(11) NOT NULL auto_increment,
dyninfo text,
PRIMARY KEY (recid)
) TYPE=MyISAM;
INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n');
INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n');
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n');
INSERT INTO t1 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n');
SELECT DISTINCT
(IF( LOCATE( 'year=\"', dyninfo ) = 1,
SUBSTRING( dyninfo, 6+1, LOCATE('\"\r',dyninfo) - 6 -1),
IF( LOCATE( '\nyear=\"', dyninfo ),
SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7,
LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year
FROM t620
FROM t1
HAVING year != '' ORDER BY year;
year
DROP TABLE t1;
......@@ -300,3 +300,16 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1);
COUNT(*)
6
DROP TABLE t1;
CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) );
INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4);
SELECT * FROM t1
WHERE
(
( b =1 AND a BETWEEN 14 AND 21 ) OR
( b =2 AND a BETWEEN 16 AND 18 ) OR
( b =3 AND a BETWEEN 15 AND 19 ) OR
(a BETWEEN 19 AND 47)
);
a b
15 1
47 1
DROP TABLE IF EXISTS t620;
CREATE TABLE t620 (
--disable_warnings
drop table if exists t1;
--enable_warnings
CREATE TABLE t1 (
recid int(11) NOT NULL auto_increment,
dyninfo text,
PRIMARY KEY (recid)
) TYPE=MyISAM;
) ENGINE=MyISAM;
INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n');
INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n');
INSERT INTO t1 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n');
INSERT INTO t1 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n');
SELECT DISTINCT
(IF( LOCATE( 'year=\"', dyninfo ) = 1,
......@@ -14,5 +17,7 @@ SELECT DISTINCT
IF( LOCATE( '\nyear=\"', dyninfo ),
SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7,
LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year
FROM t620
FROM t1
HAVING year != '' ORDER BY year;
DROP TABLE t1;
......@@ -238,7 +238,7 @@ SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
DROP TABLE t1;
#
# Test error with
# Test problem with range optimzer and sub ranges
#
CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b));
......@@ -249,3 +249,17 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1);
SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1);
DROP TABLE t1;
#
# Test problem with range optimization over overlapping ranges (#2448)
#
CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) );
INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4);
SELECT * FROM t1
WHERE
(
( b =1 AND a BETWEEN 14 AND 21 ) OR
( b =2 AND a BETWEEN 16 AND 18 ) OR
( b =3 AND a BETWEEN 15 AND 19 ) OR
(a BETWEEN 19 AND 47)
);
......@@ -4747,7 +4747,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
berkeley_env_flags|= DB_TXN_NOSYNC;
else
berkeley_env_flags&= ~DB_TXN_NOSYNC;
printf("berkeley_env_flags: %d, arg '%s'\n", berkeley_env_flags, argument);
break;
case OPT_BDB_NO_RECOVER:
berkeley_init_flags&= ~(DB_RECOVER);
......
......@@ -1710,6 +1710,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
return 0; // OOM
tmp->copy_max_to_min(&key);
tmp->increment_use_count(key1->use_count+1);
/* Increment key count as it may be used for next loop */
key.increment_use_count(1);
new_arg->next_key_part=key_or(tmp->next_key_part,key.next_key_part);
key1=key1->insert(new_arg);
break;
......@@ -2708,15 +2710,18 @@ int QUICK_SELECT_DESC::get_next()
}
else
{
/* Heikki changed Sept 11, 2002: since InnoDB does not store the cursor
position if READ_KEY_EXACT is used to a primary key with all
key columns specified, we must use below HA_READ_KEY_OR_NEXT,
so that InnoDB stores the cursor position and is able to move
the cursor one step backward after the search. */
/*
Heikki changed Sept 11, 2002: since InnoDB does not store the cursor
position if READ_KEY_EXACT is used to a primary key with all
key columns specified, we must use below HA_READ_KEY_OR_NEXT,
so that InnoDB stores the cursor position and is able to move
the cursor one step backward after the search. */
DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range));
/* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
* do the right thing - go past all keys which match the prefix */
/*
Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
do the right thing - go past all keys which match the prefix
*/
result=file->index_read(record, (byte*) range->max_key,
range->max_length,
((range->flag & NEAR_MAX) ?
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment