Commit 6d7862ae authored by igor@linux.local's avatar igor@linux.local

logging_ok:

  Logging to logging@openlogging.org accepted
func_group.result, func_group.test:
  Added a test case for bug #8893.
opt_sum.cc:
  A misplaced initialization for the returned parameter
  prefix_len in the function find_key_for_maxmin caused
  usage of a wrong key prefix by the min/max optimization
  in cases when the matching index was not the first index
  that contained the min/max field.
parent d565920b
......@@ -67,6 +67,7 @@ hf@deer.(none)
hf@deer.mysql.r18.ru
hf@genie.(none)
igor@hundin.mysql.fi
igor@linux.local
igor@rurik.mysql.com
ingo@mysql.com
jan@hundin.mysql.fi
......
......@@ -754,3 +754,29 @@ show columns from t2;
Field Type Null Key Default Extra
f2 datetime 0000-00-00 00:00:00
drop table t2, t1;
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_b_id(a,b,id),
INDEX i_id(a,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
MAX(id)
NULL
DROP TABLE t1;
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_id(a,id),
INDEX i_b_id(a,b,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
MAX(id)
NULL
DROP TABLE t1;
......@@ -496,3 +496,33 @@ drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
drop table t2, t1;
#
# Bug 8893: wrong result for min/max optimization with 2 indexes
#
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_b_id(a,b,id),
INDEX i_id(a,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
DROP TABLE t1;
# change the order of the last two index definitions
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_id(a,id),
INDEX i_b_id(a,b,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
DROP TABLE t1;
......@@ -624,7 +624,6 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
{
if (!(field->flags & PART_KEY_FLAG))
return 0; // Not key field
*prefix_len= 0;
TABLE *table= field->table;
uint idx= 0;
......@@ -637,6 +636,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
KEY_PART_INFO *part,*part_end;
key_part_map key_part_to_use= 0;
uint jdx= 0;
*prefix_len= 0;
for (part= keyinfo->key_part, part_end= part+keyinfo->key_parts ;
part != part_end ;
part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1)
......
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