diff options
author | Matt Stancliff <matt@genges.com> | 2014-03-28 23:08:56 -0400 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-08-07 11:58:28 +0200 |
commit | bbc1cd0bd9cb50e0734a98d066ccc7d0171fc652 (patch) | |
tree | e0633da68d77e0c79e1038c25a8fa62632f0f5bf /src | |
parent | 78a012d81a0f487b92b2b79a91de1f28697100e8 (diff) | |
download | redis-bbc1cd0bd9cb50e0734a98d066ccc7d0171fc652.tar.gz |
redis-cli: Re-attach selected DB after auth
Previously, if you did SELECT then AUTH, redis-cli
would show your SELECT'd db even though it didn't
happen.
Note: running into this situation is a (hopefully) very limited
used case of people using multiple DBs and AUTH all at the same
time.
Fixes antirez#1639
Diffstat (limited to 'src')
-rw-r--r-- | src/redis-cli.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c index 907e62b74..8c3e013eb 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -320,8 +320,10 @@ static int cliSelect() { reply = redisCommand(context,"SELECT %d",config.dbnum); if (reply != NULL) { + int result = REDIS_OK; + if (reply->type == REDIS_REPLY_ERROR) result = REDIS_ERR; freeReplyObject(reply); - return REDIS_OK; + return result; } return REDIS_ERR; } @@ -650,6 +652,8 @@ static int cliSendCommand(int argc, char **argv, int repeat) { if (!strcasecmp(command,"select") && argc == 2) { config.dbnum = atoi(argv[1]); cliRefreshPrompt(); + } else if (!strcasecmp(command,"auth") && argc == 2) { + cliSelect(); } } if (config.interval) usleep(config.interval); |