Commit 4404eb7
fix(string): add empty string value check for INCR to match Redis behavior (#3354)
### Background
Previously, Kvrocks allowed INCR on a key whose value was an empty
string (""),
treating it as zero and returning 1.
In Redis, the same operation results in an error:
ERR value is not an integer or out of range
This difference caused inconsistent behavior between Kvrocks and Redis.
### Changes
- Added check for empty string values before performing INCR
- Return error when value is an empty string, matching Redis behavior
### Result
Kvrocks now behaves consistently with Redis when performing INCR on
empty string values,
improving compatibility and reducing unexpected results in client
applications.
Co-authored-by: yxj25245 <yxj25245@ly.com>1 parent cf384eb commit 4404eb7
2 files changed
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
376 | 380 | | |
377 | 381 | | |
378 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| |||
0 commit comments