From 330c90b01848f0f7b945aafd0f36c1703adbfd7f Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 16 May 2011 17:20:27 +0200 Subject: [PATCH 1/6] fmacros in utils.c to avoid warning about strcasecmp() --- src/util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util.c b/src/util.c index e83dbedd..f5a23af2 100644 --- a/src/util.c +++ b/src/util.c @@ -1,9 +1,11 @@ +#include "fmacros.h" #include #include #include #include #include #include + #include "util.h" /* Glob-style pattern matching. */ From 521ddcce1483d1b8760a108fd5d7df0ae663799a Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 19 May 2011 17:58:29 +0200 Subject: [PATCH 2/6] Fix for ZUNIONSTORE bug when there is an empty set among input sets. Regression test added. --- src/t_zset.c | 2 +- tests/unit/type/zset.tcl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/t_zset.c b/src/t_zset.c index 1c55cb97..19aac3d5 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1550,7 +1550,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { } } else if (op == REDIS_OP_UNION) { for (i = 0; i < setnum; i++) { - if (zuiLength(&src[0]) == 0) + if (zuiLength(&src[i]) == 0) continue; while (zuiNext(&src[i],&zval)) { diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index 37668cfe..761cac49 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -353,6 +353,14 @@ start_server {tags {"zset"}} { assert_equal 0 [r exists dst_key] } + test "ZUNIONSTORE with empty set - $encoding" { + r del zseta zsetb + r zadd zseta 1 a + r zadd zseta 2 b + r zunionstore zsetc 2 zseta zsetb + r zrange zsetc 0 -1 withscores + } {a 1 b 2} + test "ZUNIONSTORE basics - $encoding" { r del zseta zsetb zsetc r zadd zseta 1 a From 206d62710c2cf35ae036f55d59c8a523ad22abd8 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 20 May 2011 11:44:09 +0200 Subject: [PATCH 3/6] Print version info before running the test --- tests/test_helper.tcl | 1 + tests/unit/printver.tcl | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 tests/unit/printver.tcl diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index c594f6f6..6dc85eff 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -110,6 +110,7 @@ proc cleanup {} { } proc execute_everything {} { + execute_tests "unit/printver" execute_tests "unit/auth" execute_tests "unit/protocol" execute_tests "unit/basic" diff --git a/tests/unit/printver.tcl b/tests/unit/printver.tcl new file mode 100644 index 00000000..c80f4514 --- /dev/null +++ b/tests/unit/printver.tcl @@ -0,0 +1,6 @@ +start_server {} { + set i [r info] + regexp {redis_version:(.*?)\r\n} $i - version + regexp {redis_git_sha1:(.*?)\r\n} $i - sha1 + puts "Testing Redis version $version ($sha1)" +} From d200342ac2730c27cd456a79cc9e8725eaf0c5c2 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 24 May 2011 10:35:48 +0200 Subject: [PATCH 4/6] Fixed typo in comment --- src/t_zset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t_zset.c b/src/t_zset.c index 19aac3d5..a5dc27c7 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1521,7 +1521,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { score = src[0].weight * zval.score; for (j = 1; j < setnum; j++) { - /* It is not safe to access the hash we zset we are + /* It is not safe to access the zset we are * iterating, so explicitly check for equal object. */ if (src[j].subject == src[0].subject) { value = zval.score*src[j].weight; @@ -1566,7 +1566,7 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { /* Because the inputs are sorted by size, it's only possible * for sets at larger indices to hold this element. */ for (j = (i+1); j < setnum; j++) { - /* It is not safe to access the hash we zset we are + /* It is not safe to access the zset we are * iterating, so explicitly check for equal object. */ if(src[j].subject == src[i].subject) { value = zval.score*src[j].weight; From 27fee630f509fcca03e97e4d9632e967c81e60b8 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 24 May 2011 10:43:19 +0200 Subject: [PATCH 5/6] Comment typo fixed --- tests/integration/replication.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index 7be4df4b..892fae03 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -28,7 +28,7 @@ start_server {tags {"repl"}} { createComplexDataset r 50000 useexpire after 4000 ;# Make sure everything expired before taking the digest r keys * ;# Force DEL syntesizing to slave - after 1000 ;# Wait another second. Now everything should be file. + after 1000 ;# Wait another second. Now everything should be fine. if {[r debug digest] ne [r -1 debug digest]} { set csv1 [csvdump r] set csv2 [csvdump {r -1}] From efc3408748061a08ec5ff18e392c30f31f5094a2 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 25 May 2011 12:29:14 +0200 Subject: [PATCH 6/6] Fix for Pub/Sub system, introduced in Redis 2.2.6 with the new copy-on-write safe iterator semantics. In the hope this is the last bug I introduced this way. --- src/pubsub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pubsub.c b/src/pubsub.c index 2bd3d058..728e559c 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -141,7 +141,7 @@ int pubsubUnsubscribePattern(redisClient *c, robj *pattern, int notify) { /* Unsubscribe from all the channels. Return the number of channels the * client was subscribed from. */ int pubsubUnsubscribeAllChannels(redisClient *c, int notify) { - dictIterator *di = dictGetIterator(c->pubsub_channels); + dictIterator *di = dictGetSafeIterator(c->pubsub_channels); dictEntry *de; int count = 0;