summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-10-23 01:41:17 +0800
committerGitHub <noreply@github.com>2022-10-22 20:41:17 +0300
commit9e1b879f5bcbf105d5581c77f8c368b0ef1708f6 (patch)
treed5507669bcd33f522078388c1e07108740e5906d /src
parent6dd213558b0f77e2233743718e23556fb06a557e (diff)
downloadredis-9e1b879f5bcbf105d5581c77f8c368b0ef1708f6.tar.gz
Make PFMERGE source key optional in docs, add tests with one input key, add tests on missing source keys (#11205)
The following two cases will create an empty destkey HLL: 1. called with no source keys, like `pfmerge destkey` 2. called with non-existing source keys, like `pfmerge destkey non-existing-source-key` In the first case, in `PFMERGE`, the dest key is actually one of the source keys too. So `PFMERGE k1 k2` is equivalent to `SUNIONSTORE k1 k1 k2`, and `PFMERGE k1` is equivalent to `SUNIONSTORE k1 k1`. So the first case is reasonable, the source key is actually optional. And the second case, `PFMERGE` on missing keys should succeed and create an empty dest. This is consistent with `PFCOUNT`, and also with `SUNIONSTORE`, no need to change.
Diffstat (limited to 'src')
-rw-r--r--src/commands.c2
-rw-r--r--src/commands/pfmerge.json1
-rw-r--r--src/help.h2
3 files changed, 3 insertions, 2 deletions
diff --git a/src/commands.c b/src/commands.c
index 5ee012c79..b9b4b915d 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -2608,7 +2608,7 @@ struct redisCommandArg PFDEBUG_Args[] = {
/* PFMERGE argument table */
struct redisCommandArg PFMERGE_Args[] = {
{"destkey",ARG_TYPE_KEY,0,NULL,NULL,NULL,CMD_ARG_NONE},
-{"sourcekey",ARG_TYPE_KEY,1,NULL,NULL,NULL,CMD_ARG_MULTIPLE},
+{"sourcekey",ARG_TYPE_KEY,1,NULL,NULL,NULL,CMD_ARG_OPTIONAL|CMD_ARG_MULTIPLE},
{0}
};
diff --git a/src/commands/pfmerge.json b/src/commands/pfmerge.json
index ae18dad1e..648a8b43a 100644
--- a/src/commands/pfmerge.json
+++ b/src/commands/pfmerge.json
@@ -62,6 +62,7 @@
"name": "sourcekey",
"type": "key",
"key_spec_index": 1,
+ "optional": true,
"multiple": true
}
]
diff --git a/src/help.h b/src/help.h
index a95da3695..e8a94210e 100644
--- a/src/help.h
+++ b/src/help.h
@@ -1125,7 +1125,7 @@ struct commandHelp {
11,
"2.8.9" },
{ "PFMERGE",
- "destkey sourcekey [sourcekey ...]",
+ "destkey [sourcekey [sourcekey ...]]",
"Merge N different HyperLogLogs into a single one.",
11,
"2.8.9" },