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

BITCOUNT return wrong when args > 4 #1978

Closed
1 of 2 tasks
jihuayu opened this issue Jan 3, 2024 · 2 comments · Fixed by #1979
Closed
1 of 2 tasks

BITCOUNT return wrong when args > 4 #1978

jihuayu opened this issue Jan 3, 2024 · 2 comments · Fixed by #1979
Labels
bug type bug

Comments

@jihuayu
Copy link
Member

jihuayu commented Jan 3, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

unstable

Minimal reproduce step

127.0.0.1:6666> SET mykey "foobar"
OK
127.0.0.1:6666> BITCOUNT mykey 5 30
(integer) 4
127.0.0.1:6666> BITCOUNT mykey 5 30 111
(integer) 26

What did you expect to see?

BITCOUNT mykey 5 30 111 return 4

What did you see instead?

BITCOUNT mykey 5 30 111 return ERROR

Anything Else?

class CommandBitCount : public Commander {
public:
Status Parse(const std::vector<std::string> &args) override {
if (args.size() == 3) {
return {Status::RedisParseErr, errInvalidSyntax};
}
if (args.size() == 4) {
auto parse_start = ParseInt<int64_t>(args[2], 10);
if (!parse_start) {
return {Status::RedisParseErr, errValueNotInteger};
}
start_ = *parse_start;
auto parse_stop = ParseInt<int64_t>(args[3], 10);
if (!parse_stop) {
return {Status::RedisParseErr, errValueNotInteger};
}
stop_ = *parse_stop;
}
return Commander::Parse(args);
}

We need return ERROR when args.size() > 4

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@jihuayu jihuayu added the bug type bug label Jan 3, 2024
@tisonkun
Copy link
Member

tisonkun commented Jan 3, 2024

Below is how Redis works:

127.0.0.1:6379> SET mykey "foobar"
OK
127.0.0.1:6379>  BITCOUNT mykey 5 30
(integer) 4
127.0.0.1:6379>  BITCOUNT mykey 5 30 111
(error) ERR syntax error

@jihuayu would you like to fix it? Or I can take a look.

@jihuayu
Copy link
Member Author

jihuayu commented Jan 3, 2024

@tisonkun Go ahead. Thank you!
I will not fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug type bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants