From 9e25f3e1defd29d4cf37380870141c40bf97f121 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 5 Jun 2018 16:34:31 +0200 Subject: [PATCH] Remove XINFO special form. As observed by Michael Grunder this usage while practical is inconsistent because for instance it does not work against a key called HELP. Removed. --- src/t_stream.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/t_stream.c b/src/t_stream.c index 04125bfa..fe702110 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -2131,14 +2131,12 @@ void xtrimCommand(client *c) { /* XINFO CONSUMERS key group * XINFO GROUPS * XINFO STREAM - * XINFO (alias of XINFO STREAM key) * XINFO HELP. */ void xinfoCommand(client *c) { const char *help[] = { "CONSUMERS -- Show consumer groups of group .", "GROUPS -- Show the stream consumer groups.", "STREAM -- Show information about the stream.", -" -- Alias for STREAM .", "HELP -- Print this help.", NULL }; @@ -2150,16 +2148,15 @@ NULL if (!strcasecmp(c->argv[1]->ptr,"HELP")) { addReplyHelp(c, help); return; + } else if (c->argc < 3) { + addReplyError(c,"syntax error, try 'XINFO HELP'"); + return; } - /* Handle the fact that no subcommand means "STREAM". */ - if (c->argc == 2) { - opt = "STREAM"; - key = c->argv[1]; - } else { - opt = c->argv[1]->ptr; - key = c->argv[2]; - } + /* With the exception of HELP handled before any other sub commands, all + * the ones are in the form of " ". */ + opt = c->argv[1]->ptr; + key = c->argv[2]; /* Lookup the key now, this is common for all the subcommands but HELP. */ robj *o = lookupKeyWriteOrReply(c,key,shared.nokeyerr); @@ -2218,9 +2215,7 @@ NULL addReplyLongLong(c,raxSize(cg->pel)); } raxStop(&ri); - } else if (c->argc == 2 || - (!strcasecmp(opt,"STREAM") && c->argc == 3)) - { + } else if (!strcasecmp(opt,"STREAM") && c->argc == 3) { /* XINFO STREAM (or the alias XINFO ). */ addReplyMultiBulkLen(c,12); addReplyStatus(c,"length");