From a3da3e592d310fd6e99ba17643baf6285c0dc5a8 Mon Sep 17 00:00:00 2001 From: Huang Zhw Date: Mon, 5 Apr 2021 13:30:41 +0800 Subject: [PATCH] redis-cli --bigkeys / memkeys, report detailed error on dbsize failure (#8740) When DBSIZE failed (e.g. on AUTH error), the printed error didn't reflect the reason. --- src/redis-cli.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index c2a7d2df8..7e1fe3934 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -7417,8 +7417,14 @@ static int getDbSize(void) { reply = redisCommand(context, "DBSIZE"); - if(reply == NULL || reply->type != REDIS_REPLY_INTEGER) { - fprintf(stderr, "Couldn't determine DBSIZE!\n"); + if (reply == NULL) { + fprintf(stderr, "\nI/O error\n"); + exit(1); + } else if (reply->type == REDIS_REPLY_ERROR) { + fprintf(stderr, "Couldn't determine DBSIZE: %s\n", reply->str); + exit(1); + } else if (reply->type != REDIS_REPLY_INTEGER) { + fprintf(stderr, "Non INTEGER response from DBSIZE!\n"); exit(1); }