Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ZMPOP/BZMPOP duplicate parameters #1543

Merged
merged 3 commits into from
Jul 5, 2023

Conversation

enjoy-binbin
Copy link
Member

We did not check for repeated parameters before, so the
following code is executable:

127.0.0.1:6666> zmpop 1 zset min max
(nil)
127.0.0.1:6666> zmpop 1 zset min count 10 count 100
(nil)
127.0.0.1:6666> zmpop 1 zset min min max max min
(nil)
127.0.0.1:6666> zmpop 1 zset min count 10 count 100 max
(nil)
127.0.0.1:6666> bzmpop 0.1 1 zset min max
(nil)
127.0.0.1:6666> bzmpop 0.1 1 zset min count 1 count 10
(nil)

Now we don't allow duplicate parameters (throw a syntax error):

127.0.0.1:6666> zmpop 1 zset min max
(error) ERR syntax error
127.0.0.1:6666> zmpop 1 zset min count 10 count 100
(error) ERR syntax error
127.0.0.1:6666> zmpop 1 zset min min max max min
(error) ERR syntax error
127.0.0.1:6666> zmpop 1 zset min count 10 count 100 max
(error) ERR syntax error
127.0.0.1:6666> bzmpop 0.1 1 zset min max
(error) ERR syntax error
127.0.0.1:6666> bzmpop 0.1 1 zset min count 1 count 10
(error) ERR syntax error

Also added some tests to cover these wrong error paths.
Refs: ZMPOP was added in #1468 and BZMPOP was added in #1490.

We did not check for repeated parameters before, so the
following code is executable:
```
127.0.0.1:6666> zmpop 1 zset min max
(nil)
127.0.0.1:6666> zmpop 1 zset min count 10 count 100
(nil)
127.0.0.1:6666> zmpop 1 zset min min max max min
(nil)
127.0.0.1:6666> zmpop 1 zset min count 10 count 100 max
(nil)
127.0.0.1:6666> bzmpop 0.1 1 zset min max
(nil)
127.0.0.1:6666> bzmpop 0.1 1 zset min count 1 count 10
(nil)
```

Now we don't allow duplicate parameters (throw a syntax error):
```
127.0.0.1:6666> zmpop 1 zset min max
(error) ERR syntax error
127.0.0.1:6666> zmpop 1 zset min count 10 count 100
(error) ERR syntax error
127.0.0.1:6666> zmpop 1 zset min min max max min
(error) ERR syntax error
127.0.0.1:6666> zmpop 1 zset min count 10 count 100 max
(error) ERR syntax error
127.0.0.1:6666> bzmpop 0.1 1 zset min max
(error) ERR syntax error
127.0.0.1:6666> bzmpop 0.1 1 zset min count 1 count 10
(error) ERR syntax error
```

Also added some tests to cover these wrong error paths.
Refs: ZMPOP was added in apache#1468 and BZMPOP was added in apache#1490.
@enjoy-binbin
Copy link
Member Author

This may not be that important, since there may be other commands that have this problem (redis itself also have it),
but at least for ZMPOP and BZMPOP, this behavior can be consistent (i just happened to see it, a cleanup)

torwig
torwig previously approved these changes Jul 5, 2023
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

git-hulk
git-hulk previously approved these changes Jul 5, 2023
@git-hulk git-hulk dismissed stale reviews from torwig and themself via bbb6617 July 5, 2023 08:00
@git-hulk git-hulk merged commit 74f710f into apache:unstable Jul 5, 2023
@enjoy-binbin enjoy-binbin deleted the fix_mpop_dup_args branch July 5, 2023 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants