} else {
dictEntry *de = dictFind(o->ptr,key);
if (de == NULL) return -1;
- *objval = dictGetEntryVal(de);
+ *objval = dictGetVal(de);
}
return o->encoding;
}
} else if (hi->encoding == REDIS_ENCODING_HT) {
hi->di = dictGetIterator(subject->ptr);
} else {
- redisAssert(NULL);
+ redisAssertWithInfo(NULL,subject,0);
}
return hi;
}
}
} else {
if (what & REDIS_HASH_KEY)
- *objval = dictGetEntryKey(hi->de);
+ *objval = dictGetKey(hi->de);
else
- *objval = dictGetEntryVal(hi->de);
+ *objval = dictGetVal(hi->de);
}
return hi->encoding;
}
unsigned int klen, vlen;
dict *dict = dictCreate(&hashDictType,NULL);
- redisAssert(o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
+ redisAssertWithInfo(NULL,o,o->type == REDIS_HASH && o->encoding != REDIS_ENCODING_HT);
p = zipmapRewind(zm);
while((p = zipmapNext(p,&key,&klen,&val,&vlen)) != NULL) {
robj *keyobj, *valobj;
void hdelCommand(redisClient *c) {
robj *o;
+ int j, deleted = 0;
+
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
checkType(c,o,REDIS_HASH)) return;
- if (hashTypeDelete(o,c->argv[2])) {
- if (hashTypeLength(o) == 0) dbDelete(c->db,c->argv[1]);
- addReply(c,shared.cone);
+ for (j = 2; j < c->argc; j++) {
+ if (hashTypeDelete(o,c->argv[j])) {
+ deleted++;
+ if (hashTypeLength(o) == 0) {
+ dbDelete(c->db,c->argv[1]);
+ break;
+ }
+ }
+ }
+ if (deleted) {
signalModifiedKey(c->db,c->argv[1]);
- server.dirty++;
- } else {
- addReply(c,shared.czero);
+ server.dirty += deleted;
}
+ addReplyLongLong(c,deleted);
}
void hlenCommand(redisClient *c) {