Skip to content

[BUG] SUBSTR returns wrong result with start 0 and end less than start #11738

@jimsnab

Description

@jimsnab

Describe the bug

SUBSTR returns an empty string when end is less than start. However, if start is 0, the first character is returned.

To reproduce

> set test cat
OK
> substr test 1 -500
""
> substr test 0 -500
"c"

Expected behavior

If end < start, SUBSTR should return an empty string.

Additional information

Redis server v=7.0.8 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=8b9bd5cdb53a6549

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions