Commit c150453b authored by monty@mysql.com's avatar monty@mysql.com

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/my/mysql-4.1
parents ec33d794 f6dc9169
......@@ -222,3 +222,16 @@ explain select 1 from t1 where id =2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref id id 4 const 1 Using where; Using index
drop table t1;
CREATE TABLE t1 (numeropost mediumint(8) unsigned NOT NULL default '0', numreponse int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
SELECT numeropost FROM t1 WHERE numreponse='1';
numeropost
1
EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const numreponse numreponse 4 const 1 Using index
FLUSH TABLES;
SELECT numeropost FROM t1 WHERE numreponse='1';
numeropost
1
drop table t1;
......@@ -216,3 +216,15 @@ explain select name from t1 where id =2;
ALTER TABLE t1 DROP PRIMARY KEY, ADD INDEX (id);
explain select 1 from t1 where id =2;
drop table t1;
#
# Test of problem with key read (Bug #3666)
#
CREATE TABLE t1 (numeropost mediumint(8) unsigned NOT NULL default '0', numreponse int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
SELECT numeropost FROM t1 WHERE numreponse='1';
EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1';
FLUSH TABLES;
SELECT numeropost FROM t1 WHERE numreponse='1';
drop table t1;
......@@ -3638,7 +3638,7 @@ make_join_readinfo(JOIN *join, uint options)
table->status=STATUS_NO_RECORD;
tab->read_first_record= join_read_const;
tab->read_record.read_record= join_no_more_records;
if (table->used_keys.is_set(tab->index) &&
if (table->used_keys.is_set(tab->ref.key) &&
!table->no_keyread)
{
table->key_read=1;
......@@ -5967,7 +5967,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
}
else
{
if (!table->key_read && table->used_keys.is_set(tab->index) &&
if (!table->key_read && table->used_keys.is_set(tab->ref.key) &&
!table->no_keyread)
{
table->key_read=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