MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / cliSelect

Function cliSelect

src/redis-cli.c:620–640  ·  view source on GitHub ↗

Send SELECT input_dbnum to the server */

Source from the content-addressed store, hash-verified

618
619/* Send SELECT input_dbnum to the server */
620static int cliSelect(void) {
621 redisReply *reply;
622 if (config.input_dbnum == config.dbnum) return REDIS_OK;
623
624 reply = redisCommand(context,"SELECT %d",config.input_dbnum);
625 if (reply == NULL) {
626 fprintf(stderr, "\nI/O error\n");
627 return REDIS_ERR;
628 }
629
630 int result = REDIS_OK;
631 if (reply->type == REDIS_REPLY_ERROR) {
632 result = REDIS_ERR;
633 fprintf(stderr,"SELECT %d failed: %s\n",config.input_dbnum,reply->str);
634 } else {
635 config.dbnum = config.input_dbnum;
636 cliRefreshPrompt();
637 }
638 freeReplyObject(reply);
639 return result;
640}
641
642/* Select RESP3 mode if redis-cli was started with the -3 option. */
643static int cliSwitchProto(void) {

Callers 2

cliConnectFunction · 0.85
cliSendCommandFunction · 0.85

Calls 3

cliRefreshPromptFunction · 0.85
freeReplyObjectFunction · 0.85
redisCommandClass · 0.70

Tested by

no test coverage detected