summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2014-08-01 13:57:30 -0400
committerantirez <antirez@gmail.com>2014-08-08 11:19:37 +0200
commit25791550e085930c196b9234465f6538fe8ee383 (patch)
tree12e9a24256f32a9ab223755fb659c749fdc3cd87
parent4bb6844e4354738b1fc7400be016277e22fa585b (diff)
downloadredis-25791550e085930c196b9234465f6538fe8ee383.tar.gz
pubsub: Return integers for NUMSUB, not strings
Also adds test for numsub — due to tcl being tcl, it doesn't capture the "numberness" of the fix, but now we at least have one test case for numsub. Closes #1561
-rw-r--r--src/pubsub.c2
-rw-r--r--tests/unit/pubsub.tcl4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/pubsub.c b/src/pubsub.c
index 720cd5185..d6cfbdf3c 100644
--- a/src/pubsub.c
+++ b/src/pubsub.c
@@ -358,7 +358,7 @@ void pubsubCommand(redisClient *c) {
list *l = dictFetchValue(server.pubsub_channels,c->argv[j]);
addReplyBulk(c,c->argv[j]);
- addReplyBulkLongLong(c,l ? listLength(l) : 0);
+ addReplyLongLong(c,l ? listLength(l) : 0);
}
} else if (!strcasecmp(c->argv[1]->ptr,"numpat") && c->argc == 2) {
/* PUBSUB NUMPAT */
diff --git a/tests/unit/pubsub.tcl b/tests/unit/pubsub.tcl
index 18033bdf2..9c7a43bf0 100644
--- a/tests/unit/pubsub.tcl
+++ b/tests/unit/pubsub.tcl
@@ -196,6 +196,10 @@ start_server {tags {"pubsub"}} {
$rd1 close
}
+ test "NUMSUB returns numbers, not strings (#1561)" {
+ r pubsub numsub abc def
+ } {abc 0 def 0}
+
test "Mix SUBSCRIBE and PSUBSCRIBE" {
set rd1 [redis_deferring_client]
assert_equal {1} [subscribe $rd1 {foo.bar}]