summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-26 12:30:35 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-26 12:35:09 +0200
commitf5936fa1c2e0ee4d25ba0c1a9944ebe29a6eee4b (patch)
tree3394b2585bba223bbfa8da8e3a1153b9002c2f13
parentb766149d5fa4cdb76c117f4246d83948babf0ad8 (diff)
downloadredis-f5936fa1c2e0ee4d25ba0c1a9944ebe29a6eee4b.tar.gz
Return error to client on wrong type for HMGET (backport of e584d82f)
-rw-r--r--redis.c1
-rw-r--r--tests/unit/type/hash.tcl5
2 files changed, 6 insertions, 0 deletions
diff --git a/redis.c b/redis.c
index ffe7c2b4c..fefaa6bd1 100644
--- a/redis.c
+++ b/redis.c
@@ -6707,6 +6707,7 @@ static void hmgetCommand(redisClient *c) {
o = lookupKeyRead(c->db,c->argv[1]);
if (o != NULL && o->type != REDIS_HASH) {
addReply(c,shared.wrongtypeerr);
+ return;
}
/* Note the check for o != NULL happens inside the loop. This is
diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl
index ef49a27d8..451438dba 100644
--- a/tests/unit/type/hash.tcl
+++ b/tests/unit/type/hash.tcl
@@ -140,6 +140,11 @@ start_server {tags {"hash"}} {
set _ $rv
} {{{} {}} {{} {}} {{} {}}}
+ test {HMGET against wrong type} {
+ r set wrongtype somevalue
+ assert_error "*wrong*" {r hmget wrongtype field1 field2}
+ }
+
test {HMGET - small hash} {
set keys {}
set vals {}