Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
70016f78
Unverified
Commit
70016f78
authored
Nov 19, 2019
by
Salvatore Sanfilippo
Committed by
GitHub
Nov 19, 2019
Browse files
Merge pull request #6574 from guybe7/fix_xadd_empty_id
XADD with ID 0-0 stores an empty key
parents
64a78f5b
4a12047c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/t_stream.c
View file @
70016f78
...
...
@@ -1220,6 +1220,14 @@ void xaddCommand(client *c) {
return
;
}
/* Return ASAP if minimal ID (0-0) was given so we avoid possibly creating
* a new stream and have streamAppendItem fail, leaving an empty key in the
* database. */
if
(
id_given
&&
id
.
ms
==
0
&&
id
.
seq
==
0
)
{
addReplyError
(
c
,
"The ID specified in XADD must be greater than 0-0"
);
return
;
}
/* Lookup the stream at key. */
robj
*
o
;
stream
*
s
;
...
...
tests/unit/type/stream.tcl
View file @
70016f78
...
...
@@ -123,6 +123,12 @@ start_server {
assert
{[
r xlen mystream
]
== $j
}
}
test
{
XADD with ID 0-0
}
{
r DEL mystream
catch
{
r XADD mystream 0-0 k v
}
err
assert
{[
r EXISTS mystream
]
== 0
}
}
test
{
XRANGE COUNT works as expected
}
{
assert
{[
llength
[
r xrange mystream - + COUNT 10
]]
== 10
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment