From 6501b6bb6d8d8243c47402e25e9d54e7309f727f Mon Sep 17 00:00:00 2001 From: "dejun.xdj" Date: Tue, 17 Jul 2018 18:19:10 +0800 Subject: [PATCH 1/2] Streams: return an error message if using xreadgroup with '$' ID. Redis will always return an empty result when '$' ID is specified with xreadgroup command, it's meaningless. --- src/t_stream.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/t_stream.c b/src/t_stream.c index 44251586..8540cfc6 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -1351,6 +1351,11 @@ void xreadCommand(client *c) { } if (strcmp(c->argv[i]->ptr,"$") == 0) { + if (xreadgroup) { + addReplyError(c,"The $ ID can be specified only when calling " + "XREAD without GROUP option."); + goto cleanup; + } if (o) { stream *s = o->ptr; ids[id_idx] = s->last_id; From 846cf12ae592b8a97c9e932f08b7533902733c17 Mon Sep 17 00:00:00 2001 From: "dejun.xdj" Date: Tue, 17 Jul 2018 18:23:47 +0800 Subject: [PATCH 2/2] Streams: remove meaningless if condition. It's already checked if xreadgroup is set and groupname is NULL. --- src/t_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t_stream.c b/src/t_stream.c index 8540cfc6..ed0aa214 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -1365,7 +1365,7 @@ void xreadCommand(client *c) { } continue; } else if (strcmp(c->argv[i]->ptr,">") == 0) { - if (!xreadgroup || groupname == NULL) { + if (!xreadgroup) { addReplyError(c,"The > ID can be specified only when calling " "XREADGROUP using the GROUP " " option.");