Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c2f1815b
Unverified
Commit
c2f1815b
authored
May 30, 2023
by
Oran Agra
Committed by
GitHub
May 30, 2023
Browse files
Avoid trying to trim string loaded from RDB file. (#12241)
This is a followup fix for #11817
parent
0dfb0250
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/object.c
View file @
c2f1815b
...
@@ -629,7 +629,7 @@ void trimStringObjectIfNeeded(robj *o, int trim_small_values) {
...
@@ -629,7 +629,7 @@ void trimStringObjectIfNeeded(robj *o, int trim_small_values) {
}
}
/* Try to encode a string object in order to save space */
/* Try to encode a string object in order to save space */
robj
*
tryObjectEncoding
(
robj
*
o
)
{
robj
*
tryObjectEncoding
Ex
(
robj
*
o
,
int
try_trim
)
{
long
value
;
long
value
;
sds
s
=
o
->
ptr
;
sds
s
=
o
->
ptr
;
size_t
len
;
size_t
len
;
...
@@ -694,12 +694,17 @@ robj *tryObjectEncoding(robj *o) {
...
@@ -694,12 +694,17 @@ robj *tryObjectEncoding(robj *o) {
/* We can't encode the object...
/* We can't encode the object...
* Do the last try, and at least optimize the SDS string inside */
* Do the last try, and at least optimize the SDS string inside */
trimStringObjectIfNeeded
(
o
,
0
);
if
(
try_trim
)
trimStringObjectIfNeeded
(
o
,
0
);
/* Return the original object. */
/* Return the original object. */
return
o
;
return
o
;
}
}
robj
*
tryObjectEncoding
(
robj
*
o
)
{
return
tryObjectEncodingEx
(
o
,
1
);
}
/* Get a decoded version of an encoded object (returned as a new object).
/* Get a decoded version of an encoded object (returned as a new object).
* If the object is already raw-encoded just increment the ref count. */
* If the object is already raw-encoded just increment the ref count. */
robj
*
getDecodedObject
(
robj
*
o
)
{
robj
*
getDecodedObject
(
robj
*
o
)
{
...
...
src/rdb.c
View file @
c2f1815b
...
@@ -1844,7 +1844,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
...
@@ -1844,7 +1844,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) {
if
(
rdbtype
==
RDB_TYPE_STRING
)
{
if
(
rdbtype
==
RDB_TYPE_STRING
)
{
/* Read string value */
/* Read string value */
if
((
o
=
rdbLoadEncodedStringObject
(
rdb
))
==
NULL
)
return
NULL
;
if
((
o
=
rdbLoadEncodedStringObject
(
rdb
))
==
NULL
)
return
NULL
;
o
=
tryObjectEncoding
(
o
);
o
=
tryObjectEncoding
Ex
(
o
,
0
);
}
else
if
(
rdbtype
==
RDB_TYPE_LIST
)
{
}
else
if
(
rdbtype
==
RDB_TYPE_LIST
)
{
/* Read list value */
/* Read list value */
if
((
len
=
rdbLoadLen
(
rdb
,
NULL
))
==
RDB_LENERR
)
return
NULL
;
if
((
len
=
rdbLoadLen
(
rdb
,
NULL
))
==
RDB_LENERR
)
return
NULL
;
...
...
src/server.h
View file @
c2f1815b
...
@@ -2738,6 +2738,7 @@ robj *dupStringObject(const robj *o);
...
@@ -2738,6 +2738,7 @@ robj *dupStringObject(const robj *o);
int
isSdsRepresentableAsLongLong
(
sds
s
,
long
long
*
llval
);
int
isSdsRepresentableAsLongLong
(
sds
s
,
long
long
*
llval
);
int
isObjectRepresentableAsLongLong
(
robj
*
o
,
long
long
*
llongval
);
int
isObjectRepresentableAsLongLong
(
robj
*
o
,
long
long
*
llongval
);
robj
*
tryObjectEncoding
(
robj
*
o
);
robj
*
tryObjectEncoding
(
robj
*
o
);
robj
*
tryObjectEncodingEx
(
robj
*
o
,
int
try_trim
);
robj
*
getDecodedObject
(
robj
*
o
);
robj
*
getDecodedObject
(
robj
*
o
);
size_t
stringObjectLen
(
robj
*
o
);
size_t
stringObjectLen
(
robj
*
o
);
robj
*
createStringObjectFromLongLong
(
long
long
value
);
robj
*
createStringObjectFromLongLong
(
long
long
value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment