diff options
author | Binbin <binloveplay1314@qq.com> | 2021-11-18 16:13:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 10:13:16 +0200 |
commit | 91e77a0cfb5c7e4bc6473ae04353e48ad9e8697b (patch) | |
tree | 1c97446e9c788eaa0789fa26c645d4523ed0e149 /src/t_stream.c | |
parent | 32215e788955acd7845d3839ba1f78e137ca0dfb (diff) | |
download | redis-91e77a0cfb5c7e4bc6473ae04353e48ad9e8697b.tar.gz |
Fixes ZPOPMIN/ZPOPMAX wrong replies when count is 0 with non-zset (#9711)
Moves ZPOP ... 0 fast exit path after type check to reply with
WRONGTYPE. In the past it will return an empty array.
Also now count is not allowed to be negative.
see #9680
before:
```
127.0.0.1:6379> set zset str
OK
127.0.0.1:6379> zpopmin zset 0
(empty array)
127.0.0.1:6379> zpopmin zset -1
(empty array)
```
after:
```
127.0.0.1:6379> set zset str
OK
127.0.0.1:6379> zpopmin zset 0
(error) WRONGTYPE Operation against a key holding the wrong kind of value
127.0.0.1:6379> zpopmin zset -1
(error) ERR value is out of range, must be positive
```
Diffstat (limited to 'src/t_stream.c')
-rw-r--r-- | src/t_stream.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_stream.c b/src/t_stream.c index 900e23d0e..776030c94 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -2182,7 +2182,7 @@ void xreadCommand(client *c) { goto cleanup; } blockForKeys(c, BLOCKED_STREAM, c->argv+streams_arg, streams_count, - 0, timeout, NULL, NULL, ids); + -1, timeout, NULL, NULL, ids); /* If no COUNT is given and we block, set a relatively small count: * in case the ID provided is too low, we do not want the server to * block just to serve this client a huge stream of messages. */ |