]> git.saurik.com Git - redis.git/blobdiff - redis.c
Fix for HGET against non Hash type, debug messages used to understand a bit better...
[redis.git] / redis.c
diff --git a/redis.c b/redis.c
index 48f2e4158acd3778fc9df65f9e08077f47d67c52..73b66177b67f1539d2b827c87df7d7f5108e7a42 100644 (file)
--- a/redis.c
+++ b/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;