Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
aca6cb52
Commit
aca6cb52
authored
Mar 10, 2014
by
Salvatore Sanfilippo
Browse files
Merge pull request #1586 from mattsta/fix-zunioninterstorekeys
Fix key extraction for z{union,inter}store
parents
c1a7d3e6
f0782a6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
aca6cb52
...
...
@@ -993,9 +993,23 @@ int *zunionInterGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *num
*
numkeys
=
0
;
return
NULL
;
}
keys
=
zmalloc
(
sizeof
(
int
)
*
num
);
/* Keys in z{union,inter}store come from two places:
argv[1] = storage key,
argv[3...n] = keys to intersect */
/* (num+1) is (argv[2] + 1) to account for argv[1] too */
keys
=
zmalloc
(
sizeof
(
int
)
*
(
num
+
1
));
/* Add all key positions for argv[3...n] to keys[] */
for
(
i
=
0
;
i
<
num
;
i
++
)
keys
[
i
]
=
3
+
i
;
*
numkeys
=
num
;
/* Now add the argv[1] key position (the storage key target)
to our list of command positions containing keys.
num is the number of source keys, but we initialized
keys[] to size num+1, so keys[num] is safe and valid and okay. */
keys
[
num
]
=
1
;
*
numkeys
=
num
+
1
;
/* Total keys = {union,inter} keys + storage key */
return
keys
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment