summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Nethercutt <glenn.nethercutt@inin.com>2015-04-17 09:27:54 -0400
committerGlenn Nethercutt <glenn.nethercutt@inin.com>2015-04-17 09:27:54 -0400
commit626b4f69078276e35ed947e0d4ebd704e7f09992 (patch)
treeb5d00cfd2a0eb53179e8f963b5708217627ae96b
parent6c60526db91e23fb2d666fc52facc9a11780a2a3 (diff)
downloadredis-626b4f69078276e35ed947e0d4ebd704e7f09992.tar.gz
uphold the smove contract to return 0 when the element is not a member of the source set, even if source=dest
-rw-r--r--src/t_set.c5
-rw-r--r--tests/unit/type/set.tcl1
2 files changed, 5 insertions, 1 deletions
diff --git a/src/t_set.c b/src/t_set.c
index c974c1855..f50c0aa34 100644
--- a/src/t_set.c
+++ b/src/t_set.c
@@ -343,7 +343,10 @@ void smoveCommand(redisClient *c) {
/* If srcset and dstset are equal, SMOVE is a no-op */
if (srcset == dstset) {
- addReply(c,shared.cone);
+ if (setTypeIsMember(srcset,ele))
+ addReply(c,shared.cone);
+ else
+ addReply(c,shared.czero);
return;
}
diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl
index a9a3d0835..7b467f1c4 100644
--- a/tests/unit/type/set.tcl
+++ b/tests/unit/type/set.tcl
@@ -519,6 +519,7 @@ start_server {
test "SMOVE non existing key" {
setup_move
assert_equal 0 [r smove myset1 myset2 foo]
+ assert_equal 0 [r smove myset1 myset1 foo]
assert_equal {1 a b} [lsort [r smembers myset1]]
assert_equal {2 3 4} [lsort [r smembers myset2]]
}