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
2537b214
Unverified
Commit
2537b214
authored
Mar 13, 2019
by
Salvatore Sanfilippo
Committed by
GitHub
Mar 13, 2019
Browse files
Merge pull request #5787 from soloestoy/bugfix-xgroup-create-with-mkstream
Streams: checkType before XGROUP CREATE
parents
71499ab1
645d44d5
Changes
1
Show whitespace changes
Inline
Side-by-side
src/t_stream.c
View file @
2537b214
...
@@ -1737,14 +1737,17 @@ NULL
...
@@ -1737,14 +1737,17 @@ NULL
/* Everything but the "HELP" option requires a key and group name. */
/* Everything but the "HELP" option requires a key and group name. */
if
(
c
->
argc
>=
4
)
{
if
(
c
->
argc
>=
4
)
{
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
if
(
o
)
s
=
o
->
ptr
;
if
(
o
)
{
if
(
checkType
(
c
,
o
,
OBJ_STREAM
))
return
;
s
=
o
->
ptr
;
}
grpname
=
c
->
argv
[
3
]
->
ptr
;
grpname
=
c
->
argv
[
3
]
->
ptr
;
}
}
/* Check for missing key/group. */
/* Check for missing key/group. */
if
(
c
->
argc
>=
4
&&
!
mkstream
)
{
if
(
c
->
argc
>=
4
&&
!
mkstream
)
{
/* At this point key must exist, or there is an error. */
/* At this point key must exist, or there is an error. */
if
(
o
==
NULL
)
{
if
(
s
==
NULL
)
{
addReplyError
(
c
,
addReplyError
(
c
,
"The XGROUP subcommand requires the key to exist. "
"The XGROUP subcommand requires the key to exist. "
"Note that for CREATE you may want to use the MKSTREAM "
"Note that for CREATE you may want to use the MKSTREAM "
...
@@ -1752,8 +1755,6 @@ NULL
...
@@ -1752,8 +1755,6 @@ NULL
return
;
return
;
}
}
if
(
checkType
(
c
,
o
,
OBJ_STREAM
))
return
;
/* Certain subcommands require the group to exist. */
/* Certain subcommands require the group to exist. */
if
((
cg
=
streamLookupCG
(
s
,
grpname
))
==
NULL
&&
if
((
cg
=
streamLookupCG
(
s
,
grpname
))
==
NULL
&&
(
!
strcasecmp
(
opt
,
"SETID"
)
||
(
!
strcasecmp
(
opt
,
"SETID"
)
||
...
@@ -1781,7 +1782,8 @@ NULL
...
@@ -1781,7 +1782,8 @@ NULL
}
}
/* Handle the MKSTREAM option now that the command can no longer fail. */
/* Handle the MKSTREAM option now that the command can no longer fail. */
if
(
s
==
NULL
&&
mkstream
)
{
if
(
s
==
NULL
)
{
serverAssert
(
mkstream
);
o
=
createStreamObject
();
o
=
createStreamObject
();
dbAdd
(
c
->
db
,
c
->
argv
[
2
],
o
);
dbAdd
(
c
->
db
,
c
->
argv
[
2
],
o
);
s
=
o
->
ptr
;
s
=
o
->
ptr
;
...
...
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