summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/t/handler.test65
-rw-r--r--sql/sql_handler.cc6
2 files changed, 47 insertions, 24 deletions
diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test
index 18f1d37fee4..a84a574aa29 100644
--- a/mysql-test/t/handler.test
+++ b/mysql-test/t/handler.test
@@ -3,30 +3,47 @@
#
drop table if exists t1;
-create table t1 (a int, b char(10), key a(a));
+create table t1 (a int, b char(10), key a(a), key b(a,b));
insert into t1 values
-(14,"aaa"),(15,"bbb"),(16,"ccc"),
-(17,"ddd"),(18,"eee"),(19,"fff"),
+(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
+(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(20,"ggg"),(21,"hhh"),(22,"iii");
-handler t1 open;
-handler t1 read a first;
-handler t1 read a next;
-handler t1 read a next;
-handler t1 read a prev;
-handler t1 read a last;
-handler t1 read a prev;
-handler t1 read a prev;
-
-handler t1 read a first;
-handler t1 read a prev;
-
-handler t1 read a last;
-handler t1 read a prev;
-handler t1 read a next;
-handler t1 read a next;
-
-handler t1 read a=(15);
-
-handler t1 close;
-drop table if exists t1;
+handler t1 open as t2;
+handler t2 read a first;
+handler t2 read a next;
+handler t2 read a next;
+handler t2 read a prev;
+handler t2 read a last;
+handler t2 read a prev;
+handler t2 read a prev;
+
+handler t2 read a first;
+handler t2 read a prev;
+
+handler t2 read a last;
+handler t2 read a prev;
+handler t2 read a next;
+handler t2 read a next;
+
+handler t2 read a=(15);
+handler t2 read a=(16);
+
+!$1070 handler t2 read a=(19,"fff");
+handler t2 read b=(19,"fff");
+handler t2 read b=(19,"yyy");
+handler t2 read b=(19);
+
+!$1109 handler t1 read a last;
+
+handler t2 read a=(11);
+handler t2 read a>=(11);
+
+handler t2 read a=(18);
+handler t2 read a>=(18);
+handler t2 read a>(18);
+handler t2 read a<=(18);
+handler t2 read a<(18);
+
+handler t2 close;
+drop table if exists t1;
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index df6734c5fd3..17d5ea02e82 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -90,6 +90,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
KEY *keyinfo=table->key_info+keyno;
uint key_len=0, i;
byte *key, *buf;
+ if (key_expr->elements > keyinfo->key_parts)
+ {
+ my_printf_error(ER_TOO_MANY_KEY_PARTS,ER(ER_TOO_MANY_KEY_PARTS),
+ MYF(0),keyinfo->key_parts);
+ return -1;
+ }
for (i=0; i < key_expr->elements; i++)
key_len+=keyinfo->key_part[i].store_length;
if (!(key=sql_calloc(ALIGN_SIZE(key_len))))