提交 bcd11906 编写于 作者: A antirez

Fix for HGET against non Hash type, debug messages used to understand a bit...

Fix for HGET against non Hash type, debug messages used to understand a bit better a corrupted rdb file
上级 b9eed483
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册