Skip to content
New issue

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

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

Already on GitHub? # to your account

zremrangebylex bug, result not the same as official redis #466

Open
0xtonyxia opened this issue Jun 13, 2019 · 0 comments
Open

zremrangebylex bug, result not the same as official redis #466

0xtonyxia opened this issue Jun 13, 2019 · 0 comments

Comments

@0xtonyxia
Copy link

How to reproduce?
generate a test sorted set.
execute zremrangebylex myzset [ [, official redis won't delete any member.

i believe the bug is here,

       if (max.empty()) {
            in_range = str >= min ? 0 : -1;

complete code :

struct ZLexRangeSpec {
    std::string min;
    std::string max;
    bool include_min;
    bool include_max;
    ZLexRangeSpec()
        : include_min(false), include_max(false) {
    }
    bool Parse(const std::string &minstr, const std::string &maxstr);
    int InRange(const std::string &str) const {
        int in_range = -1;

        if (max.empty()) {
            in_range = str >= min ? 0 : -1;
        } else {
            if (str >= min) {
                if (str <= max) {
                    in_range = 0;
                } else {
                    in_range = 1;
                }
            } else {
                in_range = -1;
            }
        }

        if (0 == in_range) {
            if (!include_min && str == min) {
                return -1;
            }

            if (!include_max && str == max) {
                return 1;
            }
        }

        return in_range;
    }
};
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant