summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorram@mysql.r18.ru <>2003-07-04 17:15:16 +0500
committerram@mysql.r18.ru <>2003-07-04 17:15:16 +0500
commit15346c8a6675e5dc57fea1e804e9cba786e6931f (patch)
tree342ce2825ff481ad0d90c2f76758b63b77613fc7
parentede742b6303e5ceebee56ec550d943ebdcf172f3 (diff)
downloadmariadb-git-15346c8a6675e5dc57fea1e804e9cba786e6931f.tar.gz
fix and test case for the bug #787: HANDLER without INDEX doesn't work with deleted rows
-rw-r--r--mysql-test/r/handler.result19
-rw-r--r--mysql-test/t/handler.test15
-rw-r--r--sql/sql_handler.cc39
3 files changed, 51 insertions, 22 deletions
diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result
index 1973797ae79..4af38807518 100644
--- a/mysql-test/r/handler.result
+++ b/mysql-test/r/handler.result
@@ -146,6 +146,25 @@ alter table t1 type=MyISAM;
handler t2 read first;
Unknown table 't2' in HANDLER
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));
insert into t1 values (1), (2), (3);
handler t1 open;
diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test
index 39ceab7ab22..737b220c805 100644
--- a/mysql-test/t/handler.test
+++ b/mysql-test/t/handler.test
@@ -81,6 +81,21 @@ handler t2 read first;
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
#
create table t1(a int, index(a));
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 42cfcb51377..e685ea3a059 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -219,6 +219,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
goto err;
}
+ if (err == HA_ERR_RECORD_DELETED)
+ continue;
if (err)
{
if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE)
@@ -230,31 +232,24 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
}
goto ok;
}
- if (cond)
+ if (cond && !cond->val_int())
+ continue;
+ if (!err && num_rows >= offset_limit)
{
- err=err;
- if (!cond->val_int())
- continue;
- }
- if (num_rows>=offset_limit)
- {
- if (!err)
+ String *packet = &thd->packet;
+ Item *item;
+ packet->length(0);
+ it.rewind();
+ while ((item=it++))
{
- String *packet = &thd->packet;
- Item *item;
- packet->length(0);
- it.rewind();
- while ((item=it++))
- {
- if (item->send(thd,packet))
- {
- packet->free(); // Free used
- my_error(ER_OUT_OF_RESOURCES,MYF(0));
- goto err;
- }
- }
- my_net_write(&thd->net, (char*)packet->ptr(), packet->length());
+ if (item->send(thd,packet))
+ {
+ packet->free(); // Free used
+ my_error(ER_OUT_OF_RESOURCES,MYF(0));
+ goto err;
+ }
}
+ my_net_write(&thd->net, (char*)packet->ptr(), packet->length());
}
num_rows++;
}