mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
fix to return error when calling INCR on a non-string type
This commit is contained in:
parent
1b67773229
commit
6485f29382
4
redis.c
4
redis.c
@ -4231,8 +4231,8 @@ static void incrDecrCommand(redisClient *c, long long incr) {
|
||||
robj *o;
|
||||
|
||||
o = lookupKeyWrite(c->db,c->argv[1]);
|
||||
|
||||
if (getLongLongFromObjectOrReply(c, o, &value, NULL) != REDIS_OK) return;
|
||||
if (o != NULL && checkType(c,o,REDIS_STRING)) return;
|
||||
if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return;
|
||||
|
||||
value += incr;
|
||||
o = createObject(REDIS_STRING,sdscatprintf(sdsempty(),"%lld",value));
|
||||
|
@ -373,7 +373,7 @@ proc main {} {
|
||||
|
||||
test {INCR fails against a key holding a list} {
|
||||
$r rpush mylist 1
|
||||
catch {$r incr novar} err
|
||||
catch {$r incr mylist} err
|
||||
$r rpop mylist
|
||||
format $err
|
||||
} {ERR*}
|
||||
|
Loading…
x
Reference in New Issue
Block a user