mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Fix for HGET against non Hash type, debug messages used to understand a bit better a corrupted rdb file
This commit is contained in:
parent
b9eed483ae
commit
bcd1190644
11
redis.c
11
redis.c
@ -3451,6 +3451,7 @@ static int rdbLoadDoubleValue(FILE *fp, double *val) {
|
||||
static robj *rdbLoadObject(int type, FILE *fp) {
|
||||
robj *o;
|
||||
|
||||
redisLog(REDIS_DEBUG,"LOADING OBJECT %d (at %d)\n",type,ftell(fp));
|
||||
if (type == REDIS_STRING) {
|
||||
/* Read string value */
|
||||
if ((o = rdbLoadStringObject(fp)) == NULL) return NULL;
|
||||
@ -3486,13 +3487,16 @@ static robj *rdbLoadObject(int type, FILE *fp) {
|
||||
o = createZsetObject();
|
||||
zs = o->ptr;
|
||||
/* Load every single element of the list/set */
|
||||
redisLog(REDIS_DEBUG,"SORTED SET LEN: %zu\n", zsetlen);
|
||||
while(zsetlen--) {
|
||||
robj *ele;
|
||||
double *score = zmalloc(sizeof(double));
|
||||
|
||||
if ((ele = rdbLoadStringObject(fp)) == NULL) return NULL;
|
||||
redisLog(REDIS_DEBUG,"ele %s (%d) (%d)\n", (char*)ele->ptr, ftell(fp), zsetlen);
|
||||
tryObjectEncoding(ele);
|
||||
if (rdbLoadDoubleValue(fp,score) == -1) return NULL;
|
||||
redisLog(REDIS_DEBUG,"score %.17g\n", *score);
|
||||
dictAdd(zs->dict,ele,score);
|
||||
zslInsert(zs->zsl,*score,ele);
|
||||
incrRefCount(ele); /* added to skiplist */
|
||||
@ -3540,6 +3544,7 @@ static robj *rdbLoadObject(int type, FILE *fp) {
|
||||
} else {
|
||||
redisAssert(0 != 0);
|
||||
}
|
||||
redisLog(REDIS_DEBUG,"DONE\n");
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -3594,6 +3599,7 @@ static int rdbLoad(char *filename) {
|
||||
}
|
||||
/* Read key */
|
||||
if ((keyobj = rdbLoadStringObject(fp)) == NULL) goto eoferr;
|
||||
redisLog(REDIS_DEBUG,"KEY: %s\n", (char*)keyobj->ptr);
|
||||
/* Read value */
|
||||
if ((o = rdbLoadObject(type,fp)) == NULL) goto eoferr;
|
||||
/* Add the new object in the hash table */
|
||||
@ -5952,6 +5958,11 @@ static void hgetCommand(redisClient *c) {
|
||||
addReply(c,shared.nullbulk);
|
||||
return;
|
||||
} else {
|
||||
if (o->type != REDIS_HASH) {
|
||||
addReply(c,shared.wrongtypeerr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (o->encoding == REDIS_ENCODING_ZIPMAP) {
|
||||
unsigned char *zm = o->ptr;
|
||||
unsigned char *val;
|
||||
|
Loading…
Reference in New Issue
Block a user