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.
This commit is contained in:
Huang Zhw 2021-04-05 13:30:41 +08:00 committed by GitHub
parent 1cab962098
commit a3da3e592d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}