Commit 15346c8a authored by ram@mysql.r18.ru's avatar ram@mysql.r18.ru

fix and test case for the bug #787: HANDLER without INDEX doesn't work with deleted rows

parent ede742b6
...@@ -146,6 +146,25 @@ alter table t1 type=MyISAM; ...@@ -146,6 +146,25 @@ alter table t1 type=MyISAM;
handler t2 read first; handler t2 read first;
Unknown table 't2' in HANDLER Unknown table 't2' in HANDLER
drop table t1; drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
handler t1 open;
handler t1 read first;
a
3
handler t1 read first limit 1,1;
a
4
handler t1 read first limit 2,2;
a
5
6
delete from t1 limit 3;
handler t1 read first;
a
6
drop table t1;
create table t1(a int, index(a)); create table t1(a int, index(a));
insert into t1 values (1), (2), (3); insert into t1 values (1), (2), (3);
handler t1 open; handler t1 open;
......
...@@ -80,6 +80,21 @@ alter table t1 type=MyISAM; ...@@ -80,6 +80,21 @@ alter table t1 type=MyISAM;
handler t2 read first; handler t2 read first;
drop table t1; drop table t1;
#
# test case for the bug #787
#
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
handler t1 open;
handler t1 read first;
handler t1 read first limit 1,1;
handler t1 read first limit 2,2;
delete from t1 limit 3;
handler t1 read first;
drop table t1;
# #
#test for #751 #test for #751
# #
......
...@@ -219,6 +219,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -219,6 +219,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
goto err; goto err;
} }
if (err == HA_ERR_RECORD_DELETED)
continue;
if (err) if (err)
{ {
if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE) if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE)
...@@ -230,15 +232,9 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -230,15 +232,9 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
goto ok; goto ok;
} }
if (cond) if (cond && !cond->val_int())
{
err=err;
if (!cond->val_int())
continue; continue;
} if (!err && num_rows >= offset_limit)
if (num_rows>=offset_limit)
{
if (!err)
{ {
String *packet = &thd->packet; String *packet = &thd->packet;
Item *item; Item *item;
...@@ -255,7 +251,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -255,7 +251,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
} }
my_net_write(&thd->net, (char*)packet->ptr(), packet->length()); my_net_write(&thd->net, (char*)packet->ptr(), packet->length());
} }
}
num_rows++; num_rows++;
} }
ok: ok:
......
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