From 3738ff5f32aaadd3074a691544caf2f2daa77928 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 31 May 2011 20:14:29 +0200 Subject: [PATCH] Fix for the variadic version of SREM. Regression test added. --- src/t_set.c | 5 ++++- tests/unit/type/set.tcl | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/t_set.c b/src/t_set.c index be083c8b..c7d05c2f 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -249,8 +249,11 @@ void sremCommand(redisClient *c) { for (j = 2; j < c->argc; j++) { if (setTypeRemove(set,c->argv[j])) { - if (setTypeSize(set) == 0) dbDelete(c->db,c->argv[1]); deleted++; + if (setTypeSize(set) == 0) { + dbDelete(c->db,c->argv[1]); + break; + } } } if (deleted) { diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl index 1a37ed61..bdd1f9bf 100644 --- a/tests/unit/type/set.tcl +++ b/tests/unit/type/set.tcl @@ -105,6 +105,12 @@ start_server { lsort [r smembers myset] } {a c} + test {SREM variadic version with more args needed to destroy the key} { + r del myset + r sadd myset 1 2 3 + r srem myset 1 2 3 4 5 6 7 8 + } {3} + foreach {type} {hashtable intset} { for {set i 1} {$i <= 5} {incr i} { r del [format "set%d" $i] -- 2.45.2