mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
make sure the value to insert is string encoded
This commit is contained in:
parent
bcfb387694
commit
244b873b0c
2
redis.c
2
redis.c
@ -5091,6 +5091,7 @@ static robj *listTypeGet(listTypeEntry *entry) {
|
|||||||
static void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
|
static void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
|
||||||
robj *subject = entry->li->subject;
|
robj *subject = entry->li->subject;
|
||||||
if (entry->li->encoding == REDIS_ENCODING_ZIPLIST) {
|
if (entry->li->encoding == REDIS_ENCODING_ZIPLIST) {
|
||||||
|
value = getDecodedObject(value);
|
||||||
if (where == REDIS_TAIL) {
|
if (where == REDIS_TAIL) {
|
||||||
unsigned char *next = ziplistNext(subject->ptr,entry->zi);
|
unsigned char *next = ziplistNext(subject->ptr,entry->zi);
|
||||||
|
|
||||||
@ -5104,6 +5105,7 @@ static void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
|
|||||||
} else {
|
} else {
|
||||||
subject->ptr = ziplistInsert(subject->ptr,entry->zi,value->ptr,sdslen(value->ptr));
|
subject->ptr = ziplistInsert(subject->ptr,entry->zi,value->ptr,sdslen(value->ptr));
|
||||||
}
|
}
|
||||||
|
decrRefCount(value);
|
||||||
} else if (entry->li->encoding == REDIS_ENCODING_LIST) {
|
} else if (entry->li->encoding == REDIS_ENCODING_LIST) {
|
||||||
if (where == REDIS_TAIL) {
|
if (where == REDIS_TAIL) {
|
||||||
listInsertNode(subject->ptr,entry->ln,value,AL_START_TAIL);
|
listInsertNode(subject->ptr,entry->ln,value,AL_START_TAIL);
|
||||||
|
@ -73,6 +73,8 @@ start_server {
|
|||||||
assert_equal 8 [r linsert xlist before a aa]
|
assert_equal 8 [r linsert xlist before a aa]
|
||||||
assert_equal 8 [r linsert xlist before bad aaa]
|
assert_equal 8 [r linsert xlist before bad aaa]
|
||||||
assert_equal {aa a b zz c yy d dd} [r lrange xlist 0 10]
|
assert_equal {aa a b zz c yy d dd} [r lrange xlist 0 10]
|
||||||
|
assert_equal 9 [r linsert xlist before aa 42]
|
||||||
|
assert_equal 42 [r lrange xlist 0 0]
|
||||||
}
|
}
|
||||||
|
|
||||||
test {LPUSHX, RPUSHX, LPUSHXAFTER, RPUSHXAFTER - regular list} {
|
test {LPUSHX, RPUSHX, LPUSHXAFTER, RPUSHXAFTER - regular list} {
|
||||||
@ -98,6 +100,8 @@ start_server {
|
|||||||
assert_equal 8 [r linsert xlist before a aa]
|
assert_equal 8 [r linsert xlist before a aa]
|
||||||
assert_equal 8 [r linsert xlist before bad aaa]
|
assert_equal 8 [r linsert xlist before bad aaa]
|
||||||
assert_equal {aa a aaaaaaaaaaaaaaaaa zz c yy d dd} [r lrange xlist 0 10]
|
assert_equal {aa a aaaaaaaaaaaaaaaaa zz c yy d dd} [r lrange xlist 0 10]
|
||||||
|
assert_equal 9 [r linsert xlist before aa 42]
|
||||||
|
assert_equal 42 [r lrange xlist 0 0]
|
||||||
}
|
}
|
||||||
|
|
||||||
test {DEL a list - ziplist} {
|
test {DEL a list - ziplist} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user