diff options
author | antirez <antirez@gmail.com> | 2011-05-13 12:53:07 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-05-13 12:53:07 +0200 |
commit | 430719ca53dfe1cb6f5c0ecaa6db92e117c89e77 (patch) | |
tree | 064506155fa224129e03bcd19370848fa5585e59 | |
parent | cc8a0f898b0aa881064da23dba23f183b13e3195 (diff) | |
download | redis-430719ca53dfe1cb6f5c0ecaa6db92e117c89e77.tar.gz |
Fixed bug introduced with the copy-on-write friendly iteartor
-rw-r--r-- | src/t_zset.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/t_zset.c b/src/t_zset.c index 962ad4622..be92e4521 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -686,7 +686,18 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) { score = src[0].weight * zunionInterDictValue(de); for (j = 1; j < setnum; j++) { - dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de)); + dictEntry *other; + + /* If it's the same dictionary don't lookup as we are not + * in the context of a safe iterator. It's the same + * dictionary so we are sure the element is inside. + * This happens on SINTERSTORE dest 2 mykey mykey. */ + if (src[j].dict == src[0].dict) { + other = de; + } else { + other = dictFind(src[j].dict,dictGetEntryKey(de)); + } + if (other) { value = src[j].weight * zunionInterDictValue(other); zunionInterAggregate(&score,value,aggregate); |