Fixed a bug in optimiser with MERGE tables with non-unique values

with aggregating functions.

This consistently crashed Mysql
parent eab0de7c
......@@ -49456,7 +49456,12 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@item
Fixed a bug in optimiser when a range specified makes index grouping impossible
Fixed a bug in optimiser with merge tables when non-uniques values are
used in summing up.
This consistently crashed MySQL.
@item
Fixed a bug in optimiser when a range specified makes index grouping impossible.
This consistently crashed MySQL.
@item
Fixed a rare bug when fulltext index is present and no tables are used
@item
......@@ -462,3 +462,12 @@ a b
6 1
6 2
drop table if exists t6, t5, t4, t3, t2, t1;
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,1);
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,2), (2,2);
CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
select max(b) from t where a = 2;
max(b)
NULL
drop table if exists t,t1,t2;
......@@ -168,3 +168,10 @@ select * from t3 order by a,b;
select * from t4 order by a,b;
select * from t5 order by a,b;
drop table if exists t6, t5, t4, t3, t2, t1;
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,1);
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,2), (2,2);
CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
select max(b) from t where a = 2;
drop table if exists t,t1,t2;
......@@ -152,9 +152,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
error=table->file->index_last(table->record[0]) !=0;
else
{
(void) table->file->index_read(table->record[0], key_buff,
error= table->file->index_read(table->record[0], key_buff,
ref.key_length,
HA_READ_AFTER_KEY);
if (!error)
error=table->file->index_prev(table->record[0]) ||
key_cmp(table,key_buff,ref.key,ref.key_length);
}
......
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